Commit 271e1c52 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Ignore 0 Content-Lengths in 204 responses

Broken implementations do it contrary to what the RFC mandates.

Fixes #1826.
parent 7b2be3cf
......@@ -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
......
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
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