From: Amos Jeffries Date: Wed, 24 Dec 2008 13:59:42 +0000 (+1300) Subject: Author: Alexander Lukyanov X-Git-Tag: SQUID_3_2_0_1~1284 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7dc5c30994f516b1db2ae7d784e8b4eca531b43e;p=thirdparty%2Fsquid.git Author: Alexander Lukyanov 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). --- diff --git a/src/http.cc b/src/http.cc index f07c03c8d9..83199ba03e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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);