Mailing List Archive

#1809: Allow a Content-Length: 0 header on a 204 response
#1809: Allow a Content-Length: 0 header on a 204 response
--------------------------------+--------------------
Reporter: widodh | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: trunk | Severity: normal
Keywords: 204,content-length |
--------------------------------+--------------------
Currently Varnish 4 errors out when a 204 response is given by a backend
and a Content-Length header is present:

In cache_fetch.c:

{{{#!c
} else if (http_IsStatus(bo->beresp, 204)) {
/*
* 204 is "No Content", obviously don't expect a body.
* [RFC2616 10.2.5 p60]
*/
wrk->stats->fetch_204++;
if (http_GetHdr(bo->beresp, H_Content_Length, NULL) ||
http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL))
bo->htc->body_status = BS_ERROR;
else
bo->htc->body_status = BS_NONE;

}}}

If a Content-Length header is present it errors out. Looking at RFC 2616
10.2.5 it says:

"The 204 response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields"

However, it doesn't say that Content-Length is not an allowed header here.
Content-Length with a value of 0 is a valid case which should be allowed.

I think we should allow a Content-Length header if the value is 0.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1809>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1809: Allow a Content-Length: 0 header on a 204 response [ In reply to ]
#1809: Allow a Content-Length: 0 header on a 204 response
--------------------------------+--------------------
Reporter: widodh | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version: trunk
Severity: normal | Resolution:
Keywords: 204,content-length |
--------------------------------+--------------------

Comment (by widodh):

A direct link to the RFC: https://www.ietf.org/rfc/rfc2616.txt

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1809#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1809: Allow a Content-Length: 0 header on a 204 response [ In reply to ]
#1809: Allow a Content-Length: 0 header on a 204 response
--------------------------------+--------------------
Reporter: widodh | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version: trunk
Severity: normal | Resolution:
Keywords: 204,content-length |
--------------------------------+--------------------

Comment (by widodh):

I've looked at this with a colleague and he pointed me at RFC7230:
https://tools.ietf.org/html/rfc7230#section-3.3.2

{{{
A server MUST NOT send a Content-Length header field in any response with
a status code of 1xx (Informational) or 204 (No Content).
}}}

That clarifies it. Varnish is keeping to the standard, BUT, the comment in
the code should be updated that it points to RFC7230 and not to RFC2616.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1809#comment:2>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1809: Allow a Content-Length: 0 header on a 204 response [ In reply to ]
#1809: Allow a Content-Length: 0 header on a 204 response
-----------------------------+---------------------------------------------
Reporter: widodh | Owner: Federico G. Schwindt <fgsch@…>
Type: defect | Status: closed
Priority: normal | Milestone:
Component: build | Version: trunk
Severity: normal | Resolution: fixed
Keywords: 204,content- |
length |
-----------------------------+---------------------------------------------
Changes (by Federico G. Schwindt <fgsch@…>):

* status: new => closed
* owner: => Federico G. Schwindt <fgsch@…>
* resolution: => fixed


Comment:

In [54471f2a86ae7234a31c97c0adb5e70a1b28ee38]:
{{{
#!CommitTicketReference repository=""
revision="54471f2a86ae7234a31c97c0adb5e70a1b28ee38"
Update RFC reference

Fixes #1809.
}}}

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1809#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1809: Allow a Content-Length: 0 header on a 204 response [ In reply to ]
#1809: Allow a Content-Length: 0 header on a 204 response
-----------------------------+---------------------------------------------
Reporter: widodh | Owner: Federico G. Schwindt <fgsch@…>
Type: defect | Status: closed
Priority: normal | Milestone:
Component: build | Version: trunk
Severity: normal | Resolution: fixed
Keywords: 204,content- |
length |
-----------------------------+---------------------------------------------

Comment (by Lasse Karstensen <lkarsten@…>):

In [a75a278e7ebedac0e34232e216f945881bd1d523]:
{{{
#!CommitTicketReference repository=""
revision="a75a278e7ebedac0e34232e216f945881bd1d523"
Update RFC reference

Fixes #1809.
}}}

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1809#comment:4>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs