------------------------------------------------------------ revno: 11847 revision-id: squid3@treenet.co.nz-20161217125941-aeubtf32hb2n5l3n parent: squid3@treenet.co.nz-20161217102402-vbe31by79bp7y71q fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4169 author: Garri Djavadyan committer: Amos Jeffries branch nick: 3.2 timestamp: Sun 2016-12-18 01:59:41 +1300 message: Bug 4169: HIT marked as MISS when If-None-Match does not match ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20161217125941-aeubtf32hb2n5l3n # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: 98e187ae91a0492d13bf2e02b022858d6a67b9ce # timestamp: 2016-12-17 13:00:06 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.2 # base_revision_id: squid3@treenet.co.nz-20161217102402-\ # vbe31by79bp7y71q # # Begin patch === modified file 'src/client_side.cc' --- src/client_side.cc 2015-08-28 13:26:26 +0000 +++ src/client_side.cc 2016-12-17 12:59:41 +0000 @@ -455,6 +455,7 @@ 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; === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2016-12-17 10:24:02 +0000 +++ src/client_side_reply.cc 2016-12-17 12:59:41 +0000 @@ -710,40 +710,27 @@ 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 @@ -1880,7 +1867,12 @@ 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(); === modified file 'src/enums.h' --- src/enums.h 2012-05-21 03:52:08 +0000 +++ src/enums.h 2016-12-17 12:59:41 +0000 @@ -45,6 +45,7 @@ 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, === modified file 'src/log/access_log.cc' --- src/log/access_log.cc 2015-05-01 07:24:56 +0000 +++ src/log/access_log.cc 2016-12-17 12:59:41 +0000 @@ -584,6 +584,9 @@ if (code == LOG_TCP_HIT) return 1; + if (code == LOG_TCP_INM_HIT) + return 1; + if (code == LOG_TCP_IMS_HIT) return 1;