Skip to content
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

Pass throught custom http headers as transport configuration #1630

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions autobahn/wamp/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def _create_transport(index, transport, check_native_endpoint=None):
valid_transport_keys = [
'type', 'url', 'endpoint', 'serializer', 'serializers', 'options',
'max_retries', 'max_retry_delay', 'initial_retry_delay',
'retry_delay_growth', 'retry_delay_jitter', 'proxy',
]
'retry_delay_growth', 'retry_delay_jitter', 'proxy', 'headers'
]
for k in transport.keys():
if k not in valid_transport_keys:
raise ValueError(
Expand Down Expand Up @@ -160,6 +160,8 @@ def _create_transport(index, transport, check_native_endpoint=None):
raise ValueError(
'options must be a dict, not {}'.format(type(options))
)

headers = transport.get("headers", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want a check in "rawsocket" (i.e. headers should be None if kind == 'rawsocket' because headers doesn't make sense for that case).


if kind == 'websocket':
for key in ['url']:
Expand Down Expand Up @@ -252,6 +254,7 @@ def _create_transport(index, transport, check_native_endpoint=None):
serializers=serializer_config,
proxy=proxy,
options=options,
headers=headers,
**kw
)

Expand All @@ -268,7 +271,8 @@ def __init__(self, idx, kind, url, endpoint, serializers,
retry_delay_growth=1.5,
retry_delay_jitter=0.1,
proxy=None,
options=None):
options=None,
headers=None):
"""
"""
if options is None:
Expand All @@ -279,6 +283,7 @@ def __init__(self, idx, kind, url, endpoint, serializers,
self.url = url
self.endpoint = endpoint
self.options = options
self.headers = headers

self.serializers = serializers
if self.type == 'rawsocket' and len(serializers) != 1:
Expand Down
Loading