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

index 3c0e3dbe8298aed9a8f805ff9b6097a3cec1fd7f..6a21bb4bfdf1793ac9b5e940c67f65e2c62d47e3 100644 (file)
@@ -2451,6 +2451,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;
 
index e5fe4106fd77464e5136c951c7b7e1393b4f4cbc..47787d0911f92c84bb58412e033793f0eead474a 100644 (file)
@@ -365,6 +365,7 @@ clientUpdateStatHistCounters(log_type logType, int svc_time)
         statHistCount(&statCounter.client_http.nh_svc_time, svc_time);
         break;
 
+    case LOG_TCP_INM_HIT:
     case LOG_TCP_IMS_HIT:
         statHistCount(&statCounter.client_http.nm_svc_time, svc_time);
         break;
index 9686a9b66c1a355d8ff32b67cec00f9d7de5287e..8b4774fea483516d19de579b27aac2c55907339e 100644 (file)
@@ -706,40 +706,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
@@ -1835,7 +1822,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, request_flags());
     e = http->storeEntry();
index f974ef863c6672f4815249b2828852fa912f858b..5dd2e5c626e8da2817ff11a3230636892a771944 100644 (file)
@@ -45,6 +45,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,