-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure response to HEAD request won't have message body #1079
Ensure response to HEAD request won't have message body #1079
Conversation
Ensure that Gunicorn won't try to use chunked transfer-encoding for responses to a HEAD request, so that `Response.close` will not write a terminating chunk. Responses to a HEAD request MUST NOT have a message-body. The application is still responsible for ensuring no message body is actually generated in response to a HEAD request.
Ensure response to HEAD request won't have message body
thanks! |
I have spent two months investigating a sporadic malfunction of an application of mine. I finally found this PR and it solved my problem. My problem was HEAD leaving "garbage" behind in the socket "sometimes", that Apache (acting as a reverse proxy) was reusing as the response to the next request. Could you consider pushing a new gunicorn release? |
there is one planned next week. However if you're returning some data on head, better fix your app since it will likely try to send a body when gunicorn will ignore it :) |
I do not return anything in HEAD. Just "return []". Looking forward the new release :) |
well if you only return that the patch shouldnt change anything. anyway will update you when the release is done. |
The patch solves my problem because "HEAD" was sending a chunked fragment of size zero when the standard says that HEAD doesn't return ANY body at all. The result was that HEAD was ok, but next request reusing the connection will read the "pending" chunked reply as the beginning of a HTTP/0.9 reply, with bad results. So, yes, this patch is actually critical. Steps to reproduce:
|
I think you're both agreeing, but talking about what different parts of the stack are sending. @jcea is talking about what Gunicorn send back to the client (Apache, in this case), and @benoitc is talking about what the app "sends" to Gunicorn. @jcea, your issue was exactly the same as what I was troubleshooting until I stumbled across a reproduction and isolated it. I ended up swapping out Apache for nginx, which also resolved the issue as well -- nginx behaves better in the face of the response to the HEAD request having a content-body. |
@darkrain42, then nginx is defective :-p. Anyway, thanks for catching and solving this! |
One of the steps I did to triage this was to configure Apache to avoid connection reusing to the gunicorn backend. That also solved the perceived issue but, of course, not the real issue. |
…D-replies Ensure response to HEAD request won't have message body
Ensure that Gunicorn won't try to use chunked transfer-encoding for responses
to a HEAD request, so that
Response.close
will not write a terminatingchunk. Responses to a HEAD request MUST NOT have a message-body.
The application is still responsible for ensuring no message body is actually
generated in response to a HEAD request.
Refs #990