diff --git a/NEWS b/NEWS index 9dbf75e0..5263e3db 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ NEWS * fixed too aggresive caching of nested conditionals (#41) * fixed possible overflow in unix-socket path checks on BSD (#713) * fixed extra Content-Length header on 1xx, 204 and 304 (#1002) + * fixed handling of duplicate If-Modified-Since to return 304 * removed config-check if passwd files exist (#1188) diff --git a/src/request.c b/src/request.c index c195388e..42988732 100644 --- a/src/request.c +++ b/src/request.c @@ -922,6 +922,9 @@ int http_request_parse(server *srv, connection *con) { } else if (0 == strcasecmp(con->request.http_if_modified_since, ds->value->ptr)) { /* ignore it if they are the same */ + + ds->free((data_unset *)ds); + ds = NULL; } else { con->http_status = 400; con->keep_alive = 0; @@ -977,7 +980,7 @@ int http_request_parse(server *srv, connection *con) { } } - array_insert_unique(con->request.headers, (data_unset *)ds); + if (ds) array_insert_unique(con->request.headers, (data_unset *)ds); } else { /* empty header-fields are not allowed by HTTP-RFC, we just ignore them */ } diff --git a/tests/request.t b/tests/request.t index 8ece7218..f7bc19c8 100755 --- a/tests/request.t +++ b/tests/request.t @@ -339,12 +339,12 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ]; ok($tf->handle_http($t) == 0, 'HEAD with Content-Length'); $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; ok($tf->handle_http($t) == 0, 'Duplicate If-Mod-Since, with equal timestamps'); $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \0\r\n\r\n" );