File: __init__.py

package info (click to toggle)
python-truststore 0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 236 kB
  • sloc: python: 1,835; makefile: 13; sh: 6
file content (15 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import requests
import requests.adapters


class SSLContextAdapter(requests.adapters.HTTPAdapter):
    # HTTPAdapter for Requests that allows for injecting an SSLContext
    # into the lower-level urllib3.PoolManager.
    def __init__(self, *, ssl_context=None, **kwargs):
        self._ssl_context = ssl_context
        super().__init__(**kwargs)

    def init_poolmanager(self, *args, **kwargs):
        if self._ssl_context is not None:
            kwargs.setdefault("ssl_context", self._ssl_context)
        return super().init_poolmanager(*args, **kwargs)