Skip to main content

FogHTTP logo

FogHTTP

Rust-powered HTTP client for Python with sync and asyncio APIs.

FogHTTP is a focused pre-0.5 HTTP client. The public API is Python-first, while the transport core is implemented in Rust on top of hyper.

FogHTTP is positioned as an observable, high-concurrency Rust-powered transport for Python services. It is built for controlled service-to-service HTTP workloads where explicit lifecycle, predictable resource usage, cancellation, redirect history, and request backpressure visibility matter more than browser-like feature parity.

The supported production path is an explicitly owned Client or AsyncClient, normally reused for one application lifecycle. FogHTTP does not create a hidden module-level HTTP client or shared connection pool. See Client lifecycle for the ownership contract and the limits any future convenience helpers must preserve.

Until version 0.5.0, backward compatibility is not guaranteed. I will still try to keep public interfaces stable and avoid unnecessary breaking changes.

Why FogHTTP

  • Rust hyper transport with a Python-first API
  • sync and asyncio clients with the same request model
  • explicit close()/aclose() lifecycle for Rust transport resources
  • graceful sync close() for in-flight requests and cancellable async requests
  • bounded global/per-origin request backpressure, FIFO pending-acquire limits, explicit HTTP/1.1 connection caps, and per-origin pressure diagnostics
  • typed telemetry event hooks with redacted request/response lifecycle events
  • opt-in structured lifecycle debug logging through standard Python logging
  • versioned telemetry snapshots that separate alert-oriented stats from diagnostic dump APIs
  • optional Prometheus/OpenMetrics adapters with bounded labels and no diagnostic-dump alert series
  • opt-in Rust-owned retries with replayability gates and immutable attempt traces, plus opt-in per-hop and post-DNS SSRF destination controls
  • opt-in async lifecycle debug snapshots for staging and tests
  • lazy process-wide shared Tokio runtime by default, opt-in dedicated runtime tuning, and fail-closed client ownership across fork()
  • focused HTTP surface for JSON, form, streaming upload, and multipart API workloads in internal services, workers, and benchmarks

Install

pip install foghttp

Prometheus/OpenMetrics integration is an optional extra:

pip install "foghttp[prometheus]"

Runtime requirements:

  • Python >=3.11
  • orjson>=3.11,<4

Published CPython wheels use the stable cp311-abi3 ABI: each supported OS/architecture pair has one wheel for the currently validated GIL-enabled CPython 3.11 through 3.14 range. Newer Python versions are not part of the compatibility claim until they pass the same release checks. See Packaging and Python compatibility for the complete wheel matrix and validation policy.

Quick Start

import foghttp


with foghttp.Client(
    base_url="https://api.example.com",
    headers={"accept": "application/json"},
    params={"api-version": "1"},
) as client:
    response = client.get(
        "users",
        params={"limit": 10},
    )

    response.raise_for_status()
    print(response.status_code)
    print(response.json())

Async clients use the same request API:

import foghttp


async with foghttp.AsyncClient() as client:
    response = await client.post(
        "https://api.example.com/users",
        json={"name": "Ada Lovelace"},
    )
    response.raise_for_status()

What Works Today

  • sync Client and async AsyncClient
  • GET, HEAD, POST, PUT, PATCH, DELETE, and RFC 10008 QUERY
  • base_url for reusable API clients and relative request paths
  • default client headers and query params for reusable API clients
  • query params with repeated keys, JSON, form-urlencoded data, buffered bytes/text bodies, binary file-like request bodies, and streaming bytes-like upload providers
  • multipart files= uploads with bytes-like parts, binary file-like objects, direct byte streams, and replayable byte-stream factories
  • buffered Response with status flags, charset-aware text, json(), raise_for_status(), and request metadata
  • transparent gzip, deflate, and br decoding for buffered responses
  • sync and async bytes/text/line response streaming with explicit context-managed lifecycle
  • prepared Request objects with build_request() and send()
  • immutable request extensions for policy/application metadata outside the HTTP message
  • case-insensitive Headers with repeated values
  • safe policy for transport-managed request headers
  • redacted repr/error surfaces for sensitive headers, URL credentials, token-like URL params, and buffered body bytes
  • normalized URL model with origin comparison and relative joins
  • GET/HEAD/POST/QUERY redirects with final URL, history, typed same-origin and cross-origin header policy, and no cross-origin body replay
  • HTTP proxy routing and HTTPS proxy CONNECT tunnelling through explicit proxy= or trust_env=True when the proxy endpoint uses http://
  • HTTPS with default WebPKI roots, explicit custom CA certificates, and custom-only CA trust
  • graceful sync close() that waits for in-flight sync requests
  • async request cancellation that aborts the in-flight Rust request
  • bounded global and per-origin request slots with a bounded FIFO pending queue
  • opt-in global/per-origin HTTP/1.1 connection caps with separate connection acquire pressure and idle lifecycle diagnostics
  • opt-in typed telemetry event hooks for pool acquire, HTTP/1 connection, request, redirect, response headers, response body, and request completion lifecycle
  • opt-in typed transport policy hooks for lightweight request admission and response-head checks without default-path Python callbacks
  • opt-in Rust-owned retry policy for selected statuses and pre-header network failures, with safe methods, replayable bodies, and immutable attempt traces
  • opt-in Rust-owned SSRF destination policy with per-hop allowlists, post-resolution IP checks, and DNS rebinding mitigation
  • versioned telemetry snapshot metadata for stats(), dump_transport_state(), and dump_pool_diagnostics()
  • opt-in async lifecycle debug mode for active request snapshots, strict leak checks, and unclosed-client diagnostics
  • default per-response and aggregate buffered response body limits for memory safety
  • shared Tokio runtime by default, with opt-in dedicated runtime worker tuning
  • grouped HTTP status constants and reusable HTTP method constants
  • client-level Basic and synchronous callable authentication with retry refresh and cross-origin credential stripping
  • opt-in client-owned cookie jar with bounded domain/path/expiry matching, redirect/retry coordination, and redacted diagnostics

