[Varnish] #400: HTTP/1.0 404 Not Found + no Content-Length => no content

Varnish varnish-bugs at projects.linpro.no
Tue Dec 2 13:11:34 CET 2008


#400: HTTP/1.0 404 Not Found + no Content-Length => no content
----------------------+-----------------------------------------------------
 Reporter:  jfbubus   |       Owner:  phk  
     Type:  defect    |      Status:  new  
 Priority:  normal    |   Milestone:       
Component:  varnishd  |     Version:  trunk
 Severity:  normal    |    Keywords:       
----------------------+-----------------------------------------------------
 Setup : varnish 2.0.2 + apache + PHP

 The application returns a custom PHP error page with a status line of :
 {{{
 HTTP/1.0 404 Not Found
 }}}
 The HTTP response do not have a Content-Length header (more details
 below).

 When accessing a 404 page, clients get no content. Any other page works.

 Other combinations work :
  * Direct access to the backend : OK
  * HTTP/1.1 200 w/o Content-Length : OK
  * HTTP/1.0 200 w/o Content-Length : OK
  * HTTP/1.1 404 w/o Content-Length : OK
  * HTTP/1.0 404 w/ Content-Length : OK

 The recommended/documented way of generating a 404 error in PHP forces a
 HTTP/1.0 response : http://www.php.net/manual/en/function.header.php. (You
 should not have to force the HTTP version, but that's how PHP works/is
 documented)

 Varnish config :
 {{{
 varnishd -a :80 -s malloc,1G -P /var/run/varnishd.pid -b localhost:81 -n
 /var/run/varnish/
 }}}
 The default VCL is used

 Test code :
 {{{
 <?php
 header("HTTP/1.0 404 Not Found");
 echo str_repeat("Works! ", 10000);
 ?>
 }}}

 Access through varnish :
 {{{
 curl -v http://localhost/test.php
 * About to connect() to localhost port 80
 *   Trying 127.0.0.1... connected
 * Connected to localhost (127.0.0.1) port 80
 > GET /test.php HTTP/1.1
 > User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
 > Host: localhost
 > Accept: */*
 >
 < HTTP/1.0 404 Not Found
 < Server: Apache
 < Cache-Control: max-age=0
 < Expires: Tue, 02 Dec 2008 11:51:02 GMT
 < Content-Type: text/html
 < Date: Tue, 02 Dec 2008 11:51:02 GMT
 < X-Varnish: 2027003591
 < Age: 0
 < Via: 1.1 varnish
 * HTTP/1.0 connection set to keep alive!
 < Connection: keep-alive
 * Connection #0 to host localhost left intact
 * Closing connection #0
 }}}

 Same using HTTP/1.0 :
 {{{
 curl -0 -v "http://localhost/test.php"
 * About to connect() to localhost port 80
 *   Trying 127.0.0.1... connected
 * Connected to localhost (127.0.0.1) port 80
 > GET /test.php HTTP/1.0
 > User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
 > Host: localhost
 > Accept: */*
 >
 < HTTP/1.0 404 Not Found
 < Server: Apache
 < Cache-Control: max-age=0
 < Expires: Tue, 02 Dec 2008 11:56:59 GMT
 < Content-Type: text/html
 < Date: Tue, 02 Dec 2008 11:56:59 GMT
 < X-Varnish: 2027003751
 < Age: 0
 < Via: 1.1 varnish
 < Connection: close
 * Closing connection #0
 }}}

 Direct access to the apache backend :
 {{{
 curl -v http://localhost:81/test.php
 * About to connect() to localhost port 81
 *   Trying 127.0.0.1... connected
 * Connected to localhost (127.0.0.1) port 81
 > GET /test.php HTTP/1.1
 > User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
 > Host: localhost:81
 > Accept: */*
 >
 < HTTP/1.0 404 Not Found
 < Date: Tue, 02 Dec 2008 11:47:26 GMT
 < Server: Apache
 < Cache-Control: max-age=0
 < Expires: Tue, 02 Dec 2008 11:47:26 GMT
 < Connection: close
 < Content-Type: text/html
 Works! Works! Works! Works! Works! Works [...]
 }}}

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/400>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list