Search squid archive

Content-length 0 on GET [patch?]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

We recently upgraded to squid 3.2.5 and found we were unable to get to the site http://www.alevel-english.co.uk, after a little digging around it seems like the site doesn't like being sent a content length with a GET.

I realise that this is perfectly valid (although from my understanding optional), but I have the attached patch that stops squid from sending this header when it is doing a GET.

I'd love someone to give it a quick review and comment on what they think.

Thanks,
--
Michael Graham
diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc
index b008db9..d0df4da 100644
--- a/src/HttpMsg.cc
+++ b/src/HttpMsg.cc
@@ -308,14 +308,6 @@ HttpMsg::httpMsgParseError()
     return -1;
 }

-void
-HttpMsg::setContentLength(int64_t clen)
-{
-    header.delById(HDR_CONTENT_LENGTH); // if any
-    header.putInt64(HDR_CONTENT_LENGTH, clen);
-    content_length = clen;
-}
-
 bool
 HttpMsg::persistent() const
 {
diff --git a/src/HttpMsg.h b/src/HttpMsg.h
index 6020014..33d72ab 100644
--- a/src/HttpMsg.h
+++ b/src/HttpMsg.h
@@ -64,9 +64,6 @@ public:
     ///< produce a message copy, except for a few connection-specific settings
     virtual HttpMsg *clone() const = 0; ///< \todo rename: not a true copy?

-    /// [re]sets Content-Length header and cached value
-    void setContentLength(int64_t clen);
-
     /**
      * \retval true  the message sender asks to keep the connection open.
      * \retval false the message sender will close the connection.
diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc
index 8348f2e..a44be97 100644
--- a/src/HttpRequest.cc
+++ b/src/HttpRequest.cc
@@ -415,6 +415,16 @@ HttpRequest::hdrCacheInit()
     range = header.getRange();
 }

+void
+HttpRequest::setContentLength(int64_t clen)
+{
+    header.delById(HDR_CONTENT_LENGTH); // if any
+    if (method != METHOD_GET)
+        header.putInt64(HDR_CONTENT_LENGTH, clen);
+    content_length = clen;
+}
+
+
 /* request_flags */
 bool
 request_flags::resetTCP() const
diff --git a/src/HttpRequest.h b/src/HttpRequest.h
index 737a7bc..64d351a 100644
--- a/src/HttpRequest.h
+++ b/src/HttpRequest.h
@@ -212,6 +212,9 @@ public:

     int parseHeader(const char *parse_start, int len);

+    /// [re]sets Content-Length header and cached value
+    void setContentLength(int64_t clen);
+
     virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;

     bool bodyNibbled() const; // the request has a [partially] consumed body

[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux