From: Dave Dykstra Date: Wed, 23 Mar 2016 15:36:45 +0000 (+1300) Subject: Bug 2831: Cache-control: max-age not sent on TCP_IMS_HIT/304 X-Git-Tag: SQUID_3_5_16~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b8a9311217dc33df397a5f6b57f4fbfe85b39bb;p=thirdparty%2Fsquid.git Bug 2831: Cache-control: max-age not sent on TCP_IMS_HIT/304 --- diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index d7dcacc52c..885055c29a 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -10,6 +10,7 @@ #include "squid.h" #include "Debug.h" +#include "HttpHdrCc.h" #include "HttpHeaderTools.h" #include "HttpMsg.h" #include "MemBuf.h" @@ -27,6 +28,25 @@ HttpMsg::~HttpMsg() assert(!body_pipe); } +void +HttpMsg::putCc(const HttpHdrCc *otherCc) +{ + // get rid of the old CC, if any + if (cache_control) { + delete cache_control; + cache_control = nullptr; + if (!otherCc) + header.delById(HDR_CACHE_CONTROL); + // else it will be deleted inside putCc() below + } + + // add new CC, if any + if (otherCc) { + cache_control = new HttpHdrCc(*otherCc); + header.putCc(cache_control); + } +} + HttpMsgParseState &operator++ (HttpMsgParseState &aState) { int tmp = (int)aState; diff --git a/src/HttpMsg.h b/src/HttpMsg.h index 90f9c1daef..d7912caf4a 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -64,6 +64,9 @@ public: BodyPipe::Pointer body_pipe; // optional pipeline to receive message body + /// copies Cache-Control header to this message + void putCc(const HttpHdrCc *otherCc); + // returns true and sets hdr_sz on success // returns false and sets *error to zero when needs more data // returns false and sets *error to a positive Http::StatusCode on error diff --git a/src/HttpReply.cc b/src/HttpReply.cc index b5f8a638bb..f1d88d598c 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -150,7 +150,6 @@ HttpReply::make304() const rv->last_modified = last_modified; rv->expires = expires; rv->content_type = content_type; - /* rv->cache_control */ /* rv->content_range */ /* rv->keep_alive */ rv->sline.set(Http::ProtocolVersion(1,1), Http::scNotModified, NULL); @@ -159,6 +158,8 @@ HttpReply::make304() const if ((e = header.findEntry(ImsEntries[t]))) rv->header.addEntry(e->clone()); + rv->putCc(cache_control); + /* rv->body */ return rv; }