Skip to main content

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. AsyncPyCurlTransport performs better than httpx's default AsyncHttpTransport with http2=True, taking about 78% of the time to issue 128 requests in parallel. Under heavier usage httpx-pycurl appears to pull further ahead of alternative libraries, without replacing all of httpx; just httpx's transport.

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),
)

Installation

pip install httpx-pycurl

Or with conda,

conda install -n base conda-pypi
conda pypi install httpx-pycurl

Performance

httpx-pycurl is in early development but it passes most httpx tests and has good performance. Our tests/bench.py uses asyncio.gather() to make many http/2 requests to https://httpbingo.org/get using httpx, niquests, and httpx with httpx-pycurl's transport. httpx-pycurl is the fastest library tested.

Running tests/bench.py [N] shows that the more efficient http/2 libraries shine when performing large numbers of parallel requests, and are closer together when only groups of 128 parallel requests are made.

2 groups of 512 requests each...

Time per group:
httpx: 0.679s ± 0.119s
niquests: 0.432s ± 0.140s
httpx_pycurl: 0.299s ± 0.056s

Paired t-test: httpx_pycurl vs niquests
t-stat: -2.249 (approx p < 0.05 if |t| > 2.365)
Speedup: 1.44x
4 groups of 256 requests each...

Time per group:
httpx: 0.378s ± 0.077s
niquests: 0.259s ± 0.064s
httpx_pycurl: 0.190s ± 0.034s

Paired t-test: httpx_pycurl vs niquests
t-stat: -4.208 (approx p < 0.05 if |t| > 2.365)
Speedup: 1.36x
8 groups of 128 requests each...

Time per group:
httpx: 0.215s ± 0.073s
niquests: 0.205s ± 0.038s
httpx_pycurl: 0.162s ± 0.033s

Paired t-test: httpx_pycurl vs niquests
t-stat: -8.949 (approx p < 0.05 if |t| > 2.365)
Speedup: 1.27x

Dependencies

httpx-pycurl uses curl to support http/2 instead of the h2, hpack and hyperframe dependencies used by httpx.

$ pip install --dry-run httpx-pycurl
...
Would install anyio-4.13.0 certifi-2026.4.22 h11-0.16.0 httpcore-1.0.9 httpx-0.28.1 httpx-pycurl-0.0.4 idna-3.13 pycurl-7.45.7

$ pip install --dry-run httpx[http2]
...
Would install anyio-4.13.0 certifi-2026.4.22 h11-0.16.0 h2-4.3.0 hpack-4.1.0 httpcore-1.0.9 httpx-0.28.1 hyperframe-6.1.0 idna-3.13

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

httpx_pycurl-0.0.5.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpx_pycurl-0.0.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file httpx_pycurl-0.0.5.tar.gz.

File metadata

  • Download URL: httpx_pycurl-0.0.5.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httpx_pycurl-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2c5a4eafc65f6b15ebef815bcf2f230bd2ddc1650d43aca12239bab81eae5b85
MD5 6ee54c315f1f16282d807869b3d0b0fc
BLAKE2b-256 8440881864c3d7e0081b90d3866c421ede0d7c24b9cff15a792fbe8326361ca8

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_pycurl-0.0.5.tar.gz:

Publisher: pypi.yml on dholth/httpx-pycurl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file httpx_pycurl-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: httpx_pycurl-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httpx_pycurl-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbede9e0e96b298c869d857b21f53f36ff4d16a5a178494a4d14fe14a12d36e
MD5 e4e5e09bea95fff5380606e1256355c3
BLAKE2b-256 241bfd058cc256e84842212129fc11e16d45334a210b11d64acbc174a60f61f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_pycurl-0.0.5-py3-none-any.whl:

Publisher: pypi.yml on dholth/httpx-pycurl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page