Documentation

Current Limitations

FogHTTP is currently focused on controlled HTTP workloads. Buffered responses are the broadest supported response path; sync and async response streaming are available as bytes/text/line context-managed APIs. Streaming content= uploads and multipart files= uploads are available with explicit replayability and cleanup rules. HTTP proxy routing and HTTPS proxy CONNECT tunnelling are available through proxy= and trust_env=True when the proxy endpoint itself uses http://. Proxy-routed requests fail closed when SSRFPolicy is enabled because the client cannot prove which target address a remote proxy resolves. Provider-specific OAuth flows, HTTP/2, automatic Accept-Encoding negotiation, streaming decompression, and per-request connect timeout reconfiguration are planned for later versions. Physical connection caps currently apply to the HTTP/1.1 connector path; HTTP/2 will require separate stream-level limits. Response body read timeout is available for buffered and streaming response bodies; request body write timeout is available for buffered and streaming request bodies. Socket lifecycle telemetry is available for the current HTTP/1 path. Disabling TLS verification is intentionally not supported.

Development

Development requires a Rust toolchain with cargo available in PATH.

uv run --extra dev --with "maturin>=1.7,<2" maturin develop --locked --skip-install
uv run --extra dev coverage run -m pytest && uv run --extra dev coverage report -m
uv run --extra dev pre-commit run --all-files --show-diff-on-failure

Metadata

Release files for foghttp 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foghttp 0.4.0
File Size Uploaded
foghttp-0.4.0.tar.gz 1.6 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for foghttp 0.4.0
File
foghttp-0.4.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
foghttp-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
foghttp-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
foghttp-0.4.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
foghttp-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 13.8 MB

Release files / foghttp-0.4.0.tar.gz

Download URL foghttp-0.4.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
e713d25145cc1c13d0d3ec019cbae2aea3e5af8a48bf997a487b095523dd39ae
BLAKE2b-256 checksum
How to use checksums
41d1b0e6c28c8d2a448728459aa0a2aafa817061c2fedc3d05bcc90d58d9af96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / foghttp-0.4.0-cp311-abi3-win_amd64.whl

Download URL foghttp-0.4.0-cp311-abi3-win_amd64.whl
Size 2.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
90e7e3cde6cd9cba6554939c680465fc7abae740f3cade46a967d5ea65dd2ecd
BLAKE2b-256 checksum
How to use checksums
560ba2ad80616c2c4db5888aed2c90ec1fa85bf7f4a16b25faf42d9893a0c42e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / foghttp-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL foghttp-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e6f18b4c8f6fddfadbdc2ef0b5c42846f93bf80cfb57599ed3a9575b7fafea03
BLAKE2b-256 checksum
How to use checksums
36964e5094234eb113793f0f8c90014748b10be3519b966759e9ed88d362cff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / foghttp-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL foghttp-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a3be64b6123af8c8c4696289db143200b4b6b524b0d2d92ac7319914c9c1a82a
BLAKE2b-256 checksum
How to use checksums
39d9478913c757617c9ca6cef55593c7bc0324e127c77b6fb1582419d3e6180f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / foghttp-0.4.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL foghttp-0.4.0-cp311-abi3-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ec0a88a7017ffbf66374ebba9d295efd80bb4fa8be14401e430fb9b91226c58f
BLAKE2b-256 checksum
How to use checksums
5a4d623574a8f2bbcb27c7b3d5263ac483e87f75ee61a33f1117d866e08fc4f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / foghttp-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL foghttp-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
820b44456ad5af84a5b45ff7e0ab01a03e8a3ed6a695b20c7f3ed0ff2ea6158c
BLAKE2b-256 checksum
How to use checksums
80a2ee2bf23cd716517bdf03909d716e5823c8e9844587ca5660d9f924dd2ea4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.1

6 release files

This release

0.4.0 This release

6 release files

0.3.9

6 release files

0.3.8

6 release files

0.3.7

6 release files

0.3.6

6 release files

0.3.3

21 release files

0.3.2

21 release files

0.3.1

21 release files

0.3.0

21 release files

0.2.1

21 release files

0.2.0

21 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page