uhttpd: add "Connection: close" headers, mandatory according to HTTP/1.1 spec

This commit is contained in:
Jo-Philipp Wich 2010-03-21 03:46:03 +00:00
parent 23052d8f01
commit 927d47528f
3 changed files with 8 additions and 3 deletions

View file

@ -430,7 +430,8 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
{ {
/* write status */ /* write status */
ensure(uh_http_sendf(cl, NULL, ensure(uh_http_sendf(cl, NULL,
"HTTP/%.1f %03d %s\r\n", "HTTP/%.1f %03d %s\r\n"
"Connection: close\r\n",
req->version, res->statuscode, req->version, res->statuscode,
res->statusmsg)); res->statusmsg));

View file

@ -101,6 +101,8 @@ static char * uh_file_header_lookup(struct http_request *req, const char *name)
static void uh_file_response_ok_hdrs(struct client *cl, struct http_request *req, struct stat *s) static void uh_file_response_ok_hdrs(struct client *cl, struct http_request *req, struct stat *s)
{ {
uh_http_sendf(cl, NULL, "Connection: close\r\n");
if( s ) if( s )
{ {
uh_http_sendf(cl, NULL, "ETag: %s\r\n", uh_file_mktag(s)); uh_http_sendf(cl, NULL, "ETag: %s\r\n", uh_file_mktag(s));
@ -124,8 +126,9 @@ static void uh_file_response_304(struct client *cl, struct http_request *req, st
static void uh_file_response_412(struct client *cl, struct http_request *req) static void uh_file_response_412(struct client *cl, struct http_request *req)
{ {
uh_http_sendf(cl, NULL, "HTTP/%.1f 412 Precondition Failed\r\n", uh_http_sendf(cl, NULL,
req->version); "HTTP/%.1f 412 Precondition Failed\r\n"
"Connection: close\r\n", req->version);
} }
static int uh_file_if_match(struct client *cl, struct http_request *req, struct stat *s) static int uh_file_if_match(struct client *cl, struct http_request *req, struct stat *s)

View file

@ -171,6 +171,7 @@ int uh_http_sendhf(struct client *cl, int code, const char *summary, const char
len = snprintf(buffer, sizeof(buffer), len = snprintf(buffer, sizeof(buffer),
"HTTP/1.1 %03i %s\r\n" "HTTP/1.1 %03i %s\r\n"
"Connection: close\r\n"
"Content-Type: text/plain\r\n" "Content-Type: text/plain\r\n"
"Transfer-Encoding: chunked\r\n\r\n", "Transfer-Encoding: chunked\r\n\r\n",
code, summary code, summary