miyagawa / Starman

Starman is a high-performance preforking Perl PSGI web server
http://search.cpan.org/dist/Starman
Other
287 stars 84 forks source link

Do not send a chunked body for HEAD requests #87

Closed therigu closed 11 years ago

therigu commented 11 years ago

The HTTP 1.1 spec states

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response

If a Plack app does not set a body or a Content-Length for a response to a HEAD request (which I believe is correct), Starman currently enables chunked encoding and sends the chunked 'footer' in the body of the response. I believe this contradicts the spec (as above) and causes problems with my (nodejs) client.

Server.pm already disables chunked responses for status codes without a body (204 and 304) - this patch does the same for HEAD requests.

The test fails without the patch to the .pm, it has to use the low level IO::Socket::INET so we get the body before the chunked decoding is applied

therigu commented 11 years ago

Ah, I've just realised I committed with the wrong email address. I have updated the branch, would you be willing to pull that instead? I realise that would require a forced update, so if you're not willing I understand.

miyagawa commented 11 years ago

Yeah i wouldn't do forced update lightly. Sorry about that.