Commit 97d18936 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

We have to check the magic status before other length indications,

otherwise we cannot pass a 304 with a Content-Length.

(RFC2616 p33 4.4)

Fixes: #806


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5503 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 793fbe09
......@@ -186,23 +186,6 @@ RFC2616_Body(const struct sess *sp)
return (BS_NONE);
}
/* If the headers tells us what to do, obey. */
if (http_GetHdr(hp, H_Content_Length, &b)) {
sp->wrk->stats.fetch_length++;
return (BS_LENGTH);
}
if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
sp->wrk->stats.fetch_chunked++;
return (BS_CHUNKED);
}
if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
sp->wrk->stats.fetch_bad++;
return (BS_ERROR);
}
if (hp->status <= 199) {
/*
* 1xx responses never have a body.
......@@ -230,6 +213,21 @@ RFC2616_Body(const struct sess *sp)
return (BS_NONE);
}
if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
sp->wrk->stats.fetch_chunked++;
return (BS_CHUNKED);
}
if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
sp->wrk->stats.fetch_bad++;
return (BS_ERROR);
}
if (http_GetHdr(hp, H_Content_Length, &b)) {
sp->wrk->stats.fetch_length++;
return (BS_LENGTH);
}
if (http_HdrIs(hp, H_Connection, "keep-alive")) {
/*
* Keep alive with neither TE=Chunked or C-Len is impossible.
......
# $Id$
test "Content-Length in pass'ed 304 does not trigger body fetch"
server s1 {
rxreq
txresp -status 304 \
-nolen \
-hdr "Date: Mon, 25 Oct 2010 06:34:06 GMT" \
-hdr "Connection: close" \
-hdr "Content-Length: 100"
} -start
varnish v1 -vcl+backend {
sub vcl_recv { return(pass);}
sub vcl_deliver {
set resp.http.CL = resp.http.content-length;
unset resp.http.content-length;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 304
expect resp.http.cl == 100
} -run
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