]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP/1.1 compliance: Stop using Proxy-Connection header
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Aug 2010 07:53:08 +0000 (01:53 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Aug 2010 07:53:08 +0000 (01:53 -0600)
The Proxy-Connection header is not part of any HTTP standard. It was added
by Netscape to differentiate persistent connections to intermediary proxies
but that duty has been formally superceded by the Connection: header.

This compliance update makes Squid stop sending Proxy-Connection on outbound
requests. Starts consistently using Connection: header instead.

The Proxy-Connection header is also ignored on HTTP-strict builds.
For compatibility we must do a small violation and drop it as a hop-by-hop
header despite strct-mode technically being required to pass it through.

For origin server connections the non-strict builds will retain the
status-quo: interpret it, but treat it as an HTTP/0.9 thing to be
upgraded to HTTP/1.1 Connection:.

squidclient is also fixed not to send it.

src/HttpHeaderTools.cc
src/cf.data.pre
src/client_side_reply.cc
src/http.cc
tools/squidclient.cc

index c4b995b34989a8ab0694916fee46735295842107..ae7e9120eb5c08b6471f4338fc1534cb35ec6cbf 100644 (file)
@@ -145,19 +145,19 @@ int
 httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive)
 {
     String list;
-    http_hdr_type ht;
     int res;
     /* what type of header do we have? */
 
+#if USE_HTTP_VIOLATIONS
     if (hdr->has(HDR_PROXY_CONNECTION))
-        ht = HDR_PROXY_CONNECTION;
-    else if (hdr->has(HDR_CONNECTION))
-        ht = HDR_CONNECTION;
+        list = hdr->getList(HDR_PROXY_CONNECTION);
+    else
+#endif
+    if (hdr->has(HDR_CONNECTION))
+        list = hdr->getList(HDR_CONNECTION);
     else
         return 0;
 
-    list = hdr->getList(ht);
-
     res = strListIsMember(&list, directive, ',');
 
     list.clean();
index e1c6c430eae449e43b56ca5f4471d7ca6478ddbb..6d213ea6d3ff095e619652dae1e4305eee2b1f0f 100644 (file)
@@ -4042,7 +4042,6 @@ DOC_START
                request_header_access Retry-After allow all
                request_header_access Title allow all
                request_header_access Connection allow all
-               request_header_access Proxy-Connection allow all
                request_header_access All deny all
 
        although many of those are HTTP reply headers, and so should be
@@ -4118,7 +4117,6 @@ DOC_START
                reply_header_access Retry-After allow all
                reply_header_access Title allow all
                reply_header_access Connection allow all
-               reply_header_access Proxy-Connection allow all
                reply_header_access All deny all
 
        although the HTTP request headers won't be usefully controlled
index a32d7e40a235e3ef0f8a63be6798e15065d05c90..4932e339e1c89054b1403745803410b3b43d01d7 100644 (file)
@@ -1402,9 +1402,8 @@ clientReplyContext::buildReplyHeader()
         hdr->delById(HDR_VIA);
         hdr->putStr(HDR_VIA, strVia.termedBuf());
     }
-    /* Signal keep-alive if needed */
-    hdr->putStr( (http->flags.accel || http->flags.intercepted)? HDR_CONNECTION : HDR_PROXY_CONNECTION,
-                 request->flags.proxy_keepalive ? "keep-alive" : "close");
+    /* Signal keep-alive or close explicitly */
+    hdr->putStr(HDR_CONNECTION, request->flags.proxy_keepalive ? "keep-alive" : "close");
 
 #if ADD_X_REQUEST_URI
     /*
index 6e922bb54447ad863dac1d4c4d1725be2e2f3bc1..4a712aeddb78d5b4a6a792f9c052d9ff349017ca 100644 (file)
@@ -1732,11 +1732,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
 
     /* maybe append Connection: keep-alive */
     if (flags.keepalive) {
-        if (flags.proxying) {
-            hdr_out->putStr(HDR_PROXY_CONNECTION, "keep-alive");
-        } else {
-            hdr_out->putStr(HDR_CONNECTION, "keep-alive");
-        }
+        hdr_out->putStr(HDR_CONNECTION, "keep-alive");
     }
 
     /* append Front-End-Https */
@@ -1881,12 +1877,13 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, co
 
         break;
 
-    case HDR_PROXY_CONNECTION:
+    case HDR_PROXY_CONNECTION: // SHOULD ignore. But doing so breaks things.
+        break;
 
     case HDR_X_FORWARDED_FOR:
 
     case HDR_CACHE_CONTROL:
-        /** \par Proxy-Connaction:, X-Forwarded-For:, Cache-Control:
+        /** \par X-Forwarded-For:, Cache-Control:
          * handled specially by Squid, so leave off for now.
          * append these after the loop if needed */
         break;
index 581f382c788eff78e9ff826bf5e39fa46188801a..769a794570bcc37d31088d926113b11539d4bb70 100644 (file)
@@ -427,17 +427,11 @@ main(int argc, char *argv[])
             strcat(msg, buf);
         }
 
-        /* HTTP/1.0 may need keep-alive */
-        if (strcmp(version, "1.0") == 0) {
-            if (keep_alive) {
-                if (strchr(url, ':')) {
-                    snprintf(buf, BUFSIZ, "Proxy-Connection: keep-alive\r\n");
-                    strcat(msg, buf);
-                } else
-                    strcat(msg, "Connection: keep-alive\r\n");
-            }
-        }
-        /* HTTP/1.1 may need close */
+        /* HTTP/1.0 may need keep-alive explicitly */
+        if (strcmp(version, "1.0") == 0 && keep_alive)
+            strcat(msg, "Connection: keep-alive\r\n");
+
+        /* HTTP/1.1 may need close explicitly */
         if (!keep_alive)
             strcat(msg, "Connection: close\r\n");