]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added HttpRequest::expectingBody() method to indicate whether or
authorwessels <>
Tue, 22 Nov 2005 05:50:16 +0000 (05:50 +0000)
committerwessels <>
Tue, 22 Nov 2005 05:50:16 +0000 (05:50 +0000)
not we would usually expect an entity-body in the request.

This was added for ICAP integration.

src/HttpRequest.cc
src/HttpRequest.h

index 90696661d6e9e7c8313093000d46d9272d007e61..0f8ce5b8615531e781be5fa8d51708210bf88299 100644 (file)
@@ -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;
+}
index bf91269ce141cb17d5c4abbd83f532a1c8f7a613..0275fa4812e95ed489baa0c6a825d2b499c2128e 100644 (file)
@@ -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;