[Varnish] #1809: Allow a Content-Length: 0 header on a 204 response

Varnish varnish-bugs at varnish-cache.org
Fri Oct 23 12:36:34 CEST 2015


#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



More information about the varnish-bugs mailing list