-
-
Notifications
You must be signed in to change notification settings - Fork 954
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
Additional headers for WS accept
message.
#1361
Conversation
It would be cool to have this supported by unicorn as well (although is not a prerequisite). |
@Kludex I will handle it soon. |
a080bf5
to
128e35f
Compare
Here is PR for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a single comment. Thanks @matiuszka ! 😄
Co-authored-by: Marcelo Trylesinski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides that, everything is cool!
Thanks @matiuszka ! 😄
Thanks @matiuszka ! 😄 |
@@ -315,6 +316,7 @@ def __enter__(self) -> "WebSocketTestSession": | |||
self.exit_stack.close() | |||
raise | |||
self.accepted_subprotocol = message.get("subprotocol", None) | |||
self.extra_headers = message.get("headers", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be message.get("headers", [])
with #1422
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this part is ok. When passing None
you'll need to check assert websocket.extra_headers is None
but with that change:
def test_additional_headers(test_client_factory):
def app(scope):
async def asgi(receive, send):
websocket = WebSocket(scope, receive=receive, send=send)
await websocket.accept(headers=None)
await websocket.close()
return asgi
client = test_client_factory(app)
with client.websocket_connect("/") as websocket:
assert websocket.extra_headers == []
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not. I don't have strong feelings on this. 👍
Hello,
Here is a proposal for improvement about supporting additional headers for the WebSocket
accept
messages.As per disscuision in gitter: