python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

why session is not used in AsyncTransport ?

Open mathbeal opened this issue 2 years ago • 1 comments

the session param is not used.

https://github.com/mvantellingen/python-zeep/blob/4e16b7726b5027e83d0dbe911bd45f153b7a09dc/src/zeep/transports.py#L173

I'm using Api key on session header, it would be nice to be used in the following init lines.

        self.wsdl_client.headers = {
            "User-Agent": "Zeep/%s (www.python-zeep.org)" % (get_version())
            **dict(session.headers),
        }
        self.client.headers = {
            "User-Agent": "Zeep/%s (www.python-zeep.org)" % (get_version())
            **dict(session.headers),
        }

mathbeal avatar Oct 18 '21 19:10 mathbeal

Hello, @mathbeal. You can achieve that by using the AsyncTransport.client.headers attribute instead of session:

transport = AsyncTransport()
# https://www.python-httpx.org/advanced/#sharing-configuration-across-requests
transport.client.headers.update({"X-Api-Key": "top-secret"})

The session attribute seems to be deprecated after migration from aiohttp to httpx.

d-ryzhykau avatar Dec 17 '21 21:12 d-ryzhykau