]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2831: Cache-control: max-age not sent on TCP_IMS_HIT/304
authorDave Dykstra <dwd@fnal.gov>
Wed, 23 Mar 2016 15:36:45 +0000 (04:36 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 23 Mar 2016 15:36:45 +0000 (04:36 +1300)
src/HttpMsg.cc
src/HttpMsg.h
src/HttpReply.cc

index d7dcacc52c9810dc27a6e93d2070255e08ec2ee0..885055c29ad4d515e325df3247831c0c29f91cc4 100644 (file)
@@ -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;
index 90f9c1daef5bc0f071fb009cde1942b018eb64c6..d7912caf4a98e2945b18ce251f578fbddc4bc494 100644 (file)
@@ -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
index b5f8a638bb694dad066d9d7ac1dc43ab46dfd1b9..f1d88d598c43d955f6171830b15ec63610aa9a08 100644 (file)
@@ -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;
 }