From: Amos Jeffries Date: Wed, 10 Mar 2010 12:50:39 +0000 (+1300) Subject: Bug 412: Send HTTP/1.1 to servers and peers X-Git-Tag: SQUID_3_2_0_1~372 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3872be7c733c3cfbdcc29f2a40d6479e11c51834;p=thirdparty%2Fsquid.git Bug 412: Send HTTP/1.1 to servers and peers Building on a lot of work by a very great many people over eight years. Thank you very, very much to everyone who made this possible. --- diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index 09324b1574..15466eb7ea 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -321,18 +321,13 @@ HttpMsg::setContentLength(int64_t clen) int httpMsgIsPersistent(HttpVersion const &http_ver, const HttpHeader * hdr) { -#if WHEN_SQUID_IS_HTTP1_1 - if ((http_ver.major >= 1) && (http_ver.minor >= 1)) { /* * for modern versions of HTTP: persistent unless there is * a "Connection: close" header. */ return !httpHeaderHasConnDir(hdr, "close"); - } else -#else - { -#endif + } else { /* * Persistent connections in Netscape 3.x are allegedly broken, * return false if it is a browser connection. If there is a @@ -340,17 +335,17 @@ httpMsgIsPersistent(HttpVersion const &http_ver, const HttpHeader * hdr) */ const char *agent = hdr->getStr(HDR_USER_AGENT); - if (agent && !hdr->has(HDR_VIA)) { - if (!strncasecmp(agent, "Mozilla/3.", 10)) - return 0; + if (agent && !hdr->has(HDR_VIA)) { + if (!strncasecmp(agent, "Mozilla/3.", 10)) + return 0; - if (!strncasecmp(agent, "Netscape/3.", 11)) - return 0; - } + if (!strncasecmp(agent, "Netscape/3.", 11)) + return 0; + } - /* for old versions of HTTP: persistent if has "keep-alive" */ - return httpHeaderHasConnDir(hdr, "keep-alive"); -} + /* for old versions of HTTP: persistent if has "keep-alive" */ + return httpHeaderHasConnDir(hdr, "keep-alive"); + } } void HttpMsg::packInto(Packer *p, bool full_uri) const diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 6f83a3387f..cc9a060494 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -327,8 +327,9 @@ HttpRequest::pack(Packer * p) { assert(p); /* pack request-line */ - packerPrintf(p, "%s " SQUIDSTRINGPH " HTTP/1.0\r\n", - RequestMethodStr(method), SQUIDSTRINGPRINT(urlpath)); + packerPrintf(p, "%s " SQUIDSTRINGPH " HTTP/%d.%d\r\n", + RequestMethodStr(method), SQUIDSTRINGPRINT(urlpath), + http_ver.major, http_ver.minor); /* headers */ header.packInto(p); /* trailer */ diff --git a/src/client_side.cc b/src/client_side.cc index f8785fcf8d..d866b59e55 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -716,8 +716,8 @@ clientSetKeepaliveFlag(ClientHttpRequest * http) debugs(33, 3, "clientSetKeepaliveFlag: method = " << RequestMethodStr(request->method)); + /* We are HTTP/1.0 facing clients still */ HttpVersion http_ver(1,0); - /* we are HTTP/1.0, no matter what the client requests... */ if (httpMsgIsPersistent(http_ver, req_hdr)) request->flags.proxy_keepalive = 1; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 980b66d062..e3056f20fe 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -367,8 +367,8 @@ clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * stre request->my_addr.SetPort(0); - /* RFC 2616 says 'upgrade' to our 1.0 regardless of what the client is */ - HttpVersion http_ver(1,0); + /* Our version is HTTP/1.1 */ + HttpVersion http_ver(1,1); request->http_ver = http_ver; http->request = HTTPMSGLOCK(request); diff --git a/src/http.cc b/src/http.cc index 503a164f9a..36c9f2c511 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1940,7 +1940,7 @@ HttpStateData::buildRequestPrefix(HttpRequest * aRequest, http_state_flags stateFlags) { const int offset = mb->size; - HttpVersion httpver(1,0); + HttpVersion httpver(1,1); mb->Printf("%s %s HTTP/%d.%d\r\n", RequestMethodStr(aRequest->method), aRequest->urlpath.size() ? aRequest->urlpath.termedBuf() : "/", @@ -2163,15 +2163,6 @@ HttpStateData::abortTransaction(const char *reason) deleteThis("HttpStateData::abortTransaction"); } -#if DEAD_CODE -void -httpBuildVersion(HttpVersion * version, unsigned int major, unsigned int minor) -{ - version->major = major; - version->minor = minor; -} -#endif - HttpRequest * HttpStateData::originalRequest() { diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 32df89cdc1..72115e92ad 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -1321,7 +1321,7 @@ netdbExchangeStart(void *data) HTTPMSGLOCK(ex->r); assert(NULL != ex->r); - ex->r->http_ver = HttpVersion(1,0); + ex->r->http_ver = HttpVersion(1,1); ex->connstate = STATE_HEADER; ex->e = storeCreateEntry(uri, uri, request_flags(), METHOD_GET); ex->buf_sz = NETDB_REQBUF_SZ; diff --git a/src/tunnel.cc b/src/tunnel.cc index 8d74df00b9..374ef29c75 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -710,7 +710,7 @@ tunnelProxyConnected(int fd, void *data) flags.proxying = tunnelState->request->flags.proxying; MemBuf mb; mb.init(); - mb.Printf("CONNECT %s HTTP/1.0\r\n", tunnelState->url); + mb.Printf("CONNECT %s HTTP/1.1\r\n", tunnelState->url); HttpStateData::httpBuildRequestHeader(tunnelState->request, tunnelState->request, NULL, /* StoreEntry */