Requests v1.2.3 doesn’t expose httplib
’s support (since Python 2.7) for specifying the source address for binding the socket used by HTTPConnection
:
- https://github.com/kennethreitz/requests/issues/394
- https://github.com/kennethreitz/requests/issues/995
- urllib3/urllib3#9
“This is what connection adapters are for.”
The example in adapter.py
shows a basic implementation of a transport adapter that supports a src_addr
keyword argument for specifying the source address. It has the following limitations because I did the simplest thing that could possibly work for my requirements:
- Requires Python 2.7+ for source address support in
httplib
orhttp.client
. - Not tested with Python 3.
- Supports only HTTPS.
- Doesn’t validate SSL credentials.