diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 3f4957a1..31af16cf 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -158,10 +158,12 @@ int http_response_handle_cachable(server *srv, connection *con, buffer *mtime) { */ if ((vb = http_header_request_get(con, HTTP_HEADER_IF_NONE_MATCH, CONST_STR_LEN("If-None-Match")))) { - /* use strong etag checking for now: weak comparison must not be used - * for ranged requests - */ - if (etag_is_equal(con->physical.etag, vb->ptr, 0)) { + /*(weak etag comparison must not be used for ranged requests)*/ + int range_request = + (con->conf.range_requests + && (200 == con->http_status || 0 == con->http_status) + && NULL != http_header_request_get(con, HTTP_HEADER_RANGE, CONST_STR_LEN("Range"))); + if (etag_is_equal(con->physical.etag, vb->ptr, !range_request)) { if (head_or_get) { con->http_status = 304; return HANDLER_FINISHED; diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 619f4513..68d20435 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -2127,7 +2127,7 @@ webdav_if_match_or_unmodified_since (connection * const con, struct stat *st) if (NULL == st ? !buffer_is_equal_string(inm,CONST_STR_LEN("*")) || (errno != ENOENT && errno != ENOTDIR) - : etag_is_equal(etagb, inm->ptr, 0)) + : etag_is_equal(etagb, inm->ptr, 1)) return 412; /* Precondition Failed */ } diff --git a/tests/cachable.t b/tests/cachable.t index d0790e0e..35b9ea90 100755 --- a/tests/cachable.t +++ b/tests/cachable.t @@ -152,8 +152,7 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; ok($tf->handle_http($t) == 0, 'A quoted star is just a regular ETag'); -TODO: { - local $TODO = "weak etags not allowed yet"; +{ $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; ok($tf->handle_http($t) == 0, 'Client sent a list of ETags, the second matches'); -TODO: { - local $TODO = "weak etags not allowed yet"; +{ $t->{REQUEST} = ( <