/*
- * $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
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
}
/* 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);
int k;
request_t *request = NULL;
int size;
+ int cont_len;
method_t method;
clientHttpRequest *http = NULL;
clientHttpRequest **H = NULL;
*/
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);
/*
- * $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
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;
}
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);
/*
- * $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
debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", httpState->fd, httpState);
- if (pumpMethod(req->method))
+ if (req->body)
sendHeaderDone = httpSendRequestEntry;
else
sendHeaderDone = httpSendComplete;