From: wessels <> Date: Tue, 22 Nov 2005 05:50:16 +0000 (+0000) Subject: Added HttpRequest::expectingBody() method to indicate whether or X-Git-Tag: SQUID_3_0_PRE4~518 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ddea6437b4542376dca652aae7ce75520fb584a;p=thirdparty%2Fsquid.git Added HttpRequest::expectingBody() method to indicate whether or not we would usually expect an entity-body in the request. This was added for ICAP integration. --- diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 90696661d6..0f8ce5b861 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.53 2005/09/19 17:30:23 wessels Exp $ + * $Id: HttpRequest.cc,v 1.54 2005/11/21 22:50:16 wessels Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -206,6 +206,7 @@ bool HttpRequest::parseFirstLine(const char *start, const char *end) return true; } + HttpRequest * requestLink(HttpRequest * request) { @@ -374,3 +375,40 @@ void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const packableURI(full_uri), http_ver.major, http_ver.minor); } + +/* + * Indicate whether or not we would usually expect an entity-body + * along with this request + */ +bool +HttpRequest::expectingBody(method_t unused, ssize_t& theSize) const +{ + 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 + */ + + 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 (httpHeaderHasListMember(&header, HDR_TRANSFER_ENCODING, "chunked", ',')) + expectBody = true; + else if (content_length >= 0) + expectBody = true; + else + expectBody = false; + + if (expectBody) { + if (httpHeaderHasListMember(&header, HDR_TRANSFER_ENCODING, "chunked", ',')) + theSize = -1; + else if (content_length >= 0) + theSize = content_length; + else + theSize = -1; + } + + return expectBody; +} diff --git a/src/HttpRequest.h b/src/HttpRequest.h index bf91269ce1..0275fa4812 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.14 2005/09/15 20:19:41 wessels Exp $ + * $Id: HttpRequest.h,v 1.15 2005/11/21 22:50:16 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -97,6 +97,7 @@ public: public: bool parseFirstLine(const char *start, const char *end); int parseHeader(const char *parse_start); + virtual bool expectingBody(method_t unused, ssize_t&) const; private: const char *packableURI(bool full_uri) const;