From: Amos Jeffries Date: Fri, 10 Apr 2009 09:23:50 +0000 (+1200) Subject: HTTP 1.1: Forward OPTIONS requests properly X-Git-Tag: SQUID_3_0_STABLE14~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5738e4581163141a7013c5dc0aaa5951e87fe843;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 b926f3449f..c6175367de 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -96,7 +96,7 @@ public: int imslen; - int max_forwards; + int64_t max_forwards; /* these in_addr's could probably be sockaddr_in's */ diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 66168bab7f..f1f908ee46 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index f94e03ebeb..ce5e467c4a 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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(); diff --git a/src/http.cc b/src/http.cc index 28e63877eb..0e63d9ba4d 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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;