]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP 1.1: Forward OPTIONS requests properly
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 8 Apr 2009 10:01:57 +0000 (22:01 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 8 Apr 2009 10:01:57 +0000 (22:01 +1200)
Bump the max_forwards type to 64-bit to cope with wider range of values.

NP: still no internal handling of OPTIONS requests, but this will
    forward them according to RFC 2616 requirements.

src/HttpRequest.h
src/client_side_reply.cc
src/client_side_request.cc
src/http.cc

index 9aa75ef3d23c812c415c7dc5a3b629c52c428340..d7981eefa3a78c421dbdb0b3a0fea46b24ac45a5 100644 (file)
@@ -122,7 +122,7 @@ public:
 
     int imslen;
 
-    int max_forwards;
+    int64_t max_forwards;
 
     IpAddress client_addr;
 
index 914df6851ee690eaabaa7ab774a54f27dcce0a3f..e61e14a2c4cee968559b7ffac6bc39d364dad332 100644 (file)
@@ -1595,6 +1595,8 @@ clientGetMoreData(clientStreamNode * aNode, ClientHttpRequest * http)
         return;
     }
 
+    /* TODO: handle OPTIONS request on max_forwards == 0 as well */
+
     if (context->http->request->method == METHOD_TRACE) {
         if (context->http->request->max_forwards == 0) {
             context->traceReply(aNode);
index 39aec87431e6bcf1c308f21ab1779024d0c3b013..cd51b7032348c502f9d17a3d72f46c79723f65b6 100644 (file)
@@ -928,8 +928,8 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
     }
 
 #endif
-    if (request->method == METHOD_TRACE) {
-        request->max_forwards = req_hdr->getInt(HDR_MAX_FORWARDS);
+    if (request->method == METHOD_TRACE || request->method == METHOD_OPTIONS) {
+        request->max_forwards = req_hdr->getInt64(HDR_MAX_FORWARDS);
     }
 
     request->flags.cachable = http->request->cacheable();
index e1bf41e3650c6f73375c9fb68c39ec733f8d2d1e..6bff3c1c8932cebc652ee6c53a449df467a107b2 100644 (file)
@@ -1749,12 +1749,12 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, co
 
     case HDR_MAX_FORWARDS:
         /** \par Max-Forwards:
-         * pass only on TRACE requests */
-        if (orig_request->method == METHOD_TRACE) {
-            const int hops = e->getInt();
+         * pass only on TRACE or OPTIONS requests */
+        if (orig_request->method == METHOD_TRACE || orig_request->method == METHOD_OPTIONS) {
+            const int64_t hops = e->getInt64();
 
             if (hops > 0)
-                hdr_out->putInt(HDR_MAX_FORWARDS, hops - 1);
+                hdr_out->putInt64(HDR_MAX_FORWARDS, hops - 1);
         }
 
         break;