From: Alex Rousskov Date: Tue, 24 Aug 2010 04:07:00 +0000 (-0600) Subject: Compliance: respond to OPTIONS requests with a zero Max-Forwards value. X-Git-Tag: take1~338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e18b8316f02564f2616e5509a64daf5590b0bb41;p=thirdparty%2Fsquid.git Compliance: 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 96c6348ea7..921ff931da 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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(node->data.getRaw()); assert (repContext); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 339e3670c8..5c79db6d42 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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) { diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 3fbe0fada2..51130e9da0 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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();