-
Notifications
You must be signed in to change notification settings - Fork 263
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
warp: Connections with HEAD requests are not kept alive if they don't have Content-Length #956
Comments
This will get around yesodweb/wai#956 But there are other endpoints so, perhaps we shouldn't do this.
Reading through RFC9110, it does say "However, a server MAY omit header fields for which a value is determined only while generating the content. [...] Such a response to GET might contain Content-Length and Vary fields, for example, that are not generated within a HEAD response." So I think removing the |
I don't remember why I gave special treatment to the |
Note for posterity, |
I've looked through RFC-2616 to check if HEAD was maybe handled differently in the past, but couldn't find any mention of it. So it is probably just a misunderstanding. A PR would be welcomed to rectify this. EDIT: Since it's in the |
Here is a tiny server for testing:
Any requests made to this server keep the connection alive except for HEAD requests.
The connection will hang on. Then send a
HEAD
request like this:The connection will be closed by the server.
I've tracked it down to these two lines:
wai/warp/Network/Wai/Handler/Warp/Response.hs
Line 143 in 2eb5339
wai/warp/Network/Wai/Handler/Warp/Response.hs
Line 386 in 2eb5339
So,
isChunked
is alwaysFalse
forHEAD
requests and it depends completely on theContent-Length
header in response.This is not what nginx expects and this causes a race between warp actually closing the connection and nginx using it again causing nginx sometimes return
502 Bad Gateway
. It also logs errors like this:I am not sure why the connection is closed on this. But I also noticed that when warp decides to close a connection it doesn't include the
Connection: close
header to tell the client that it shouldn't try to re-use the connection.The text was updated successfully, but these errors were encountered: