An httpx transport powered by pycurl
Project description
httpx-pycurl
httpx-pycurl provides an httpx transport that executes requests with
pycurl. It combines the goodness of curl with
the familiar httpx API, including support for http/2 and even non-http
protocols built into curl. On my machine, AsyncPyCurlTransport performs
better than httpx's default AsyncHttpTransport, taking approximately 75% of
the time to fetch 60 files from a local nginx test server.
httpx-pycurl is in early development, but it passes most httpx tests and has
good performance. A niquests-derived test uses asyncio.gather() to make 1000
http/2 requests to https://httpbingo.org/get. httpx-pycurl is about as fast.
# First run:
Fetch 1000x https://httpbingo.org/get
aiohttp: 1.029s
httpx: 1.369s
httpx_pycurl: 0.637s
niquests: 0.715s
# Second run:
Fetch 1000x https://httpbingo.org/get
aiohttp: 0.927s
httpx: 1.346s
httpx_pycurl: 0.677s
niquests: 0.655s
Install
pip install httpx-pycurl
Or with conda,
conda install -n base conda-pypi
conda pypi install httpx-pycurl
Usage
AsyncPyCurlTransport is the focus of this package. It uses the curl
multi_socket
interface to integrate curl with the asyncio event loop.
import httpx
from httpx_pycurl import AsyncPyCurlTransport
transport = AsyncPyCurlTransport(timeout=10.0)
async with httpx.AsyncClient(transport=transport) as client:
responses = await asyncio.gather(*(client.get(url) for url in urls))
AsyncPyCurlTransport delegates SSL/TLS handling to curl and does not use
Python's builtin ssl module. By default it calls
certifi.where() to set root
certificates. It is also possible to pass a custom path to the root certificates
with AsyncPyCurlTransport(cainfo=ca_cert_path).
PyCurlTransport is not the focus of this project and is less likely to work.
In the future it may delegate to AsyncPyCurlTransport.
import httpx
from httpx_pycurl import PyCurlTransport
transport = PyCurlTransport(timeout=10.0)
with httpx.Client(transport=transport) as client:
response = client.get("https://example.com")
print(response.status_code)
print(response.text)
debug_transport = PyCurlTransport(
verbose=True,
debug_callback=lambda info_type, data: print(info_type, data),
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpx_pycurl-0.0.4.tar.gz.
File metadata
- Download URL: httpx_pycurl-0.0.4.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef8fa0171bab581f17bff3ddb429ce54f9055e5644c49d9873c476ede82e9386
|
|
| MD5 |
a4c3f208e3a92a97874b49f7c946fc49
|
|
| BLAKE2b-256 |
4a3358ea5b69246b4616b5dd93ed7078f3022e78ea1176f5762f1ee1d1da42e6
|
Provenance
The following attestation bundles were made for httpx_pycurl-0.0.4.tar.gz:
Publisher:
pypi.yml on dholth/httpx-pycurl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
httpx_pycurl-0.0.4.tar.gz -
Subject digest:
ef8fa0171bab581f17bff3ddb429ce54f9055e5644c49d9873c476ede82e9386 - Sigstore transparency entry: 1384262080
- Sigstore integration time:
-
Permalink:
dholth/httpx-pycurl@823ba1a1bc5e8a3d46bfa8e8944829ad1ea84ce8 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/dholth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@823ba1a1bc5e8a3d46bfa8e8944829ad1ea84ce8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file httpx_pycurl-0.0.4-py3-none-any.whl.
File metadata
- Download URL: httpx_pycurl-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb3f9f2b7a2c3a774fcf1af0456b37d770e6c684279b36b391ebd9a497019fb8
|
|
| MD5 |
f2229c70ea61117882f55238e351b6df
|
|
| BLAKE2b-256 |
1f03e405f857ef5928b2c5b24d32a3e256c06b2ff558650b72726165a8fb9743
|
Provenance
The following attestation bundles were made for httpx_pycurl-0.0.4-py3-none-any.whl:
Publisher:
pypi.yml on dholth/httpx-pycurl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
httpx_pycurl-0.0.4-py3-none-any.whl -
Subject digest:
bb3f9f2b7a2c3a774fcf1af0456b37d770e6c684279b36b391ebd9a497019fb8 - Sigstore transparency entry: 1384262093
- Sigstore integration time:
-
Permalink:
dholth/httpx-pycurl@823ba1a1bc5e8a3d46bfa8e8944829ad1ea84ce8 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/dholth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@823ba1a1bc5e8a3d46bfa8e8944829ad1ea84ce8 -
Trigger Event:
push
-
Statement type: