From 23b0d867c5454423fe153849a7ed7114a10e056b Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Fri, 8 Feb 2019 23:18:36 -0500 Subject: [core] replace con->response.keep_alive set con->keep_alive = 0 to indicate backend request to close connection --- src/base.h | 2 -- src/connections-glue.c | 1 - src/connections.c | 17 ----------------- src/http-header-glue.c | 6 ++++-- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/base.h b/src/base.h index 827ce5da..1f56303b 100644 --- a/src/base.h +++ b/src/base.h @@ -50,8 +50,6 @@ typedef struct { typedef struct { off_t content_length; - int keep_alive; /* used by the subrequests in proxy, cgi and fcgi to say the subrequest was keep-alive or not */ - unsigned int htags; /* bitfield of flagged headers present in response */ array *headers; int send_chunked; diff --git a/src/connections-glue.c b/src/connections-glue.c index 8b4f9712..7d8a9e04 100644 --- a/src/connections-glue.c +++ b/src/connections-glue.c @@ -492,7 +492,6 @@ void connection_response_reset(server *srv, connection *con) { con->is_writable = 1; con->file_finished = 0; con->file_started = 0; - con->response.keep_alive = 0; if (con->physical.path) { /*(skip for mod_fastcgi authorizer)*/ buffer_clear(con->physical.doc_root); buffer_reset(con->physical.path); diff --git a/src/connections.c b/src/connections.c index ac032555..e9d18a61 100644 --- a/src/connections.c +++ b/src/connections.c @@ -422,22 +422,6 @@ static int connection_handle_write_prepare(server *srv, connection *con) { con->keep_alive = 0; } } - - /** - * if the backend sent a Connection: close, follow the wish - * - * NOTE: if the backend sent Connection: Keep-Alive, but no Content-Length, we - * will close the connection. That's fine. We can always decide the close - * the connection - * - * FIXME: to be nice we should remove the Connection: ... - */ - if (con->response.htags & HTTP_HEADER_CONNECTION) { - /* a subrequest disable keep-alive although the client wanted it */ - if (con->keep_alive && !con->response.keep_alive) { - con->keep_alive = 0; - } - } } if (con->request.http_method == HTTP_METHOD_HEAD) { @@ -1200,7 +1184,6 @@ static int connection_handle_request(server *srv, connection *con) { con->is_writable = 1; con->file_finished = 0; con->file_started = 0; - con->response.keep_alive = 0; con->error_handler_saved_status = con->http_status; con->error_handler_saved_method = con->request.http_method; diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 6aae9728..168c2520 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -988,8 +988,10 @@ static int http_response_process_headers(server *srv, connection *con, http_resp break; case HTTP_HEADER_CONNECTION: if (opts->backend == BACKEND_PROXY) continue; - con->response.keep_alive = - (0 == strcasecmp(value, "Keep-Alive")) ? 1 : 0; + /*(should parse for tokens and do case-insensitive match for "close" + * but this is an imperfect though simplistic attempt to honor + * backend request to close)*/ + if (NULL != strstr(value, "lose")) con->keep_alive = 0; break; case HTTP_HEADER_CONTENT_LENGTH: con->response.content_length = strtoul(value, NULL, 10); -- cgit v1.2.1