Hi, In the 304 case we were already skipping it for non-zero C-L. For 204 responses this was introduced as a side effect of 271e1c52.
Comments? OK?
From a764ff2612c18a5e8338c0db9827d1c7496c7b23 Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" <[email protected]> Date: Sun, 3 Jan 2016 19:10:29 +0000 Subject: [PATCH] Do not send a zero Content-Length for 204 and 304 In the 304 case we were already skipping it for non-zero C-L. For 204 responses this was introduced as a side effect of 271e1c52. --- bin/varnishd/cache/cache_req_fsm.c | 2 +- bin/varnishtest/tests/c00008.vtc | 19 +++++++++++++++++++ bin/varnishtest/tests/r01826.vtc | 10 ++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8279bdd..107ec45 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -73,7 +73,7 @@ cnt_vdp(struct req *req, struct busyobj *bo) else sendbody = 0; } else if (status < 200 || status == 204 || status == 304) { - req->resp_len = 0; + req->resp_len = -1; sendbody = 0; } else sendbody = 1; diff --git a/bin/varnishtest/tests/c00008.vtc b/bin/varnishtest/tests/c00008.vtc index 690b362..eb3c472 100644 --- a/bin/varnishtest/tests/c00008.vtc +++ b/bin/varnishtest/tests/c00008.vtc @@ -6,6 +6,10 @@ server s1 { txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr {ETag: "foo"} \ -body "11111\n" + rxreq + expect req.url == "/bar" + txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ + -hdr {ETag: "bar"} } -start varnish v1 -vcl+backend { } -start @@ -41,6 +45,21 @@ client c1 { expect resp.http.etag == {"foo"} expect resp.http.content-length == "<undef>" expect resp.bodylen == "<undef>" + + txreq -url "/bar" + rxresp + expect resp.status == 200 + expect resp.http.etag == {"bar"} + expect resp.http.content-length == "0" + expect resp.bodylen == 0 + + txreq -url "/bar" \ + -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" + rxresp -no_obj + expect resp.status == 304 + expect resp.http.etag == {"bar"} + expect resp.http.content-length == <undef> + expect resp.bodylen == <undef> } client c1 -run diff --git a/bin/varnishtest/tests/r01826.vtc b/bin/varnishtest/tests/r01826.vtc index 6a553d5..d830d7b 100644 --- a/bin/varnishtest/tests/r01826.vtc +++ b/bin/varnishtest/tests/r01826.vtc @@ -2,6 +2,11 @@ varnishtest "Check we ignore a zero C-L with a 204" server s1 { rxreq + txresp -status 204 -bodylen 5 + expect_close + + accept + rxreq txresp -status 204 } -start @@ -11,5 +16,10 @@ varnish v1 -vcl+backend { client c1 { txreq rxresp + expect resp.status == 503 + + txreq + rxresp expect resp.status == 204 + expect resp.http.content-length == <undef> } -run -- 2.6.4
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
