Commit 67445851 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix another cornercase that fell out as part of the pass->fetch rewrite:

If we pass a HEAD request, we should not rewrite it to GET and not expect
a body either.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1997 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent b29fc323
......@@ -463,6 +463,7 @@ void http_Setup(struct http *ht, void *space, unsigned len);
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(struct http *hp);
const char *http_GetReq(struct http *hp);
const char *http_GetProto(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
......
......@@ -263,7 +263,7 @@ Fetch(struct sess *sp)
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
int len, mklen;
int len, mklen, is_get;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
......@@ -272,6 +272,7 @@ Fetch(struct sess *sp)
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
is_get = !strcasecmp(http_GetReq(hp), "get");
sp->obj->xid = sp->xid;
......@@ -341,7 +342,9 @@ Fetch(struct sess *sp)
/* Determine if we have a body or not */
cls = 0;
mklen = 0;
if (http_GetHdr(hp, H_Content_Length, &b)) {
if (!is_get) {
/* nothing */
} else if (http_GetHdr(hp, H_Content_Length, &b)) {
cls = fetch_straight(sp, vc->fd, hp, b);
mklen = 1;
} else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
......
......@@ -388,6 +388,13 @@ http_GetProto(struct http *hp)
return (hp->hd[HTTP_HDR_PROTO].b);
}
const char *
http_GetReq(struct http *hp)
{
AN(hp->hd[HTTP_HDR_REQ].b);
return (hp->hd[HTTP_HDR_REQ].b);
}
/*--------------------------------------------------------------------
* Dissect the headers of the HTTP protocol message.
* Detect conditionals (headers which start with '^[Ii][Ff]-')
......@@ -802,7 +809,8 @@ http_FilterHeader(struct sess *sp, unsigned how)
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_copyreq(hp, sp->http, how == HTTPH_R_PIPE);
http_copyreq(hp, sp->http,
(how == HTTPH_R_PIPE) || (how == HTTPH_R_PASS));
http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment