From: Garri Djavadyan Date: Sat, 17 Dec 2016 08:34:47 +0000 (+1300) Subject: Bug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20d036c097b79f9458f7c7fa5544870b355ca381;p=thirdparty%2Fsquid.git Bug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure --- diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 8ea4f2d041..3710b747b7 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -563,6 +563,7 @@ clientReplyContext::cacheHit(StoreIOBuffer result) ) { http->logType = LOG_TCP_NEGATIVE_HIT; sendMoreData(result); + return; } else if (!http->flags.internal && refreshCheckHTTP(e, r)) { debugs(88, 5, "clientCacheHit: in refreshCheck() block"); /* @@ -609,25 +610,29 @@ clientReplyContext::cacheHit(StoreIOBuffer result) http->logType = LOG_TCP_MISS; processMiss(); } - } else if (r->conditional()) - processConditional(result); - else { - /* - * plain ol' cache hit - */ + return; + } else if (r->conditional()) { + debugs(88, 5, "conditional HIT"); + if (processConditional(result)) + return; + } + + /* + * plain ol' cache hit + */ + debugs(88, 5, "plain old HIT"); #if USE_DELAY_POOLS - if (e->store_status != STORE_OK) - http->logType = LOG_TCP_MISS; - else + if (e->store_status != STORE_OK) + http->logType = LOG_TCP_MISS; + else #endif - if (e->mem_status == IN_MEMORY) - http->logType = LOG_TCP_MEM_HIT; - else if (Config.onoff.offline) - http->logType = LOG_TCP_OFFLINE_HIT; + if (e->mem_status == IN_MEMORY) + http->logType = LOG_TCP_MEM_HIT; + else if (Config.onoff.offline) + http->logType = LOG_TCP_OFFLINE_HIT; - sendMoreData(result); - } + sendMoreData(result); } /** @@ -726,7 +731,7 @@ clientReplyContext::processOnlyIfCachedMiss() } /// process conditional request from client -void +bool clientReplyContext::processConditional(StoreIOBuffer &result) { StoreEntry *const e = http->storeEntry(); @@ -736,7 +741,7 @@ clientReplyContext::processConditional(StoreIOBuffer &result) e->getReply()->sline.status << " != 200"); http->logType = LOG_TCP_MISS; processMiss(); - return; + return true; } HttpRequest &r = *http->request; @@ -744,7 +749,7 @@ clientReplyContext::processConditional(StoreIOBuffer &result) if (r.header.has(HDR_IF_MATCH) && !e->hasIfMatchEtag(r)) { // RFC 2616: reply with 412 Precondition Failed if If-Match did not match sendPreconditionFailedError(); - return; + return true; } bool matchedIfNoneMatch = false; @@ -757,14 +762,14 @@ clientReplyContext::processConditional(StoreIOBuffer &result) r.header.delById(HDR_IF_MODIFIED_SINCE); http->logType = LOG_TCP_MISS; sendMoreData(result); - return; + return true; } 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 sendNotModifiedOrPreconditionFailedError(); - return; + return true; } // otherwise check IMS below to decide if we reply with 304 or 412 @@ -776,19 +781,20 @@ clientReplyContext::processConditional(StoreIOBuffer &result) if (e->modifiedSince(&r)) { http->logType = LOG_TCP_IMS_HIT; sendMoreData(result); - return; - } - if (matchedIfNoneMatch) { + } else if (matchedIfNoneMatch) { // If-None-Match matched, reply with 304 Not Modified or // 412 Precondition Failed sendNotModifiedOrPreconditionFailedError(); - return; - } - // otherwise reply with 304 Not Modified - sendNotModified(); + } else { + // otherwise reply with 304 Not Modified + sendNotModified(); + } + return true; } + + return false; } void diff --git a/src/client_side_reply.h b/src/client_side_reply.h index dd8d330d73..a3d44f457a 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -137,7 +137,7 @@ private: bool alwaysAllowResponse(http_status sline) const; int checkTransferDone(); void processOnlyIfCachedMiss(); - void processConditional(StoreIOBuffer &result); + bool processConditional(StoreIOBuffer &result); void cacheHit(StoreIOBuffer result); void handleIMSReply(StoreIOBuffer result); void sendMoreData(StoreIOBuffer result);