mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Fix conn->close logic:
. HTTP/1.1 protocol enables keep-alive. . `Connection: keep-alive' enables keep-alive, regardless of protocol. . `Connection: close' disables keep-alive.
This commit is contained in:
parent
3389cc39d4
commit
dd4a217817
@ -1245,6 +1245,7 @@ static void parse_range_field(struct connection *conn)
|
|||||||
static void parse_request(struct connection *conn)
|
static void parse_request(struct connection *conn)
|
||||||
{
|
{
|
||||||
size_t bound1, bound2;
|
size_t bound1, bound2;
|
||||||
|
char *tmp;
|
||||||
assert(conn->request_length == strlen(conn->request));
|
assert(conn->request_length == strlen(conn->request));
|
||||||
|
|
||||||
/* parse method */
|
/* parse method */
|
||||||
@ -1281,19 +1282,19 @@ static void parse_request(struct connection *conn)
|
|||||||
;
|
;
|
||||||
|
|
||||||
proto = split_string(conn->request, bound1, bound2);
|
proto = split_string(conn->request, bound1, bound2);
|
||||||
if (strcasecmp(proto, "HTTP/1.1") == 0)
|
if (strcasecmp(proto, "HTTP/1.1") == 0) conn->conn_close = 0;
|
||||||
{
|
|
||||||
char *tmp = parse_field(conn, "Connection: ");
|
|
||||||
conn->conn_close = 0;
|
|
||||||
if (tmp != NULL)
|
|
||||||
{
|
|
||||||
if (strcasecmp(tmp, "close") == 0) conn->conn_close = 1;
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(proto);
|
free(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* parse connection field */
|
||||||
|
tmp = parse_field(conn, "Connection: ");
|
||||||
|
if (tmp != NULL)
|
||||||
|
{
|
||||||
|
if (strcasecmp(tmp, "close") == 0) conn->conn_close = 1;
|
||||||
|
else if (strcasecmp(tmp, "keep-alive") == 0) conn->conn_close = 0;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
/* parse referer, user_agent */
|
/* parse referer, user_agent */
|
||||||
conn->referer = parse_field(conn, "Referer: ");
|
conn->referer = parse_field(conn, "Referer: ");
|
||||||
conn->user_agent = parse_field(conn, "User-Agent: ");
|
conn->user_agent = parse_field(conn, "User-Agent: ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user