From: Amos Jeffries Date: Tue, 1 Feb 2011 01:50:29 +0000 (-0700) Subject: Author: Henrik Nordstrom X-Git-Tag: SQUID_3_1_11~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dcab323871f931ddc1307166d313c33e5715c98;p=thirdparty%2Fsquid.git Author: Henrik Nordstrom Simplify request parsing to not check request method when determining entities Requests containing a request-entity or not is signalled entirely by Content-Length/Transfer-Encoding regardless of method. Also drops the requirement that PUT/POST requests must have a request-entity. The RFC do not explicitly state this requirement even if the wording for those methods do assume there is a enclosed request-entity. The administrative "request_entities" config flag is kept for security reasons, even if not really RFC compliant. (RFC meaning of request-entity in GET/HEAD is just undefined or "ignored", not forbidden) --- diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index d21ae3fed5..5ed2976c6f 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -480,7 +480,7 @@ void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const } /* - * Indicate whether or not we would usually expect an entity-body + * Indicate whether or not we would expect an entity-body * along with this request */ bool @@ -489,28 +489,18 @@ HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t& theSize) co bool expectBody = false; /* - * GET and HEAD don't usually have bodies, but we should be prepared - * to accept one if the request_entities directive is set + * Note: Checks for message validity is in clientIsContentLengthValid(). + * this just checks if a entity-body is expected based on HTTP message syntax */ - - if (method == METHOD_GET || method == METHOD_HEAD) - expectBody = Config.onoff.request_entities ? true : false; - else if (method == METHOD_PUT || method == METHOD_POST) - expectBody = true; - else if (header.chunked()) + if (header.chunked()) { expectBody = true; - else if (content_length >= 0) + theSize = -1; + } else if (content_length >= 0) { expectBody = true; - else + theSize = content_length; + } else { expectBody = false; - - if (expectBody) { - if (header.chunked()) - theSize = -1; - else if (content_length >= 0) - theSize = content_length; - else - theSize = -1; + // theSize undefined } return expectBody; diff --git a/src/client_side.cc b/src/client_side.cc index a086faf3dc..49e4a36899 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -714,12 +714,6 @@ clientIsContentLengthValid(HttpRequest * r) { switch (r->method.id()) { - case METHOD_PUT: - - case METHOD_POST: - /* PUT/POST requires a request entity */ - return (r->content_length >= 0); - case METHOD_GET: case METHOD_HEAD: