]> 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>
Sun, 20 Mar 2016 16:20:28 +0000 (05:20 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 20 Mar 2016 16:20:28 +0000 (05:20 +1300)
src/HttpMsg.cc
src/HttpMsg.h
src/HttpReply.cc

index fea8bb9ebd6815471fd1f192e96e85571b9347b0..5e42e4f09d29f1c5988e50f909ca9c89ec2600c6 100644 (file)
@@ -11,6 +11,7 @@
 #include "squid.h"
 #include "Debug.h"
 #include "http/one/Parser.h"
+#include "HttpHdrCc.h"
 #include "HttpHeaderTools.h"
 #include "HttpMsg.h"
 #include "MemBuf.h"
@@ -33,6 +34,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 f783886d04c250c638c89220fcd10f8ee9a3d104..0d16a5d681efc953a9b0c83495bcc8b895954ecc 100644 (file)
@@ -87,6 +87,9 @@ public:
 
     uint32_t sources; ///< The message sources
 
+    /// 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 eed1d1de798f693824d879f2eacf62d6e3fdb071..eb36a2929aecf38d79dc0b857a4cc71c5d1673b3 100644 (file)
@@ -146,7 +146,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(), Http::scNotModified, NULL);
@@ -156,6 +155,8 @@ HttpReply::make304() const
             rv->header.addEntry(e->clone());
     }
 
+    rv->putCc(cache_control);
+
     /* rv->body */
     return rv;
 }