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

Special case beresp status 1xx, 204 and 304, they have no body.

(r5477 is a requirement for this fix)

Fixes: #803



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5478 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e708a88e
......@@ -476,13 +476,14 @@ FetchBody(struct sess *sp)
* Determine if we have a body or not
* XXX: Missing: RFC2616 sec. 4.4 in re 1xx, 204 & 304 responses
*/
cls = 0;
mklen = 0;
switch (sp->wrk->body_status) {
case BS_NONE:
cls = 0;
mklen = 0;
break;
case BS_ZERO:
cls = 0;
mklen = 1;
break;
case BS_LENGTH:
......@@ -499,12 +500,23 @@ FetchBody(struct sess *sp)
mklen = 1;
break;
case BS_ERROR:
VDI_CloseFd(sp);
return (__LINE__);
cls = 1;
mklen = 0;
break;
default:
cls = 0;
mklen = 0;
INCOMPL();
}
WSL(sp->wrk, SLT_Fetch_Body, sp->vbc->fd, "%u %u %u",
sp->wrk->body_status, cls, mklen);
if (sp->wrk->body_status == BS_ERROR) {
VDI_CloseFd(sp);
return (__LINE__);
}
if (cls == 0 && http_HdrIs(hp, H_Connection, "close"))
cls = 1;
......
......@@ -166,7 +166,6 @@ RFC2616_Ttl(const struct sess *sp)
/*--------------------------------------------------------------------
* Body existence and fetch method
* XXX: Missing: RFC2616 sec. 4.4 in re 1xx, 204 & 304 responses
*/
enum body_status
......@@ -181,6 +180,7 @@ RFC2616_Body(const struct sess *sp)
/*
* A HEAD request can never have a body in the reply,
* no matter what the headers might say.
* [RFC2516 4.3 p33]
*/
sp->wrk->stats.fetch_head++;
return (BS_NONE);
......@@ -203,6 +203,33 @@ RFC2616_Body(const struct sess *sp)
return (BS_ERROR);
}
if (hp->status <= 199) {
/*
* 1xx responses never have a body.
* [RFC2616 4.3 p33]
*/
sp->wrk->stats.fetch_1xx++;
return (BS_NONE);
}
if (hp->status == 204) {
/*
* 204 is "No Content", obviously don't expect a body.
* [RFC2616 10.2.5 p60]
*/
sp->wrk->stats.fetch_204++;
return (BS_NONE);
}
if (hp->status == 304) {
/*
* 304 is "Not Modified" it has no body.
* [RFC2616 10.3.5 p63]
*/
sp->wrk->stats.fetch_304++;
return (BS_NONE);
}
if (http_HdrIs(hp, H_Connection, "keep-alive")) {
/*
* Keep alive with neither TE=Chunked or C-Len is impossible.
......@@ -229,7 +256,7 @@ RFC2616_Body(const struct sess *sp)
}
/*
* XXX: Here it should depends on the status code
* Fall back to EOF transfer.
*/
sp->wrk->stats.fetch_eof++;
return (BS_EOF);
......
......@@ -56,14 +56,17 @@ VSC_F(backend_unused, uint64_t, 0, 'a', "Backend conn. unused")
VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry")
VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head")
VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length")
VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked")
VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length")
VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked")
VSC_F(fetch_eof, uint64_t, 1, 'a', "Fetch EOF")
VSC_F(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers")
VSC_F(fetch_close, uint64_t, 1, 'a', "Fetch wanted close")
VSC_F(fetch_oldhttp, uint64_t, 1, 'a', "Fetch pre HTTP/1.1 closed")
VSC_F(fetch_oldhttp, uint64_t, 1, 'a', "Fetch pre HTTP/1.1 closed")
VSC_F(fetch_zero, uint64_t, 1, 'a', "Fetch zero len")
VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed")
VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed")
VSC_F(fetch_1xx, uint64_t, 1, 'a', "Fetch no body (1xx)")
VSC_F(fetch_204, uint64_t, 1, 'a', "Fetch no body (204)")
VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)")
VSC_F(n_sess_mem, uint64_t, 0, 'i', "N struct sess_mem")
......
......@@ -79,6 +79,7 @@ SLTM(ObjHeader)
SLTM(LostHeader)
SLTM(TTL)
SLTM(Fetch_Body)
SLTM(VCL_acl)
SLTM(VCL_call)
SLTM(VCL_trace)
......
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