-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Client-sent Host header can include port as "None" #4039
Labels
Comments
Thanks for the report! The fix is ready |
asvetlov
added a commit
that referenced
this issue
Sep 6, 2019
asvetlov
added a commit
that referenced
this issue
Sep 6, 2019
…ovided (#4040) (cherry picked from commit db760f7) Co-authored-by: Andrew Svetlov <[email protected]>
asvetlov
added a commit
that referenced
this issue
Sep 6, 2019
…ovided (#4040) (#4041) (cherry picked from commit db760f7) Co-authored-by: Andrew Svetlov <[email protected]>
And thanks for the fix! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Long story short
When the client forms the Host header, it is possible for it to include the port as "None".
This came up for me when using
aiodocker
to try to connect to the Docker API container attach websocket endpoint, which used a URL of the form "unix://localhost/..." and let to a "Host" header of "localhost:None", triggering a 400 error from docker with a message like:Expected behaviour
At least, not to send "None" as a port number for the Host header.
According to RFC 7230 Section 5.4:
So perhaps it should be possible for the
aiohttp
client to get and recognize such a URI and send a blank Host header field.At the moment though, I think, it doesn't seem possible to send such an "authority"-less URL to
ws_connect
nor does there currently exist a conditional path for the Host header construction to make a blank Host header field: client_reqrep.py lines 314-320Actual behaviour
The Host header includes the string "None" as the port when making requests whose URL registers as not
is_default_port()
but has no port defined, e.g.unix://localhost/path/to/endpoint
.Steps to reproduce
This occurred for me while using the
aiodocker
package to attach tostdin
of a running container.A sort of silly example server/client that displays the behavior is as follows:
Output:
Your environment
BTW the specific thing that I think make this appear where it didn't before was a security update to Go that make URL parsing more strict: https://github.com/golang/go/issues?q=milestone%3AGo1.12.8
The text was updated successfully, but these errors were encountered: