]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alexander Lukyanov <lav@yar.ru>
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 24 Dec 2008 13:59:42 +0000 (02:59 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 24 Dec 2008 13:59:42 +0000 (02:59 +1300)
Bug 2330: allow keep-alive+chunked; don't add max-age for no-cache

Attached patch enables keep-alive for chunked transfer-encoding, as such
encoding allows to determine reply body end.

Also the patch disables adding of max-age to requests with no-cache flag. It
saves a few bytes and also makes less difference between the incoming and
outgoing requests. Max-age is obviously not useful for no-cache requests.

NP: amended after bug discussion to also skip adding of no-cache on
    internal calculation from local state which may not be correct
    down the line in other caches. (nocache includes local config settings).

src/http.cc

index f07c03c8d933ac88694df81484f97b228af02d6f..83199ba03e9998f1fae6d670d36e1ffcba38f593 100644 (file)
@@ -633,7 +633,8 @@ HttpStateData::keepaliveAccounting(HttpReply *reply)
         if (_peer)
             _peer->stats.n_keepalives_recv++;
 
-        if (Config.onoff.detect_broken_server_pconns && reply->bodySize(request->method) == -1) {
+       if (Config.onoff.detect_broken_server_pconns
+       && reply->bodySize(request->method) == -1 && !flags.chunked) {
             debugs(11, 1, "keepaliveAccounting: Impossible keep-alive header from '" << entry->url() << "'" );
             // debugs(11, 2, "GOT HTTP REPLY HDR:\n---------\n" << readBuf->content() << "\n----------" );
             flags.keepalive_broken = 1;
@@ -1604,7 +1605,14 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         if (!cc)
             cc = httpHdrCcCreate();
 
-        if (!EBIT_TEST(cc->mask, CC_MAX_AGE)) {
+#if 0 /* see bug 2330 */
+        /* Set no-cache if determined needed but not found */
+        if (orig_request->flags.nocache)
+            EBIT_SET(cc->mask, CC_NO_CACHE);
+#endif
+
+       /* Add max-age only without no-cache */
+       if (!EBIT_TEST(cc->mask, CC_MAX_AGE) && !EBIT_TEST(cc->mask, CC_NO_CACHE)) {
             const char *url =
                 entry ? entry->url() : urlCanonical(orig_request);
             httpHdrCcSetMaxAge(cc, getMaxAge(url));
@@ -1613,10 +1621,6 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                 assert(strstr(url, request->urlpath.buf()));
         }
 
-        /* Set no-cache if determined needed but not found */
-        if (orig_request->flags.nocache && !hdr_in->has(HDR_PRAGMA))
-            EBIT_SET(cc->mask, CC_NO_CACHE);
-
         /* Enforce sibling relations */
         if (flags.only_if_cached)
             EBIT_SET(cc->mask, CC_ONLY_IF_CACHED);