r5503 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
phk at varnish-cache.org
phk at varnish-cache.org
Thu Nov 4 11:13:33 CET 2010
Author: phk
Date: 2010-11-04 11:13:32 +0100 (Thu, 04 Nov 2010)
New Revision: 5503
Added:
trunk/varnish-cache/bin/varnishtest/tests/r00806.vtc
Modified:
trunk/varnish-cache/bin/varnishd/rfc2616.c
Log:
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
Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c 2010-11-04 10:11:18 UTC (rev 5502)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2010-11-04 10:13:32 UTC (rev 5503)
@@ -186,23 +186,6 @@
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 @@
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.
Added: trunk/varnish-cache/bin/varnishtest/tests/r00806.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00806.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00806.vtc 2010-11-04 10:13:32 UTC (rev 5503)
@@ -0,0 +1,30 @@
+# $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
+
+
More information about the varnish-commit
mailing list