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.4.tar.gz (22.7 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.4-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

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

Hashes for httpx_pycurl-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ef8fa0171bab581f17bff3ddb429ce54f9055e5644c49d9873c476ede82e9386
MD5 a4c3f208e3a92a97874b49f7c946fc49
BLAKE2b-256 4a3358ea5b69246b4616b5dd93ed7078f3022e78ea1176f5762f1ee1d1da42e6

See more details on using hashes here.

Provenance

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

Hashes for httpx_pycurl-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bb3f9f2b7a2c3a774fcf1af0456b37d770e6c684279b36b391ebd9a497019fb8
MD5 f2229c70ea61117882f55238e351b6df
BLAKE2b-256 1f03e405f857ef5928b2c5b24d32a3e256c06b2ff558650b72726165a8fb9743

See more details on using hashes here.

Provenance

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