]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 412: Send HTTP/1.1 to servers and peers
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 14 Mar 2010 04:23:22 +0000 (17:23 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 14 Mar 2010 04:23:22 +0000 (17:23 +1300)
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.

src/HttpMsg.cc
src/HttpRequest.cc
src/client_side.cc
src/client_side_request.cc
src/http.cc
src/icmp/net_db.cc
src/tunnel.cc

index 7525b070aaf8d849dace94eaf0161033c4027b56..3043dbd9dea90d0aa1d69c04ddfd1f5ede1f2093 100644 (file)
@@ -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
index 994a3f5c97d3b3d72c7cb5c59c074d57d07a9004..7edac09cacc85505d09a66a0902e73b5bbc220be 100644 (file)
@@ -323,8 +323,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 */
index 1004a39d1605c353c498df951b294f211b5f75af..fcf16e86d94114fa716d1c54af0320f78555f97d 100644 (file)
@@ -706,8 +706,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;
index b977efe2abd594d2928b5cdc1b34c1d4878530a3..c00dfc834329ba2a344f4e3b582b97591222d73f 100644 (file)
@@ -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);
index 60b848c9d46d99d21851dc6dd8a25d2c9f06baf3..28fc1dafc659ec1a20aa9a4c30ebd5e5d80ae781 100644 (file)
@@ -1929,7 +1929,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() : "/",
@@ -2151,15 +2151,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()
 {
index 6227795ab8d72176ed3a84188989e38dd00f5734..38b1c238e7c483a9016f11af49826289cfc11142 100644 (file)
@@ -1320,7 +1320,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;
index a6bab679f4142e72a0c06261b8877dcd8a52c9f8..ba33df3c9535f576829855c6b43f1f39e6b00615 100644 (file)
@@ -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 */