]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From: Henrik Nordstrom <hno@hem.passagen.se>
authorwessels <>
Fri, 25 Jun 1999 04:53:43 +0000 (04:53 +0000)
committerwessels <>
Fri, 25 Jun 1999 04:53:43 +0000 (04:53 +0000)
What this patch does is to discard the pumpMethod() function, and
instead use the fact that the request has a request entity
(content-length present).

clientCheckContentLength() is extended accordingly to have rules for
methods with requires (PUT/POST) / should not (GET/HEAD) have a request
entity.

src/client_side.cc
src/forward.cc
src/http.cc

index dfc4dcc514900cd7855d9f4cab8969826d122260..397404c7446c00682e3654ca3d53f9aa4d1ce6ba 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.458 1999/06/24 20:20:01 wessels Exp $
+ * $Id: client_side.cc,v 1.459 1999/06/24 22:53:43 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -861,12 +861,21 @@ clientSetKeepaliveFlag(clientHttpRequest * http)
 static int
 clientCheckContentLength(request_t * r)
 {
-    /* We only require a content-length for "upload" methods */
-    if (!pumpMethod(r->method))
+    int has_cont_len = (httpHeaderGetInt(&r->header, HDR_CONTENT_LENGTH) >= 0);
+    switch (r->method) {
+    case METHOD_PUT:
+    case METHOD_POST:
+       /* PUT/POST requires a request entity */
+       return has_cont_len;
+    case METHOD_GET:
+    case METHOD_HEAD:
+       /* We do not want to see a request entity on GET/HEAD requests */
+       return !has_cont_len;
+    default:
+       /* For other types of requests we don't care */
        return 1;
-    if (httpHeaderGetInt(&r->header, HDR_CONTENT_LENGTH) < 0)
-       return 0;
-    return 1;
+    }
+    /* NOT REACHED */
 }
 
 static int
@@ -1905,7 +1914,7 @@ clientProcessRequest(clientHttpRequest * http)
        }
        /* yes, continue */
        http->log_type = LOG_TCP_MISS;
-    } else if (pumpMethod(r->method)) {
+    } else if (r->body) {
        http->log_type = LOG_TCP_MISS;
        /* XXX oof, POST can be cached! */
        pumpInit(fd, r, http->uri);
@@ -2259,6 +2268,7 @@ clientReadRequest(int fd, void *data)
     int k;
     request_t *request = NULL;
     int size;
+    int cont_len;
     method_t method;
     clientHttpRequest *http = NULL;
     clientHttpRequest **H = NULL;
@@ -2428,12 +2438,12 @@ clientReadRequest(int fd, void *data)
             */
            clientSetKeepaliveFlag(http);
            /*
-            * break here for NON-GET because most likely there is a
-            * reqeust body following and we don't want to parse it
-            * as though it was new request
+            * break here if the request has a content-length
+            * because there is a reqeust body following and we
+            * don't want to parse it as though it was new request.
             */
-           if (request->method != METHOD_GET) {
-               int cont_len = httpHeaderGetInt(&request->header, HDR_CONTENT_LENGTH);
+           cont_len = httpHeaderGetInt(&request->header, HDR_CONTENT_LENGTH);
+           if (cont_len >= 0) {
                int copy_len = XMIN(conn->in.offset, cont_len);
                if (copy_len > 0) {
                    assert(conn->in.offset >= copy_len);
index a459548c677624a61fee8f336f8286686eb845a5..eb69b9e4ca253b28e251714a80dac38d1a67145c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.62 1999/06/19 16:34:36 wessels Exp $
+ * $Id: forward.cc,v 1.63 1999/06/24 22:53:45 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -112,7 +112,7 @@ fwdCheckRetry(FwdState * fwdState)
        return 0;
     if (fwdState->flags.dont_retry)
        return 0;
-    if (pumpMethod(fwdState->request->method))
+    if (fwdState->request->body)
        if (0 == pumpRestart(fwdState->request))
            return 0;
     return 1;
@@ -361,7 +361,7 @@ fwdReforward(FwdState * fwdState)
     }
     if (fwdState->n_tries > 9)
        return 0;
-    if (pumpMethod(fwdState->request->method))
+    if (fwdState->request->body)
        if (0 == pumpRestart(fwdState->request))
            return 0;
     assert(fs);
index 605b75a132c5da86f5f9cef747afbcf4974b3b15..850629ee630b5de941a15bc9b7d9d851707c47d8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.349 1999/05/04 21:58:24 wessels Exp $
+ * $Id: http.cc,v 1.350 1999/06/24 22:53:46 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -800,7 +800,7 @@ httpSendRequest(HttpStateData * httpState)
 
     debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", httpState->fd, httpState);
 
-    if (pumpMethod(req->method))
+    if (req->body)
        sendHeaderDone = httpSendRequestEntry;
     else
        sendHeaderDone = httpSendComplete;