summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-05-05 23:02:24 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-05-06 01:13:58 -0400
commitb0ae5fcbcd3c1ca707fce941eb3266eb56aa57cb (patch)
treee9965a2343e71eee052fdb5f380c82047b4544ef
parent1a325a196cf2cb54fdb3874cd96f5d57043a86f8 (diff)
downloadlighttpd1.4-b0ae5fcbcd3c1ca707fce941eb3266eb56aa57cb.tar.gz
lighttpd1.4-b0ae5fcbcd3c1ca707fce941eb3266eb56aa57cb.zip
[core] support weak etags with If-None-Match
support weak etags with If-None-Match (but require strong etags for Range requests)
-rw-r--r--src/http-header-glue.c10
-rw-r--r--src/mod_webdav.c2
-rwxr-xr-xtests/cachable.t6
3 files changed, 9 insertions, 9 deletions
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} = ( <<EOF
GET / HTTP/1.0
If-None-Match: W/$etag
@@ -188,8 +187,7 @@ EOF
$t->{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} = ( <<EOF
GET / HTTP/1.0
If-None-Match: "12345", W/$etag