When used with HTTPX, this transport makes it easier to transition from Requests to HTTPX by keeping the same underlying HTTP networking layer.
Compatible with: HTTPX 0.15.x, 0.16.x (i.e. HTTPCore 0.11.x and HTTPCore 0.12.x).
Note: not all
urllib3 pool manager options are supported here — feel free to adapt this gist to your specific needs.
import httpx from urllib3_transport import URLLib3Transport with httpx.Client(transport=URLLib3Transport()) as client: response = client.get("https://example.org") print(response)
If you want to pass a custom
ssl_context using the same options than HTTPX (
trust_env), use the
import httpx from urllib3_transport import URLLib3Transport ssl_context = httpx.create_ssl_context(verify="/tmp/client.pem") with httpx.Client(transport=URLLib3Transport(ssl_context=ssl_context)) as client: response = client.get("https://example.org") print(response)
See also Changing the verification defaults in the HTTPX docs.
Copyright (c) 2020 Florimond Manca
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.