-
-
Notifications
You must be signed in to change notification settings - Fork 946
Support extra_headers for WS accept message
#1293
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,7 @@ def __init__( | |
| ping_timeout=self.config.ws_ping_timeout, | ||
| extensions=extensions, | ||
| logger=logging.getLogger("uvicorn.error"), | ||
| extra_headers=[], | ||
| ) | ||
|
|
||
| def connection_made(self, transport): | ||
|
|
@@ -236,6 +237,13 @@ async def asgi_send(self, message): | |
| ) | ||
| self.initial_response = None | ||
| self.accepted_subprotocol = message.get("subprotocol") | ||
| if "headers" in message: | ||
| self.extra_headers.extend( | ||
| # ASGI spec requires bytes | ||
| # But for compability we need to convert it to strings | ||
| (name.decode("latin-1"), value.decode("latin-1")) | ||
| for name, value in message.get("headers") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just small syntax comment:
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true, PR welcome :P
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @t1waz are you going to open PR for that? I can do that also. |
||
| ) | ||
| self.handshake_started_event.set() | ||
|
|
||
| elif message_type == "websocket.close": | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.