Search squid archive

Re: Content-length 0 on GET [patch?]

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

 



On 1/24/2013 7:48 PM, Amos Jeffries wrote:
Are you seeing Squid acting as a relay for the header?
or generating these headers itself on the upstream request?
  - please provide level 11,2 debug header trace for the client inbound
request and Squid outbound request messages to verify that.

It was doing both (our ICAP server adds the header too) but as you can see squid is doing it even when it doesn't receive the header:

----------
2013/01/25 13:02:29.721 kid1| client_side.cc(2298) parseHttpRequest: HTTP Client local=127.0.0.1:6045 remote=127.0.0.1:33733 FD 12 flags=1 2013/01/25 13:02:29.721 kid1| client_side.cc(2299) parseHttpRequest: HTTP Client REQUEST:
---------
GET http://www.alevel-english.co.uk/ HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: ASPSESSIONIDSADASRSR=CMCPPEKAEGPCNPGPEDAMLJNE; ASPSESSIONIDQCCATQSR=HIBLNKLAOPEBGFHMNDCIKEFD; ASPSESSIONIDSACBSRSQ=HOEJPOMABLMELLCOFOPHAHKO; JSESSIONID=D6044F4A7A5C9E9012EC8A26B7E1198F; ASPSESSIONIDQAADSRTQ=POLNLAEBBCIEFICNBLHFPB DJ; __utma=263889116.1108959357.1359039306.1359062156.1359118640.4; __utmb=263889116.3.10.1359118640; __utmc=263889116; __utmz=263889116.1359039306.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host: www.alevel-english.co.uk
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
Via: 1.1 pluto-icap (squid/3.2.5)
X-Forwarded-For: 192.168.68.51
Cache-Control: max-age=0
Connection: keep-alive
Transfer-Encoding: chunked


----------
2013/01/25 13:02:29.741 kid1| http.cc(2177) sendRequest: HTTP Server local=172.21.120.23:52941 remote=195.144.0.173:80 FD 15 flags=1 2013/01/25 13:02:29.741 kid1| http.cc(2178) sendRequest: HTTP Server REQUEST:
---------
GET / HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: ASPSESSIONIDSADASRSR=CMCPPEKAEGPCNPGPEDAMLJNE; ASPSESSIONIDQCCATQSR=HIBLNKLAOPEBGFHMNDCIKEFD; ASPSESSIONIDSACBSRSQ=HOEJPOMABLMELLCOFOPHAHKO; JSESSIONID=D6044F4A7A5C9E9012EC8A26B7E1198F; ASPSESSIONIDQAADSRTQ=POLNLAEBBCIEFICNBLHFPB DJ; __utma=263889116.1108959357.1359039306.1359062156.1359118640.4; __utmb=263889116.3.10.1359118640; __utmc=263889116; __utmz=263889116.1359039306.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host: www.alevel-english.co.uk
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
Content-Length: 0
Via: 1.1 pluto-icap (squid/3.2.5), 1.1 pluto-cache (squid/3.2.5)
X-Forwarded-For: 192.168.68.51, 127.0.0.1
Cache-Control: max-age=0
Connection: keep-alive

As for the code itself:

  * setting the content length is not a feature isolated to HTTP
requests. Replies also need to set it. The Squid code is just doing a
lot of abuse in the Reply code by not using the accessor properly.
  - Instead of moving it should be made a virtual method with a
speial-case version in HttpRequest.

I did think about doing that but then I noticed no one ever called the function unless they were doing a request so I just moved it. I've reinstated it now.

  - It should be using "clientIsContentLengthValid(request)" instead of
a test of the method.
   (yes, the test function itself needs cleaning up better as well,
there are other criteria beyond GET involved.)

Hmm. clientIsContentLengthValid() is a static inside client_side.cc so rather than patch HttpRequest and HttpMsg I've protected the call to setContentLength() from client_side.cc that was causing the issue.

The other option is to make clientIsContentLengthValid a member function of HttpRequest and fiddle the calls in client_side.cc from clientIsContentLengthValid(request) to request->isContentLengthValid(). If you prefer that way let me know and I'll send you that version.

Thanks,
--
Michael Graham
diff --git a/src/client_side.cc b/src/client_side.cc
index 839b0b8..f1548bb 100644
--- a/src/client_side.cc
+++ b/src/client_side.cc
@@ -3975,7 +3975,8 @@ ConnStateData::finishDechunkingRequest(bool withSuccess)
         if (withSuccess) {
             Must(myPipe->bodySizeKnown());
             ClientSocketContext::Pointer context = getCurrentContext();
-            if (context != NULL && context->http && context->http->request)
+            if (context != NULL && context->http && context->http->request &&
+                clientIsContentLengthValid(context->http->request))
                 context->http->request->setContentLength(myPipe->bodySize());
         }
     }

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

  Powered by Linux