------------------------------------------------------------ revno: 14010 revision-id: squid3@treenet.co.nz-20160323153645-n1w12v5een1fh5y1 parent: squid3@treenet.co.nz-20160323144836-6dktdxx7ek6a6zm6 fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=2831 author: Dave Dykstra committer: Amos Jeffries branch nick: 3.5 timestamp: Thu 2016-03-24 04:36:45 +1300 message: Bug 2831: Cache-control: max-age not sent on TCP_IMS_HIT/304 ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160323153645-n1w12v5een1fh5y1 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 3743edda85322f5fe456bdd4c2df5e8b6fc5d73f # timestamp: 2016-03-23 15:50:56 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20160323144836-\ # 6dktdxx7ek6a6zm6 # # Begin patch === modified file 'src/HttpMsg.cc' --- src/HttpMsg.cc 2016-01-01 00:14:27 +0000 +++ src/HttpMsg.cc 2016-03-23 15:36:45 +0000 @@ -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 @@ 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; === modified file 'src/HttpMsg.h' --- src/HttpMsg.h 2016-01-01 00:14:27 +0000 +++ src/HttpMsg.h 2016-03-23 15:36:45 +0000 @@ -64,6 +64,9 @@ 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 === modified file 'src/HttpReply.cc' --- src/HttpReply.cc 2016-01-01 00:14:27 +0000 +++ src/HttpReply.cc 2016-03-23 15:36:45 +0000 @@ -150,7 +150,6 @@ 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 @@ if ((e = header.findEntry(ImsEntries[t]))) rv->header.addEntry(e->clone()); + rv->putCc(cache_control); + /* rv->body */ return rv; }