HTTP Config
Shared, typed configuration for Python HTTP clients. Keep proxy, timeout, connection-limit, TLS, and request logging settings in one Pydantic model and reuse them across client integrations.
The core configuration models are client-library independent. The project currently provides an integration for HTTPX, with support for additional HTTP libraries planned for the future.
Installation
Using uv:
uv add "http-config[httpx]"
Using pip:
python -m pip install "http-config[httpx]"
The httpx extra installs the current HTTPX integration. The configuration models are available without any
client-library extra, allowing future integrations to be added independently.
Quick Start
from datetime import timedelta
from http_config import HTTPConfig, LimitConfig, TimeoutConfig
from http_config.httpx import sync_client
config = HTTPConfig(
timeout=TimeoutConfig(
timeout=timedelta(seconds=10),
connect_timeout=timedelta(seconds=3),
),
limits=LimitConfig(
max_connections=50,
max_keepalive_connections=10,
),
)
with sync_client(config) as client:
response = client.get("https://httpbin.org/get")
response.raise_for_status()
print(response.json())
For asynchronous code, use async_client:
from http_config.httpx import async_client
async def fetch() -> dict:
async with async_client() as client:
response = await client.get("https://httpbin.org/get")
response.raise_for_status()
return response.json()
Configuration
HTTPConfig supports these settings:
| Setting | Type | Description |
|---|---|---|
proxy |
str | None |
Proxy URL passed to the active client integration. |
timeout |
timedelta | False | TimeoutConfig | None |
Overall or per-operation timeout. False disables the timeout. |
limits |
LimitConfig | None |
Maximum open and keep-alive connections. |
ssl |
bool | SSLConfig | None |
TLS verification mode and custom certificate sources. |
log_path |
Path | None |
Directory where request and response files are recorded by supported integrations. |
Merging Configuration
The configuration models use pydantic-merge. Use
model_merge() to create a validated copy with updates applied recursively. Nested configuration is merged
instead of replaced, so an update to one timeout value preserves the other timeout values:
from datetime import timedelta
from http_config import HTTPConfig, TimeoutConfig
base = HTTPConfig(
timeout=TimeoutConfig(
timeout=timedelta(seconds=10),
read_timeout=timedelta(seconds=5),
),
)
updated = base.model_merge(
HTTPConfig(
timeout=TimeoutConfig(connect_timeout=timedelta(seconds=3)),
)
)
assert updated.timeout.timeout == timedelta(seconds=10)
assert updated.timeout.read_timeout == timedelta(seconds=5)
assert updated.timeout.connect_timeout == timedelta(seconds=3)
TLS
The default is normal certificate verification. Set ssl=False to disable verification, or provide a
custom CA file, directory, or certificate data with SSLConfig:
If certifi is installed, its CA bundle is used automatically
when no explicit cafile is configured. Install it separately with uv add certifi or
python -m pip install certifi. An explicit cafile takes precedence; set ignore_certifi=True to opt out
of the automatic certifi fallback.
from pathlib import Path
from http_config import HTTPConfig, SSLConfig
config = HTTPConfig(
ssl=SSLConfig(
cafile=Path("certificates/ca.pem"),
),
)
To disable the automatic certifi fallback:
from http_config import HTTPConfig, SSLConfig
config = HTTPConfig(ssl=SSLConfig(ignore_certifi=True))
SSLConfig.create() is useful when settings come from optional application configuration:
ssl_setting = SSLConfig.create(insecure=False, cafile=Path("ca.pem"))
Request Logging
Set log_path to enable file-based transport logging. The directory is created automatically. Each request
gets JSON header files and body files when a body is present, paired by a timestamp-based prefix and request
index.
from pathlib import Path
from http_config import HTTPConfig
from http_config.httpx import sync_client
config = HTTPConfig(log_path=Path("http-logs"))
with sync_client(config) as client:
client.get("https://httpbin.org/get")
HTTPX Middleware and Authentication
The current HTTPX client factories accept an optional transport middleware function and either an HTTPX auth object or a factory that receives the client:
import httpx
from http_config.httpx import sync_client
def middleware(transport: httpx.BaseTransport) -> httpx.BaseTransport:
return transport
with sync_client(
middleware=middleware,
auth=httpx.BasicAuth("user", "password"),
) as client:
response = client.get("https://example.com")
Development
Install the test dependencies and run the suite with:
uv sync --group test
uv run pytest
uv run ruff check
License
This project is available under the MIT License.
Release files for http-config 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| http_config-0.1.7.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| http_config-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / http_config-0.1.7.tar.gz
| Download URL | http_config-0.1.7.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5566693b88dc2ba88053766b1d6e3546dc6e8b5bc87a892639aad13beb4b5e89
|
|
BLAKE2b-256 checksum How to use checksums |
5bab7d703043b4a953161bf7796b058b1ff091a618677b447fa1f6b2c9a5e40d
|
| 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 Sep 2, 2026.
Transparency logRelease files / http_config-0.1.7-py3-none-any.whl
| Download URL | http_config-0.1.7-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04e330b550d14450efe6083b4e783d294963384a344a43e605567e287e0160e6
|
|
BLAKE2b-256 checksum How to use checksums |
7101c3c9c70c2a04349bb40b0623fb4168f3cbdc4c3e2166969ef96cf084e41b
|
| 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 Sep 2, 2026.
Transparency log