]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP 1.1: Forward OPTIONS requests properly
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 10 Apr 2009 09:23:50 +0000 (21:23 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 10 Apr 2009 09:23:50 +0000 (21:23 +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 b926f3449fd447cd9238ed419a571b4eea33ee1a..c6175367de118d728bfbab73bd4523e3174bec67 100644 (file)
@@ -96,7 +96,7 @@ public:
 
     int imslen;
 
-    int max_forwards;
+    int64_t max_forwards;
 
     /* these in_addr's could probably be sockaddr_in's */
 
index 66168bab7f419c714386e8e267fd936d6b7a7708..f1f908ee4606854e5e8558cdb90c8b48bb677d11 100644 (file)
@@ -1498,6 +1498,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 f94e03ebebf27c2cdf776c0514b63f1892fc0fc9..ce5e467c4a2682f5f2d65160840def6d3f27c85b 100644 (file)
@@ -745,8 +745,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 28e63877eb4e2da4dc0f9aeed654efa06a3ee78c..0e63d9ba4da6a7633bca8c7997e867e065fb7f91 100644 (file)
@@ -1584,11 +1584,12 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, St
         break;
 
     case HDR_MAX_FORWARDS:
-        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;