close connections for http/1.0 unless there is keep-alive

svn:r326
This commit is contained in:
Niels Provos 2007-02-13 06:25:16 +00:00
parent 19373b3dda
commit 36950cef58

13
http.c
View File

@ -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);