-
Notifications
You must be signed in to change notification settings - Fork 62
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
Consider a more convenient API for responses to HEAD #42
Comments
Also, I just noticed that if an error happens relatively early in the cycle (I guess before the client passes from the
I get this:
Not sure if this is a problem or not. It also happens on entirely valid requests, e.g. those where the request-target is longer than the h11 limit. |
This is an excellent point that I indeed didn't think about at all :-). Good catch. I think I'm not worried about the The case when the headers exceed the maximum size is a bit trickier, but I think there's a limit to how much we should worry about these things... from a quick check, it looks like common production servers like Apache and Google respond to requests like I don't much like the idea of silently discarding I'm not seeing an immediate obvious change to make here, but I'll think about it. |
Right now h11 raises a
LocalProtocolError
if you try to send a non-emptyData
event in response to a HEAD request. This can be a nuisance in a catch-all handler, such as themaybe_send_error_response
in your Curio example. Notice how there’s no way formaybe_send_error_response
to tell that it’s not supposed to send data, because it has no access to the request event, andwrapper.conn.our_state
is stillSEND_BODY
. Handling this cleanly would require some refactoring of the example code. Not to mention that you have to remember HEAD exists in the first place.Would it perhaps be better if the state machine went from
SEND_RESPONSE
directly toDONE
in this case, so the handler could readily pick that up?Alternatively, what if h11 just silently ignored the
Data
events when responding to a HEAD request? (I can see the potential problems with this though: an application could keep “streaming” a long response into the bit bucket; also it’s not clear what to do with trailers if those pop up eventually.)These are just random ideas not grounded in any serious use of h11; feel free to ignore if this doesn’t sound good.
The text was updated successfully, but these errors were encountered: