Commit 10e6d90b authored by Federico G. Schwindt's avatar Federico G. Schwindt

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.
parent 9b0a053a
......@@ -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;
......
......@@ -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
......
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
......@@ -9,7 +14,12 @@ varnish v1 -vcl+backend {
} -start
client c1 {
txreq
rxresp
expect resp.status == 503
txreq
rxresp
expect resp.status == 204
expect resp.http.content-length == <undef>
} -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