From: wessels <> Date: Fri, 25 Jun 1999 04:53:43 +0000 (+0000) Subject: From: Henrik Nordstrom X-Git-Tag: SQUID_3_0_PRE1~2138 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffc128c494b887985e4ae48f0c5e8cf06d063ce6;p=thirdparty%2Fsquid.git From: Henrik Nordstrom 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. --- diff --git a/src/client_side.cc b/src/client_side.cc index dfc4dcc514..397404c744 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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); diff --git a/src/forward.cc b/src/forward.cc index a459548c67..eb69b9e4ca 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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); diff --git a/src/http.cc b/src/http.cc index 605b75a132..850629ee63 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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;