http_tls — Rust & BoringSSL TLS (JA3/JA4) and HTTP/2 Impersonating HTTP Client for Python
http_tls (pip install http-tls) is a high-performance, standalone Rust + BoringSSL (btls) HTTP client for Python that reproduces byte-exact TLS (JA3, JA4, GREASE, ALPS, Post-Quantum X25519MLKEM768) and HTTP/2 (Akamai) browser fingerprints for over 100 Chrome, Safari, Firefox, Edge, Opera, OkHttp, and Tor profiles.
Built on Rust PyO3 (abi3-py38), Tokio, wreq, and Hickory async DNS, http_tls ships as a self-contained ~4.3 MB wheel with zero external C or Go dependencies and works as a drop-in replacement for requests, httpx, and curl_cffi.
Key Facts (At a Glance)
| Property | Value |
|---|---|
| PyPI Package | http-tls (pip install http-tls) |
| Python Import | import http_tls |
| TLS / HTTP Engine | Embedded Rust wreq + BoringSSL (btls), zero libcurl or Go CGo dependency |
| Async & DNS Stack | Native Rust Tokio runtime (pyo3-async-runtimes) + Hickory async DNS |
| Drop-in API Compatibility | requests, httpx (Client, AsyncClient, stream), and curl_cffi (BrowserType, impersonate) |
| Sync Parallelism | session.gather(urls, concurrency=50) — GIL-free multi-request batching without async/await |
| Fingerprinting | 100+ browser presets, custom JA3, tls_options, http2_options, exact wire header_order |
| WebSockets & Streaming | TLS-impersonated sync/async WebSockets, sync/async streaming, multipart files= |
| Reverse Engineering & Ops | Wireshark SSLKEYLOGFILE / keylog_file, HAR 1.2 export, Playwright storage_state.json, WAF resp.challenge detector |
| Python & Platform Support | Python 3.8 – 3.14+ (ABI3 wheels) on Windows x86_64, Linux manylinux_2_28 (x86_64, aarch64), macOS (x86_64, arm64) |
| License | MIT |
Table of Contents
- Why
http_tls? - Comparison:
http_tlsvscurl_cffi,primp,tls-client,httpx, andrequests - Verified Benchmarks & Live JA4 / HTTP/2 Fingerprint Audit
- Installation
- Migration & Drop-in Quick Start (
requests,httpx,curl_cffi,tls-client) - High-Concurrency Execution: Native Tokio Async & Sync
gather() - Streaming Responses & Multipart File Uploads
- TLS-Impersonated WebSockets (Sync & Async)
- Custom JA3, BoringSSL
tls_options, HTTP/2 Settings & Wire Header Order - Proxies, Custom DNS (
resolve), IPv6/64Binding & Hickory DNS - Authentication (
Basic,Bearer,Digest), Custom CA Bundles & Mutual TLS (mTLS) - WAF Challenge Detection, Retries, Playwright
storage_state.json& Solver Bridge - Traffic Inspection: Wireshark KeyLog & HAR 1.2 Export
- Supported Browser Impersonation Presets (100+ Profiles)
- API Reference Summary
- Frequently Asked Questions (FAQ)
- Testing & Development
- License
Why http_tls?
Standard Python HTTP clients (requests, urllib3, aiohttp, httpx) rely on the system OpenSSL stack. Their TLS ClientHello cipher suites, extensions, elliptic curves, and HTTP/2 SETTINGS frames produce non-browser JA3/JA4 signatures that are immediately flagged or throttled by Cloudflare, Akamai, DataDome, PerimeterX, Imperva, and Fastly.
Existing Python TLS-impersonating alternatives each carry architectural trade-offs:
tls-clientwraps a Go CGo shared library (utls), which suffers from CGo memory leaks in long-running workers, lacks nativeasyncio, and does not synchronizecookies.clear()across the FFI boundary.curl_cffibindslibcurl-impersonateover CFFI, carrying C memory-management complexity and lacking synchronous Rust-native batching, built-in WAF interstitial detection, HAR recording, or Playwrightstorage_state.jsonintegration.primpandrnetexpose Rust engines but do not provide full drop-in API compatibility withrequests,httpx, andcurl_cffi.
http_tls solves these problems in a single compiled Rust PyO3 module:
- Byte-Exact BoringSSL Fingerprinting: Authentic JA3, JA4, GREASE, ALPS, Post-Quantum
X25519MLKEM768, and Akamai HTTP/2 frame order for Chrome, Safari, Firefox, Edge, Opera, OkHttp, and Tor. - True Native Async + GIL-Free Sync Batching:
AsyncSessionmaps Rust Tokio futures directly onto Python'sasyncioevent loop with zeroasyncio.to_threadoverhead. Synchronous code can callsession.gather(urls, concurrency=50)to execute batches concurrently inside Rust while releasing the GIL. - Triple Drop-in API: Switch from
requests,httpx, orcurl_cffiby changing a single import line. - Rust RAII Memory Safety: Shared process-wide Tokio runtime and automatic resource cleanup with minimal Python heap overhead (16.4 KB peak Python allocation in sequential tests).
Comparison: http_tls vs curl_cffi, primp, tls-client, httpx, and requests
| Capability | http_tls |
curl_cffi |
primp / rnet |
tls-client |
httpx |
requests |
|---|---|---|---|---|---|---|
| Standalone BoringSSL TLS / JA4 | Yes (100+ presets) | Yes | Yes | Go utls |
No | No |
| Custom JA3, TLS & H2 Options | Yes | Yes | Partial | Yes | No | No |
Exact Wire Header Order (OrigHeaderMap) |
Yes | Partial | Yes | Yes | No | No |
| Native Event-Loop Async | Yes (Tokio) | Yes (libcurl) | Yes (Tokio) | No | Yes | No |
Sync Parallel gather() (No async/await) |
Yes (Rust Tokio) | No | No | No | No | No |
requests + httpx + curl_cffi Drop-in |
Yes | Partial | No | No | httpx only |
requests only |
Async Hickory DNS & Custom resolve |
Yes | resolve only |
Partial | No | No | No |
Outbound IPv4 / IPv6 /64 Socket Binding |
Yes | Yes | Partial | No | Partial | No |
| TLS-Impersonated WebSockets (Sync & Async) | Yes | Yes | Yes | No | No | No |
| Streaming, Multipart, Custom CA, mTLS | Yes | Yes | Partial | Partial | Yes | Yes |
RFC 7616 DigestAuth (MD5/SHA-256/512) |
Yes | No | No | No | Yes | Yes |
Deep cookies.clear() Sync Across FFI |
Yes | Yes | Yes | Broken | Yes | Yes |
Built-in WAF resp.challenge Detector |
Yes | No | No | No | No | No |
Playwright storage_state.json & Solver Bridge |
Yes | No | No | No | No | No |
Wireshark keylog_file & HAR 1.2 Export |
Yes | No | No | No | No | No |
| Memory Safety (No CGo / Manual Free) | Rust RAII | C/CFFI | Rust RAII | Go CGo leaks | Python | Python |
Verified Benchmarks & Live JA4 / HTTP/2 Fingerprint Audit
1. Live Multi-Browser Fingerprint Audit (https://tls.peet.ws/api/all)
Measured directly using the standalone Rust BoringSSL engine (engine="rust", zero external dependencies):
| Browser Preset | Negotiated Protocol | JA4 Fingerprint | Akamai HTTP/2 Fingerprint |
|---|---|---|---|
chrome_149 |
HTTP/2 | t13d1516h2_8daaf6152771_d8a2da3f94cd |
1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p |
edge_148 |
HTTP/2 | t13d1516h2_8daaf6152771_d8a2da3f94cd |
1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p |
safari_26_4 |
HTTP/2 | t13d2014h2_a09f3c656075_e42f34c56612 |
2:0;3:100;4:2097152;9:1|10420225|0|m,s,a,p |
firefox_151 |
HTTP/2 | t13d1717h2_5b57614c22b0_3cbfd9057e0d |
1:65536;2:0;4:131072;5:16384|12517377|0|m,p,a,s |
opera_131 |
HTTP/2 | t13d1516h2_8daaf6152771_02713d6af862 |
1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p |
okhttp_5 |
HTTP/2 | t13d1613h2_46e7e9700bed_eca864cca44a |
4:16777216|16711681|0|m,p,a,s |
2. Throughput, Latency & Python Heap Usage (https://www.cloudflare.com/cdn-cgi/trace)
Reproduce locally with python benchmarks/bench_vs_competitors.py:
Sequential Synchronous Benchmark (15 requests, warm connection):
| Python HTTP Client | Median Latency | Throughput | Peak Python Memory (tracemalloc) |
|---|---|---|---|
http_tls (Rust BoringSSL) |
38.0 ms | 24.4 req/s | 16.4 KB |
curl_cffi |
47.2 ms | 10.4 req/s | 19.2 KB |
httpx (HTTP/2, no TLS impersonation) |
40.0 ms | 15.7 req/s | 249.3 KB |
requests (HTTP/1.1) |
46.6 ms | 22.1 req/s | 170.7 KB |
Concurrent Asynchronous Benchmark (30 simultaneous requests):
| Python Async HTTP Client | Average per Request | Throughput | Peak Python Memory (tracemalloc) |
|---|---|---|---|
http_tls.AsyncSession (Native Tokio) |
2.9 ms | 346.0 req/s | 200.0 KB |
curl_cffi.AsyncSession |
4.7 ms | 211.4 req/s | 234.6 KB |
httpx.AsyncClient |
6.5 ms | 153.0 req/s | 525.0 KB |
In concurrent workloads, http_tls delivers 1.64x higher throughput than curl_cffi and 2.26x higher throughput than httpx while allocating 62% less Python heap memory than httpx.
Installation
Prebuilt ABI3 wheels (~4.3 MB) are published on PyPI for Windows (x86_64), Linux (manylinux_2_28 x86_64 and aarch64), and macOS (x86_64 and arm64), supporting Python 3.8 through 3.14+:
pip install http-tls
Upgrade to the latest version:
pip install -U http-tls
Building from Source
Building from source requires Rust (>= 1.98), cmake, perl, clang/libclang (plus nasm on Windows):
git clone https://github.com/real-coder-xD/http_tls.git
cd http_tls
pip install maturin
maturin build --release --out dist
pip install dist/*.whl
Migration & Drop-in Quick Start (requests, httpx, curl_cffi, tls-client)
1. Drop-in Replacement for requests
Replace import requests with import http_tls as requests:
import http_tls as requests
resp = requests.get("https://httpbin.org/get", timeout=10)
resp.raise_for_status()
print(resp.status_code == requests.codes.ok) # True
print(bool(resp.ok), resp.reason) # True OK
print(resp.headers["content-type"]) # Case-insensitive header access
with requests.session(params={"format": "json"}) as s:
s.get("https://httpbin.org/cookies/set?token=abc")
print(s.cookies.get_dict()) # {'token': 'abc'}
# Deep-clear removes cookies from both the Python wrapper and the Rust cookie jar
s.cookies.clear()
print(s.get("https://httpbin.org/cookies").json()["cookies"]) # {}
2. Drop-in Replacement for httpx
Replace import httpx with import http_tls as httpx:
import asyncio
import http_tls as httpx
with httpx.Client(
base_url="https://httpbin.org",
follow_redirects=True,
impersonate="chrome_149",
) as client:
r = client.get("/status/200")
print(r.is_success, r.reason_phrase, r.http_version, r.remote_addr)
with client.stream("GET", "/stream/5") as sr:
for chunk in sr.iter_text(chunk_size=128):
print(chunk, end="")
print("\nDownloaded bytes:", sr.num_bytes_downloaded)
async def main():
client = httpx.AsyncClient(base_url="https://httpbin.org", impersonate="chrome_149")
try:
r = await client.get("/get")
print(r.status_code, len(await r.aread()))
finally:
await client.aclose()
assert client.is_closed
asyncio.run(main())
3. Drop-in Replacement for curl_cffi
Replace from curl_cffi import requests, BrowserType with from http_tls import requests, BrowserType:
from http_tls import requests, BrowserType
resp = requests.get(
"https://tls.peet.ws/api/all",
impersonate=BrowserType.chrome149,
)
print(resp.status_code, resp.json()["tls"]["ja4"])
4. Migrating from tls-client
Replace tls_client.Session(client_identifier="chrome_120", random_tls_extension_order=True) with http_tls.Session(impersonate="chrome_149"):
import http_tls
with http_tls.Session(impersonate="chrome_149") as session:
resp = session.get("https://tls.peet.ws/api/all")
print(resp.status_code, resp.http_version)
High-Concurrency Execution: Native Tokio Async & Sync gather()
Native Tokio Async (AsyncSession / AsyncClient)
AsyncSession awaits Rust Tokio futures directly on Python's asyncio loop without spawning Python worker threads:
import asyncio
import http_tls
async def main():
async with http_tls.AsyncSession(impersonate="chrome_149") as session:
urls = [f"https://httpbin.org/anything?id={i}" for i in range(50)]
responses = await asyncio.gather(*(session.get(u) for u in urls))
print(f"Completed {len(responses)} requests")
asyncio.run(main())
Parallel Sync Batching (session.gather — No async/await Required)
session.gather() dispatches a list of URLs or request dictionaries directly onto the Rust Tokio multi-thread runtime while releasing the GIL, returning List[Response] in the exact input order:
import http_tls
with http_tls.Session(base_url="https://httpbin.org", impersonate="chrome_149") as s:
# Plain URL list
responses = s.gather([f"/anything?i={i}" for i in range(50)], concurrency=25)
# Mixed HTTP methods, headers, and JSON payloads
mixed = s.gather(
[
"/get?page=1",
{"method": "POST", "url": "/post", "json": {"batch": True}},
{"method": "GET", "url": "/headers", "headers": {"X-Trace": "1"}},
],
concurrency=10,
)
Streaming Responses & Multipart File Uploads
Sync & Async Streaming
import asyncio
import http_tls
# Top-level context manager (httpx style)
with http_tls.stream("GET", "https://httpbin.org/bytes/4096") as resp:
with open("output.bin", "wb") as f:
for chunk in resp.iter_bytes(chunk_size=1024):
f.write(chunk)
# Async streaming with line iteration
async def stream_lines():
async with http_tls.AsyncClient() as client:
async with client.stream("GET", "https://httpbin.org/stream/10") as resp:
async for line in resp.aiter_lines():
print(line)
asyncio.run(stream_lines())
Multipart Form-Data Uploads (files=)
import http_tls
with http_tls.Session() as s:
resp = s.post(
"https://httpbin.org/post",
data={"description": "quarterly-report"},
files={
"file": ("report.txt", b"payload-bytes", "text/plain"),
},
)
print(resp.status_code)
TLS-Impersonated WebSockets (Sync & Async)
Both synchronous and native async WebSocket connections inherit the session's BoringSSL TLS fingerprint, proxy settings, cookies, and custom headers:
import asyncio
import http_tls
# Synchronous WebSocket
with http_tls.Session(impersonate="chrome_149") as s:
with s.ws_connect("wss://echo.websocket.org") as ws:
ws.send_text("hello")
print(ws.recv_text())
ws.send_json({"event": "ping"})
print(ws.recv_json())
# Native Async WebSocket
async def ws_async():
async with http_tls.AsyncSession(impersonate="chrome_149") as s:
async with await s.ws_connect("wss://echo.websocket.org") as ws:
await ws.send_bytes(b"\x01\x02\x03")
kind, data = await ws.recv()
print(kind, data)
asyncio.run(ws_async())
Custom JA3, BoringSSL tls_options, HTTP/2 Settings & Wire Header Order
For custom mobile clients, non-standard APIs, or fingerprint research, override TLS parameters, HTTP/2 settings, and exact wire header casing and ordering (OrigHeaderMap):
import http_tls
with http_tls.Session(
# Standard 5-field JA3 string
ja3="771,4865-4866-4867-49195-49199,0-23-65281,29-23-24,0",
# Fine-grained BoringSSL configuration
tls_options={
"alpn": ["h2", "http/1.1"],
"grease_enabled": True,
"permute_extensions": True,
"enable_ech_grease": True,
"enable_ocsp_stapling": True,
},
# Custom HTTP/2 SETTINGS frame parameters
http2_options={
"header_table_size": 65536,
"enable_push": False,
"initial_window_size": 6291456,
"max_header_list_size": 262144,
},
# Enforce exact wire header order and casing
header_order=["Host", "Connection", "User-Agent", "Accept", "Accept-Language"],
# Optional protocol forcing: http1_only=True or http2_only=True
) as s:
resp = s.get("https://tls.peet.ws/api/all")
Proxies, Custom DNS (resolve), IPv6 /64 Binding & Hickory DNS
http_tls uses Hickory async DNS by default (eliminating OS resolver thread contention), supports HTTP/HTTPS/SOCKS5 proxies with round-robin pools, overrides DNS resolution per hostname without breaking TLS SNI, and binds outbound IPv4/IPv6 addresses for proxy-less IPv6 /64 rotation:
import http_tls
# Single HTTP / HTTPS / SOCKS5 proxy
r = http_tls.get("https://api.ipify.org?format=json", proxy="socks5://user:pass@1.2.3.4:1080")
# Custom DNS / Origin IP override (keeps TLS SNI and Host header intact)
with http_tls.Session(
resolve={"api.example.com": "93.184.216.34"},
# Bind outbound source IP (ideal for rotating an IPv6 /64 subnet without proxies)
local_address="2001:db8::42",
# On Linux/macOS: interface="eth0"
# Pass system_dns=True to fall back to the OS DNS resolver instead of Hickory DNS
) as s:
r = s.get("https://api.example.com/health")
print("Connected peer:", r.remote_addr)
Authentication (Basic, Bearer, Digest), Custom CA Bundles & Mutual TLS (mTLS)
import http_tls
from http_tls import BasicAuth, BearerAuth, DigestAuth
# Basic, Bearer, and RFC 7616 Digest Auth (MD5, SHA-256, SHA-512 — sync & async)
with http_tls.Session(auth=DigestAuth("alice", "secret")) as s:
r = s.get("https://httpbin.org/digest-auth/auth/alice/secret/SHA-256")
# Custom Root CA bundle (corporate TLS proxy or self-signed CA) + peer cert inspection
with http_tls.Session(verify="/path/to/custom_ca_bundle.pem", tls_info=True) as s:
r = s.get("https://internal.corp.local")
print("Server leaf certificate DER length:", len(r.peer_certificate or b""))
# Mutual TLS (client certificate + PKCS#8 private key, or single combined PEM)
with http_tls.Session(cert=("client.crt", "client.key")) as s:
r = s.get("https://mtls.example.com")
WAF Challenge Detection, Retries, Playwright storage_state.json & Solver Bridge
1. Automatic Anti-Bot Interstitial Detection & Resilient Retries
resp.challenge inspects status codes, headers, and challenge payloads to detect interstitials from cloudflare, ddos-guard, datadome, perimeterx, imperva, sucuri, vercel, and akamai:
import http_tls
with http_tls.Session(
impersonate="chrome_149",
retries=3,
retry_backoff=0.5,
retry_on_challenge=True,
rotate_impersonate=True, # rotates to market-share weighted_random on retry
proxies_pool=[
"http://user:pass@proxy1.example.com:8080",
"http://user:pass@proxy2.example.com:8080",
],
) as s:
resp = s.get("https://protected.example.com")
if resp.challenge:
print("Challenge provider detected:", resp.challenge)
2. Playwright / Camoufox storage_state.json & Solver Bridge
Reuse clearance sessions (cf_clearance, session cookies, and User-Agent) exported by Playwright or Camoufox, or attach FlareSolverr / a custom browser solver callback:
import http_tls
# Load cookies + User-Agent from Playwright context.storage_state(path="state.json")
with http_tls.Session(storage_state="state.json", impersonate="firefox_151") as s:
resp = s.get("https://protected.example.com/api/data")
s.save_storage_state("state.json")
# Automatic FlareSolverr or custom solver callback when a JS challenge is returned
with http_tls.Session(
retries=1,
retry_on_challenge=True,
flare_solverr_url="http://localhost:8191/v1",
) as s:
resp = s.get("https://protected.example.com")
3. Request & Response Event Hooks
import http_tls
def sign_request(ctx):
ctx["headers"]["X-Signature"] = "signed"
def log_response(resp):
print(f"{resp.status_code} {resp.url} ({resp.elapsed * 1000:.1f} ms)")
with http_tls.Client(event_hooks={"request": [sign_request], "response": [log_response]}) as c:
c.get("https://httpbin.org/get")
Traffic Inspection: Wireshark KeyLog & HAR 1.2 Export
Inspect TLS-encrypted HTTP/2 frames in Wireshark or replay full request/response waterfalls in Chrome DevTools:
import http_tls
with http_tls.Session(
impersonate="chrome_149",
keylog_file="sslkeys.log", # Or set SSLKEYLOGFILE env var to decrypt TLS in Wireshark
record_har=True, # Record all HTTP transactions in HAR 1.2 format
) as s:
s.get("https://httpbin.org/get")
s.post("https://httpbin.org/post", json={"test": 1})
s.export_har("session_trace.har") # Drag-and-drop into Chrome DevTools Network tab
Supported Browser Impersonation Presets (100+ Profiles)
Query the full list programmatically with http_tls.supported_presets():
- Google Chrome (
chrome_100–chrome_152): Desktop Windows/Linux, macOS (chrome_152_macos,chrome_151_macos), Android (chrome_131_android), and dynamic forward-version Client Hints patching. - Microsoft Edge (
edge_101–edge_152):edge_152,edge_148,edge_147,edge_145,edge_142,edge_134,edge_131,edge_127,edge_122,edge_101. - Apple Safari (
safari_15_3–safari_27): macOS (safari_27,safari_26_4,safari_18_5,safari_18,safari_17), iOS (safari_ios_26_2,safari_ios_26,safari_ios_18_1_1), and iPadOS (safari_ipad_26,safari_ipad_18). - Mozilla Firefox (
firefox_109–firefox_155): Desktop, private browsing (firefox_private_136), and Android (firefox_android_135). - Opera (
opera_116–opera_131):opera_131,opera_130,opera_128,opera_124,opera_120,opera_116. - OkHttp (Android):
okhttp_5,okhttp_4_12,okhttp_4_10,okhttp_4_9,okhttp_3_14,okhttp_3_11. - Tor & Automatic Rotation:
tor_14_5,random, andweighted_random(market-share weighted browser + OS selection).
API Reference Summary
Session / Client / AsyncSession / AsyncClient Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
impersonate |
str | BrowserType |
"chrome_152" |
Browser TLS + HTTP/2 + header profile |
base_url |
str |
"" |
Base URL prepended to relative request paths |
timeout / connect_timeout / read_timeout |
float | None |
30.0 |
Request, connect, and read timeouts in seconds |
verify |
bool | str |
True |
True, False, or path to a custom CA .pem/.der bundle |
cert |
str | tuple[str, str] |
None |
Client mTLS certificate (combined.pem or (crt, key)) |
proxy / proxies / proxies_pool |
str | dict | list |
None |
HTTP/HTTPS/SOCKS5 proxy or round-robin proxy list |
headers / header_order |
dict | list[str] |
None |
Default headers and exact wire header order/casing |
params / cookies |
dict |
None |
Default query parameters and session cookies |
auth |
tuple | AuthBase |
None |
(user, pass), BasicAuth, BearerAuth, or DigestAuth |
ja3 / tls_options / http2_options |
str | dict |
None |
Custom JA3 string and low-level BoringSSL / H2 overrides |
http1_only / http2_only |
bool |
False |
Force HTTP/1.1 or HTTP/2 transport |
resolve |
dict[str, str | list] |
None |
Custom DNS / origin IP mapping ({"host": "ip"}) |
local_address / interface |
str |
None |
Bind outbound IPv4/IPv6 address or network interface |
system_dns |
bool |
False |
Disable built-in Hickory async DNS and use OS resolver |
retries / retry_backoff / retry_statuses |
int | float | tuple |
0 |
Automatic retry count, exponential backoff base, and status codes |
retry_on_challenge / rotate_impersonate |
bool |
False |
Auto-retry and rotate preset/proxy on WAF challenge |
storage_state / flare_solverr_url / solver |
str | dict | callable |
None |
Playwright storage_state.json loader and JS challenge bridge |
tls_info / keylog_file / record_har |
bool | str |
False |
Capture peer cert DER, write Wireshark keylog, record HAR 1.2 |
event_hooks |
dict[str, list] |
None |
Sync or async {"request": [...], "response": [...]} hooks |
Key Response Attributes & Methods
- Metadata:
status_code,reason,reason_phrase,url,http_version,headers,cookies,elapsed,history,remote_addr,peer_certificate,links,num_bytes_downloaded,challenge. - Status Helpers:
ok,is_success,is_informational,is_redirect,is_permanent_redirect,has_redirect_location,is_client_error,is_server_error,is_error,raise_for_status(). - Body & Streaming:
content,text,json(),read(),aread(),acontent(),atext(),iter_content(),iter_bytes(),iter_text(),iter_lines(),aiter_bytes(),aiter_content(),aiter_text(),aiter_lines(),close(),aclose().
Exception Hierarchy (http_tls.exceptions)
Compatible with requests, httpx, and curl_cffi exception names:
RequestException (RequestError, RequestsError), HTTPError (HTTPStatusError), ConnectionError (ConnectError), Timeout (TimeoutException), ConnectTimeout, ReadTimeout, SSLError, TooManyRedirects, InvalidURL.
Frequently Asked Questions (FAQ)
How does http_tls differ from curl_cffi?
http_tls is compiled in Rust against BoringSSL (btls) and Tokio rather than wrapping libcurl via CFFI. In live benchmarks against Cloudflare, http_tls achieves higher sync and async throughput (346 req/s vs 211 req/s at 30-way concurrency), adds GIL-free parallel session.gather() for synchronous code, and includes built-in WAF challenge detection, RFC 7616 Digest Auth, HAR 1.2 export, Wireshark keylog_file, and Playwright storage_state.json support.
Does http_tls require libcurl, Go, or external binaries?
No. BoringSSL, Tokio, HTTP/2, and Hickory DNS are compiled directly into the native PyO3 extension inside the ~4.3 MB wheel. Installing via pip install http-tls requires zero external runtime dependencies.
How can I send concurrent requests in http_tls without writing async/await?
Use session.gather(urls, concurrency=50). It executes all requests in parallel on the Rust Tokio multi-thread runtime while releasing Python's GIL and returns responses in the exact input order.
How do I reuse Playwright or Camoufox clearance cookies in http_tls?
Export browser cookies with context.storage_state(path="state.json") and pass storage_state="state.json" to http_tls.Session(...). http_tls loads all matching cookies and User-Agent headers into the Rust cookie jar and can write updated cookies back with session.save_storage_state("state.json").
How do I decrypt and inspect http_tls HTTPS / HTTP/2 traffic in Wireshark?
Pass keylog_file="sslkeys.log" to Session(...) (or set the SSLKEYLOGFILE environment variable), then point Wireshark's Preferences -> Protocols -> TLS -> (Pre)-Master-Secret log filename to that file.
Which Python versions and operating systems are supported?
http_tls publishes prebuilt ABI3 wheels (cp38-abi3) covering Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14+ on Windows (x86_64), Linux (manylinux_2_28 x86_64 and aarch64), and macOS (x86_64 and Apple Silicon arm64).
Testing & Development
Run the full pytest suite (23 integration and unit tests covering TLS/JA4, HTTP/2, sync/async streaming, gather(), WebSockets, Digest Auth, custom CA/mTLS, storage_state.json, HAR export, and httpx/requests parity):
pip install -e ".[test]"
pytest -v tests/
Run the live throughput and memory benchmark against curl_cffi, httpx, and requests:
python benchmarks/bench_vs_competitors.py --url https://www.cloudflare.com/cdn-cgi/trace --n 15 --concurrency 30
See CHANGELOG.md for the complete version history.
License
Released under the MIT License.
Metadata
Release files for http-tls 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| http_tls-0.6.2.tar.gz | 88.5 kB | With provenance | Details for http_tls-0.6.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| http_tls-0.6.2-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details for http_tls-0.6.2-cp38-abi3-win_amd64.whl |
| http_tls-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.28+ x86-64 | Details for http_tls-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl |
| http_tls-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.28+ ARM64 | Details for http_tls-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl |
| http_tls-0.6.2-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details for http_tls-0.6.2-cp38-abi3-macosx_11_0_arm64.whl |
| http_tls-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl | CPython 3.8 | abi3 | macOS 10.12+ x86-64 | Details for http_tls-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl |
Total release size: 21.4 MB
Release files / http_tls-0.6.2.tar.gz
| Download URL | http_tls-0.6.2.tar.gz |
|---|---|
| Size | 88.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4645f1c9ae1b794982f5875889c338514b83268112c8dc0f728e7ffe57ca726
|
|
BLAKE2b-256 checksum How to use checksums |
de578cfcf22f7e2c5b8e9603778a7548392031c577c6ee0369be1a2735cbdc38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / http_tls-0.6.2-cp38-abi3-win_amd64.whl
| Download URL | http_tls-0.6.2-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1d13ab28e8b998f0650e8677ca635a23e81d013c43e920db3cb2730f12a86a8c
|
|
BLAKE2b-256 checksum How to use checksums |
b7042b2a45ceb0a4de41de5de082ece6fe4816510a7d50acf45adbf15470d454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / http_tls-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl
| Download URL | http_tls-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.4 MB |
| Tags | CPython 3.8 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a42998c782d26757b91639790920c891c7ebf0971a8774386454f480adc04a27
|
|
BLAKE2b-256 checksum How to use checksums |
27d9795248a6f828984951e45f3ff07415b3683100a4e04aae4f6128001c7f9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / http_tls-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl
| Download URL | http_tls-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.8 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
15c00f2304fb1c38d052ae8df419c78feb9481178dc4c5a144e7f82c8fa96589
|
|
BLAKE2b-256 checksum How to use checksums |
2f17faa5e26d272fb0b4a9c0929a1be3bfb3a931143451321d0615e7576e2c98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / http_tls-0.6.2-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | http_tls-0.6.2-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
03d8ca15b68c8cfa1f98b9f4e0f3d42551bdcb7525c58475a00df4947f9dce43
|
|
BLAKE2b-256 checksum How to use checksums |
772ab594de9457b156235ed5017059f4271e200ddd0d1401c106fa52885b9ec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / http_tls-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl
| Download URL | http_tls-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.8 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
31d0479ca0e6253642606723e7fb2224f5b1c3b3eb897cf29a967f7387542af2
|
|
BLAKE2b-256 checksum How to use checksums |
0ebf70a5e5938b90d20046954905fd851faf19af752edfc282c142479ceb9483
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logSecurity for http-tls 0.6.2
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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for http_tls-0.6.2.tar.gz
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 Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.