From: Amos Jeffries Date: Wed, 8 Apr 2009 10:01:57 +0000 (+1200) Subject: HTTP 1.1: Forward OPTIONS requests properly X-Git-Tag: SQUID_3_2_0_1~1074 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc90edc39042bcb9d4f9ed2469fa49a5080779ac;p=thirdparty%2Fsquid.git HTTP 1.1: Forward OPTIONS requests properly 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. --- diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 9aa75ef3d2..d7981eefa3 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -122,7 +122,7 @@ public: int imslen; - int max_forwards; + int64_t max_forwards; IpAddress client_addr; diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 914df6851e..e61e14a2c4 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 39aec87431..cd51b70323 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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(); diff --git a/src/http.cc b/src/http.cc index e1bf41e365..6bff3c1c89 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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;