Skip to content

Commit

Permalink
Ignore 0 Content-Lengths in 204 responses
Browse files Browse the repository at this point in the history
Broken implementations do it contrary to what the RFC mandates.

Fixes #1826.
  • Loading branch information
fgsch committed Dec 4, 2015
1 parent 7b2be3c commit 271e1c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/varnishd/cache/cache_fetch.c
Expand Up @@ -345,7 +345,8 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
* [RFC7230 3.3.1 p29 and 3.3.2 p31]
*/
wrk->stats->fetch_204++;
if (http_GetHdr(bo->beresp, H_Content_Length, NULL) ||
if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) &&
bo->htc->content_length != 0) ||
http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL))
bo->htc->body_status = BS_ERROR;
else
Expand Down
15 changes: 15 additions & 0 deletions bin/varnishtest/tests/r01826.vtc
@@ -0,0 +1,15 @@
varnishtest "Check we ignore a zero C-L with a 204"

server s1 {
rxreq
txresp -status 204 -nolen -hdr "Content-Length: 0"
} -start

varnish v1 -vcl+backend {
} -start

client c1 {
txreq
rxresp
expect resp.status == 204
} -run

0 comments on commit 271e1c5

Please sign in to comment.