crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 768 forks source link

Pass throught custom http headers as transport configuration #1630

Closed fungs closed 5 months ago

fungs commented 6 months ago

This minimalistic PR adds the possibility to specify custom http headers as transport configuration.

Example:

component = AutobahnComponent(
  transports={
    "type": "websocket",
    "url": "YOUR URL",
    "headers": {"Authorization": "YOUR CUSTOM AUTHORIZATION"},
  },
    ...
)

The patch does not change the internal logic, the configuration is automatically passed and used in the websocket connection factory. I tried to keep the changes minimal (although I was tempted to apply the boy scout rule and do some tidy up work).

oberstet commented 6 months ago

rgd

https://github.com/crossbario/autobahn-python/actions/runs/8187466713/job/22419880678?pr=1630#step:8:116

pls see

https://github.com/crossbario/autobahn-python/pull/1628#issuecomment-1976024550

TLDR: this is fallout from a breaking change in pytest-asyncio ...

fungs commented 6 months ago

I will do the polishing next week.

fungs commented 6 months ago

I will do the polishing next week.

Here we go, I raised a ValueError, as for the other incompatible arguments and removed the default None return value from get().

oberstet commented 6 months ago

flake is complaining about WS https://github.com/crossbario/autobahn-python/actions/runs/8357659564/job/22881485753?pr=1630#step:6:71

the asyncio issue is related to the latest (breaking) changes in pytest-asyncio rgd event loop setup I guess ..

oberstet commented 6 months ago
  autobahn/wamp/component.py:124:9: E123 closing bracket does not match indentation of opening bracket's line
  autobahn/wamp/component.py:163:1: W293 blank line contains whitespace
  1     E123 closing bracket does not match indentation of opening bracket's line
  1     W293 blank line contains whitespace
  flake8: exit 1 (4.27 seconds) /home/runner/work/autobahn-python/autobahn-python> flake8 -v --statistics --ignore=E402,E501,E722,E741,N801,N802,N803,N805,N806,N815,N818 --exclude 'autobahn/wamp/message_fbs.py,autobahn/wamp/gen/*' autobahn pid=2865
oberstet commented 5 months ago

rebased to master and rerunning CI .. let's see

https://github.com/crossbario/autobahn-python/pull/1638

oberstet commented 5 months ago

merged via #1638 - thanks for contributing!