]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4169: HIT marked as MISS when If-None-Match does not match v3.3
authorGarri Djavadyan <garryd@comnet.uz>
Sat, 17 Dec 2016 10:04:42 +0000 (23:04 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 17 Dec 2016 10:04:42 +0000 (23:04 +1300)
src/client_side.cc
src/client_side_reply.cc
src/enums.h
src/log/access_log.cc

index 0cb07ef3970ad65016b8e6b5889d1507c54f38b2..ee5b1a03a5e5ef30e1fa3ba4717cc63ac98ba347 100644 (file)
@@ -474,6 +474,7 @@ clientUpdateStatHistCounters(log_type logType, int svc_time)
         statCounter.client_http.nearHitSvcTime.count(svc_time);
         break;
 
+    case LOG_TCP_INM_HIT:
     case LOG_TCP_IMS_HIT:
         statCounter.client_http.nearMissSvcTime.count(svc_time);
         break;
index 3710b747b7f2b393b7b4e05cbe42ef96452733bc..47ed12671c43dfb44718b5e4d1e010ea8187242a 100644 (file)
@@ -752,40 +752,27 @@ clientReplyContext::processConditional(StoreIOBuffer &result)
         return true;
     }
 
-    bool matchedIfNoneMatch = false;
     if (r.header.has(HDR_IF_NONE_MATCH)) {
-        if (!e->hasIfNoneMatchEtag(r)) {
-            // RFC 2616: ignore IMS if If-None-Match did not match
-            r.flags.ims = 0;
-            r.ims = -1;
-            r.imslen = 0;
-            r.header.delById(HDR_IF_MODIFIED_SINCE);
-            http->logType = LOG_TCP_MISS;
-            sendMoreData(result);
-            return true;
-        }
+        // RFC 7232: If-None-Match recipient MUST ignore IMS
+        r.flags.ims = false;
+        r.ims = -1;
+        r.imslen = 0;
+        r.header.delById(HDR_IF_MODIFIED_SINCE);
 
-        if (!r.flags.ims) {
-            // RFC 2616: if If-None-Match matched and there is no IMS,
-            // reply with 304 Not Modified or 412 Precondition Failed
+        if (e->hasIfNoneMatchEtag(r)) {
             sendNotModifiedOrPreconditionFailedError();
             return true;
         }
 
-        // otherwise check IMS below to decide if we reply with 304 or 412
-        matchedIfNoneMatch = true;
+        // None-Match is true (no ETag matched); treat as an unconditional hit
+        return false;
     }
 
     if (r.flags.ims) {
         // handle If-Modified-Since requests from the client
         if (e->modifiedSince(&r)) {
-            http->logType = LOG_TCP_IMS_HIT;
-            sendMoreData(result);
-
-        } else if (matchedIfNoneMatch) {
-            // If-None-Match matched, reply with 304 Not Modified or
-            // 412 Precondition Failed
-            sendNotModifiedOrPreconditionFailedError();
+            // Modified-Since is true; treat as an unconditional hit
+            return false;
 
         } else {
             // otherwise reply with 304 Not Modified
@@ -1916,7 +1903,12 @@ clientReplyContext::sendNotModified()
     StoreEntry *e = http->storeEntry();
     const time_t timestamp = e->timestamp;
     HttpReply *const temprep = e->getReply()->make304();
-    http->logType = LOG_TCP_IMS_HIT;
+    // log as TCP_INM_HIT if code 304 generated for
+    // If-None-Match request
+    if (!http->request->flags.ims)
+        http->logType = LOG_TCP_INM_HIT;
+    else
+        http->logType = LOG_TCP_IMS_HIT;
     removeClientStoreReference(&sc, http);
     createStoreEntry(http->request->method, RequestFlags());
     e = http->storeEntry();
index 90ab3df1eca032f7fb50847b0010aedf18b19aec..f4cb77ce613ac5941fc4b6db880f3aa8ba649b50 100644 (file)
@@ -41,6 +41,7 @@ typedef enum {
     LOG_TCP_REFRESH_FAIL_ERR,   // refresh from origin failed, error forwarded
     LOG_TCP_REFRESH_MODIFIED,   // refresh from origin replaced existing entry
     LOG_TCP_CLIENT_REFRESH_MISS,
+    LOG_TCP_INM_HIT,
     LOG_TCP_IMS_HIT,
     LOG_TCP_SWAPFAIL_MISS,
     LOG_TCP_NEGATIVE_HIT,
index d49909cfe087bf318232615e381c7d98a1c699eb..4f0c72c7a09e0d6c56235e06374cd5d6afe72a2f 100644 (file)
@@ -584,6 +584,9 @@ logTypeIsATcpHit(log_type code)
     if (code == LOG_TCP_HIT)
         return 1;
 
+    if (code == LOG_TCP_INM_HIT)
+        return 1;
+
     if (code == LOG_TCP_IMS_HIT)
         return 1;