[4.1] 59dfdbd Do not send a zero Content-Length for 204 and 304
Lasse Karstensen
lkarsten at varnish-software.com
Thu Jan 14 15:15:12 CET 2016
commit 59dfdbd740c38a3a7316dd7af24490c872bd95bc
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sun Jan 3 19:10:29 2016 +0000
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.
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index a539817..7627726 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
More information about the varnish-commit
mailing list