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. 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

httpx_pycurl-0.0.3.tar.gz (18.0 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.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpx_pycurl-0.0.3.tar.gz
  • Upload date:
  • Size: 18.0 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.3.tar.gz
Algorithm Hash digest
SHA256 ac346f5310d412d4f1beba4b02b17b7dc5aacb0d4607e556ea8f6a9456805e7a
MD5 06bcba314c623c55c550c23500c0087a
BLAKE2b-256 3ffdea0ef02364d251f8740f9b3909c97a3ddbbe46d0befdef80b5ab4d525efa

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_pycurl-0.0.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: httpx_pycurl-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 517abbdbe6dda8281a9a17018c5ae92cef329eaf6eea02080d363563e6b04643
MD5 fc10692134fc6972c12579e9cc9d5598
BLAKE2b-256 69f9a2f2fa68dc8e62dad90e52ee976c30a70d64587fa6ae5a5a5ac03a5d40a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_pycurl-0.0.3-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