]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Compliance: respond to OPTIONS requests with a zero Max-Forwards value.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 24 Aug 2010 04:07:00 +0000 (22:07 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 24 Aug 2010 04:07:00 +0000 (22:07 -0600)
RFC 2616 section 9.2 says that a proxy MUST NOT forward requests with a
zero Max-Forwards value. RFC 2616 does not define any proper OPTIONS
responses, so we consider successful responses optional and reply with
501 Not Implemented.

No change in handling OPTIONS requests with positive Max-Forwards values.

While TRACE and OPTIONS are similar with regard to Max-Forwards, we
handle them in different places because OPTIONS responses do not need to
echo the request via Store.

Co-Advisor test case: test_case/rfc2616/maxForwardsZero-OPTIONS-absolute

src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc

index 96c6348ea7ab425a3a16fc3b65bce0e94aee9dd6..921ff931dae6755437254bbed3026bfb7e8300d4 100644 (file)
@@ -2394,6 +2394,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
     bool notedUseOfBuffer = false;
     bool tePresent = false;
     bool deChunked = false;
+    bool mustReplyToOptions = false;
     bool unsupportedTe = false;
 
     /* We have an initial client stream in place should it be needed */
@@ -2519,8 +2520,12 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
     } else
         conn->cleanDechunkingRequest();
 
+    if (method == METHOD_TRACE || method == METHOD_OPTIONS)
+        request->max_forwards = request->header.getInt64(HDR_MAX_FORWARDS);
+
+    mustReplyToOptions = (method == METHOD_OPTIONS) && (request->max_forwards == 0);
     unsupportedTe = tePresent && !deChunked;
-    if (!urlCheckRequest(request) || unsupportedTe) {
+    if (!urlCheckRequest(request) || mustReplyToOptions || unsupportedTe) {
         clientStreamNode *node = context->getClientReplyContext();
         clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
         assert (repContext);
index 339e3670c89a8c461124bec423bf3c519a15cbe3..5c79db6d425b2881dac0b2b50d28877d559bafed 100644 (file)
@@ -1633,7 +1633,7 @@ clientGetMoreData(clientStreamNode * aNode, ClientHttpRequest * http)
         return;
     }
 
-    /* TODO: handle OPTIONS request on max_forwards == 0 as well */
+    // OPTIONS with Max-Forwards:0 handled in clientProcessRequest()
 
     if (context->http->request->method == METHOD_TRACE) {
         if (context->http->request->max_forwards == 0) {
index 3fbe0fada2d559680bb89e33c442d3779cbcf1f8..51130e9da0ef4448936957b394a5c7abaaa18aea 100644 (file)
@@ -972,9 +972,6 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
     }
 
 #endif
-    if (request->method == METHOD_TRACE || request->method == METHOD_OPTIONS) {
-        request->max_forwards = req_hdr->getInt64(HDR_MAX_FORWARDS);
-    }
 
     request->flags.cachable = http->request->cacheable();