diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 17aba0ec29..fe26ac4ae1 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -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 diff --git a/bin/varnishtest/tests/r01826.vtc b/bin/varnishtest/tests/r01826.vtc new file mode 100644 index 0000000000..eeb4503858 --- /dev/null +++ b/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