From: Niels Provos Date: Tue, 13 Feb 2007 06:25:16 +0000 (+0000) Subject: close connections for http/1.0 unless there is keep-alive X-Git-Tag: release-2.0.1-alpha~649 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36950cef58fc02495dffcc143bb2ec147dc7e9ad;p=libevent close connections for http/1.0 unless there is keep-alive svn:r326 --- diff --git a/http.c b/http.c index 20771df2..cb98e276 100644 --- a/http.c +++ b/http.c @@ -316,6 +316,14 @@ evhttp_is_connection_close(struct evkeyvalq* headers) return (connection != NULL && strcasecmp(connection, "close") == 0); } +static int +evhttp_is_connection_keepalive(struct evkeyvalq* headers) +{ + const char *connection = evhttp_find_header(headers, "Connection"); + return (connection != NULL + && strncasecmp(connection, "keep-alive", 10) == 0); +} + /* * Create the headers needed for an HTTP reply */ @@ -1493,7 +1501,10 @@ evhttp_send_done(struct evhttp_connection *evcon, void *arg) /* delete possible close detection events */ evhttp_connection_stop_detectclose(evcon); - need_close = evhttp_is_connection_close(req->input_headers) || + need_close = + (req->minor == 0 && + !evhttp_is_connection_keepalive(req->input_headers))|| + evhttp_is_connection_close(req->input_headers) || evhttp_is_connection_close(req->output_headers); assert(req->flags & EVHTTP_REQ_OWN_CONNECTION);