Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #864 (defect)

Opened 2 months ago

Last modified 2 weeks ago

response.stream and HEAD method

Status: closed (fixed)

Reported by: kevinmusker@yahoo.co.uk Assigned to: fumanchu
Priority: normal Milestone: 3.1
Component: wsgiserver Keywords:
Cc:

When cherrypy.response.stream is set to true, the wsgiserver seems to output an empty chunk when responding to a HEAD request. The HTTP/1.1 spec states that the server must not return a message body, even an empty one.

The attached patch seems to fix it for my purposes. I don't fully understand the intricacies of the server code, so there is probably a better fix.

Attachments

wsgiserver_patch.diff (0.5 kB) - added by kevinmusker@yahoo.co.uk on 10/03/08 11:24:56.
Patch for wsgiserver
chunked.py (231 bytes) - added by kevinmusker@yahoo.co.uk on 10/06/08 04:11:43.
Simple demonstration

Change History

10/03/08 11:24:56: Modified by kevinmusker@yahoo.co.uk

  • attachment wsgiserver_patch.diff added.

Patch for wsgiserver

10/06/08 04:11:43: Modified by kevinmusker@yahoo.co.uk

  • attachment chunked.py added.

Simple demonstration

10/06/08 04:30:24: Modified by kevinmusker@yahoo.co.uk

As my initial post was a little low on detail, I have attached a sample app. The problem can be demonstrated using telnet.

 server:~$ telnet localhost 8080
 Trying ::1...
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 HEAD / HTTP/1.0

 HTTP/1.1 200 OK
 Date: Mon, 06 Oct 2008 09:16:06 GMT
 Content-Type: text/html
 Server: CherryPy/3.1.0

So the server responds to an HTTP/1.0 HEAD request as expected, due to 1.0 not supporting chunked encoding.

A similar, HTTP/1.1, request solicits this response:

 server:~$ telnet localhost 8080
 Trying ::1...
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 HEAD / HTTP/1.1
 Host: localhost

 HTTP/1.1 200 OK
 Date: Mon, 06 Oct 2008 09:18:55 GMT
 Content-Type: text/html
 Server: CherryPy/3.1.0
 Transfer-Encoding: chunked

 0

As you can see, the response to a HTTP/1.1 HEAD request includes a chunked body of zero length.

11/08/08 16:18:27: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 3.1.

Fixed in [2077].

Hosted by WebFaction

Log in as guest/cpguest to create tickets