From: Amos Jeffries Date: Fri, 27 Aug 2010 16:45:08 +0000 (-0600) Subject: Author: Alex Rousskov X-Git-Tag: SQUID_3_1_8~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e27c02e091b20789db29232286818298c063a2c;p=thirdparty%2Fsquid.git Author: Alex Rousskov HTTP/1.1: respond to OPTIONS requests with a zero Max-Forwards value. 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 --- diff --git a/src/client_side.cc b/src/client_side.cc index 64caf9eaa1..315ac0f9b7 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2338,6 +2338,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 */ @@ -2450,8 +2451,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(node->data.getRaw()); assert (repContext); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 9569810c31..2a69bccf95 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1631,7 +1631,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) { diff --git a/src/client_side_request.cc b/src/client_side_request.cc index bff82991ee..aae5a4d78c 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -962,9 +962,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();