⚡ http_tls
High-performance Rust-powered HTTP client with byte-exact TLS (JA3/JA4) & HTTP/2 fingerprint impersonation.
100% Drop-in replacement for both requests and curl_cffi.
🌟 Why http_tls?
Traditional HTTP libraries (requests, urllib3, aiohttp, httpx) are blocked instantly by modern anti-bot systems (Cloudflare Bot Management, Akamai, DataDome, CloudFront) because their TLS ClientHello (JA3/JA4) and HTTP/2 settings frames leak signatures.
curl_cffi solved this by wrapping C-based curl-impersonate, but suffers from complex C runtime dependencies, memory leak risks in long-running async loops, and difficult cross-compilation.
http_tls is engineered in Rust to give you the best of both worlds:
- Byte-Exact TLS & HTTP/2 Fingerprint: Generates identical JA4 hashes (
t13d1517h2_...) and Chrome HTTP/2 pseudo-header ordering (:method,:authority,:scheme,:path->m,a,s,p). - 100% Drop-in for
requests: Replaceimport requestswithimport http_tls as requests— zero code changes required. - 100% Drop-in for
curl_cffi: Fully compatible withfrom http_tls import requests, BrowserType. - Blazing Fast (+32% Throughput): Multi-threaded Rust core with complete Python GIL release (
py.allow_threads). - Modern 2026 Presets: Ships with presets up to Chrome 152, Safari 27, Firefox 155, and Edge 152, plus dynamic version generation.
- Self-Contained & Stable ABI3: Single wheel distribution for all Python versions (3.8 - 3.14+).
📊 Benchmarks & Fingerprint Parity
Tested against https://tls.peet.ws/api/all (the canonical TLS fingerprint diagnostic tool):
| Metric | requests / httpx |
curl_cffi (pip) |
http_tls (Rust) |
Cloudflare Status |
|---|---|---|---|---|
| JA4 TLS Hash | t13d1011h2 (Bot) |
t13d1517h2 (Chrome) |
t13d1517h2 (Chrome) |
✅ PASSED |
| H2 Pseudo-Headers | m,s,a,p (Bot) |
m,a,s,p (Chrome) |
m,a,s,p (Chrome) |
✅ PASSED |
| H2 Akamai Settings | Mismatched | Browser-exact | Browser-exact | ✅ PASSED |
| Throughput (10 reqs) | ~520 ms/req | ~437 ms/req | ~296 ms/req (32% faster) | ⚡ FASTEST |
| Memory Safety | Python Managed | C Pointers (Manual) | Rust RAII (Safe) | 🛡️ SAFE |
🚀 Quick Start
Installation
pip install http-tls
Or build from source via Maturin:
git clone https://github.com/real-coder-xD/http_tls.git
cd http_tls
pip install maturin
maturin build --release
pip install ./target/wheels/*.whl
Mode 1: 100% Drop-in for requests
Simply swap your import. All existing code, sessions, headers, and exception handling work seamlessly:
import http_tls as requests
# GET request with automatic Chrome 152 impersonation
resp = requests.get("https://httpbin.org/get", timeout=10)
resp.raise_for_status()
# Standard requests properties
print(resp.status_code == requests.codes.ok) # True
print(resp.ok) # True
print(resp.headers["content-type"]) # Case-insensitive headers!
# Session with cookie persistence and custom headers
with requests.Session() as s:
s.headers.update({"Authorization": "Bearer secret_token"})
s.get("https://httpbin.org/cookies/set?user=dev")
r = s.get("https://httpbin.org/cookies")
print(r.json()["cookies"]) # {'user': 'dev'}
Mode 2: 100% Drop-in for curl_cffi
If your project currently imports curl_cffi:
from http_tls import requests
from http_tls import BrowserType
# Use BrowserType enum or string presets
resp = requests.get(
"https://www.upwork.com",
impersonate=BrowserType.chrome152,
proxies={"all": "http://user:pass@proxy.example.com:8080"}
)
print("Status:", resp.status_code)
print("CF-Ray:", resp.headers.get("cf-ray"))
Mode 3: Native High-Performance Async (asyncio)
Crawl hundreds of protected endpoints concurrently:
import asyncio
import http_tls
async def worker(session, index):
url = f"https://httpbin.org/anything?idx={index}"
resp = await session.get(url)
return resp.json()["args"]
async def main():
async with http_tls.AsyncSession(impersonate="chrome_152") as session:
tasks = [worker(session, i) for i in range(20)]
results = await asyncio.gather(*tasks)
print(f"Fetched {len(results)} items successfully!")
asyncio.run(main())
🎛️ Dual-Engine Architecture
http_tls gives you explicit control over the network engine:
import http_tls
# Engine 1: 'impersonate' (Default / Auto)
# 100% byte-exact TLS & H2 frames to bypass Cloudflare Bot Management & Akamai.
with http_tls.Session(impersonate="chrome_152", engine="impersonate") as s:
resp = s.get("https://www.upwork.com")
# Engine 2: 'rust'
# Pure Rust Tokio + Rustls runtime. Maximum memory safety and zero external C dependencies.
with http_tls.Session(impersonate="chrome_152", engine="rust") as s:
resp = s.get("https://httpbin.org/get")
Mode 5: Streaming Large Responses (stream=True)
Stream large payloads, downloads, and EventStreams directly from the socket without loading entire bodies into RAM:
import http_tls as requests
# Stream download chunk-by-chunk
with requests.get("https://httpbin.org/stream/20", stream=True) as resp:
for line in resp.iter_lines():
if line:
print("Received line:", line.decode("utf-8"))
# Custom chunk size
with requests.get("https://example.com/large-file.zip", stream=True) as resp:
with open("local_file.zip", "wb") as f:
for chunk in resp.iter_content(chunk_size=65536):
f.write(chunk)
Mode 6: Built-in Anti-Bot & JS Challenge Detection
Inspect whether an anti-bot system is challenging your request (resp.challenge returns the provider name or None):
import http_tls as requests
resp = requests.get("https://protected-site.com", impersonate="chrome_152")
if resp.challenge:
print(f"Intercepted by: {resp.challenge}")
# Detected providers: "cloudflare", "datadome", "ddos-guard", "imperva", "perimeterx", "sucuri"
else:
print("Normal response:", resp.status_code)
Mode 7: Custom CA Bundles & Client Certificates (mTLS)
import http_tls as requests
# Custom Root CA bundle (PEM)
session = requests.Session(verify="./custom_ca_bundle.pem")
# Client mTLS authentication
session = requests.Session(cert=("client.crt", "client.key"))
# Or combined PEM:
session = requests.Session(cert="client_combined.pem")
🎯 Supported Browser Presets (Updated to Nov 2026)
- Chrome (Default
chrome_152):chrome_152,chrome_152_macos,chrome_151,chrome_150,chrome_146,chrome_145,chrome_142,chrome_136,chrome_133,chrome_131,chrome_130,chrome_128,chrome_124 - Dynamic Generator: You can pass any
chrome_{N}version (e.g.chrome_135), andhttp_tlswill automatically calculate GREASE ciphers, Client Hints, and Sec-CH-UA. - Edge:
edge_152,edge_142,edge_131,edge_128,edge_124 - Safari:
safari_27,safari_26,safari_18_4,safari_18,safari_17 - Firefox:
firefox_155,firefox_154,firefox_153,firefox_147,firefox_144,firefox_135,firefox_133,firefox_130 - Tor:
tor_14_5
🛡️ Cloudflare & WAF Bypass Cheat Sheet
- Cloudflare CDN / Basic WAF: Passes automatically with 200 OK.
- Cloudflare Bot Management (Super Bot Fight Mode):
http_tlsmatches Chrome's JA4 and HTTP/2 settings, preventing 403 blocks. - Turnstile / Managed Challenge ("Just a moment..."):
- Recommended: Pair
http_tlswith clean Residential Proxies so Cloudflare skips the challenge. - Alternative: Solve Turnstile once via headless browser (
playwright/nodriver) and pass thecf_clearancecookie intohttp_tls.Session(cookies={"cf_clearance": "..."}).
- Recommended: Pair
🇻🇳 Xem hướng dẫn chi tiết bằng Tiếng Việt (Click để mở)
Hướng dẫn Tiếng Việt
http_tls là thư viện HTTP Client viết bằng Rust cho Python, thiết kế để thay thế hoàn hảo cho cả requests và curl_cffi:
- Thay thế
requests:import http_tls as requests resp = requests.get("https://httpbin.org/get") print(resp.json())
- Thay thế
curl_cffi:from http_tls import requests, BrowserType resp = requests.get("https://target.com", impersonate=BrowserType.chrome152)
- Tải file lớn tiết kiệm RAM (Streaming):
import http_tls as requests with requests.get("https://httpbin.org/stream/10", stream=True) as resp: for line in resp.iter_lines(): if line: print(line.decode("utf-8"))
- Tự động nhận diện rào chắn Anti-Bot:
import http_tls as requests resp = requests.get("https://target.com", impersonate="chrome_152") if resp.challenge: print("Bị chặn bởi:", resp.challenge) # 'cloudflare', 'datadome', 'ddos-guard'...
- Cào dữ liệu Async đa luồng:
import asyncio, http_tls async def main(): async with http_tls.AsyncSession(impersonate="chrome_152") as s: r = await s.get("https://httpbin.org/get") print(r.status_code) asyncio.run(main())
📄 License
Released under the MIT License.
Metadata
Release files for http-tls 0.3.0
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.3.0.tar.gz | 41.9 kB | With provenance | Details for http_tls-0.3.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| http_tls-0.3.0-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details for http_tls-0.3.0-cp38-abi3-win_amd64.whl |
| http_tls-0.3.0-cp38-abi3-manylinux_2_38_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.38+ x86-64 | Details for http_tls-0.3.0-cp38-abi3-manylinux_2_38_x86_64.whl |
| http_tls-0.3.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ ARM64 | Details for http_tls-0.3.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| http_tls-0.3.0-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details for http_tls-0.3.0-cp38-abi3-macosx_11_0_arm64.whl |
| http_tls-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl | CPython 3.8 | abi3 | macOS 10.12+ x86-64 | Details for http_tls-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl |
Total release size: 13.6 MB
Release files / http_tls-0.3.0.tar.gz
| Download URL | http_tls-0.3.0.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2645b075de34ea0acfa62c54cf205928364b139c501b8a671a3b8fc315ce8054
|
|
BLAKE2b-256 checksum How to use checksums |
678f9359890db83eec5ad8d440d5816c3864e115b00d5d8b178754731edd200a
|
| 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 17, 2026.
Transparency logRelease files / http_tls-0.3.0-cp38-abi3-win_amd64.whl
| Download URL | http_tls-0.3.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4aa0d6bf212c6c09b38325c1e75c6a2b0734b4056bdbc0d9a5b3421439172f27
|
|
BLAKE2b-256 checksum How to use checksums |
d89a5864a3e5666fd4634c7bcc0c423864bd6891692f1319d4084efd782a25a8
|
| 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 17, 2026.
Transparency logRelease files / http_tls-0.3.0-cp38-abi3-manylinux_2_38_x86_64.whl
| Download URL | http_tls-0.3.0-cp38-abi3-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 2.9 MB |
| Tags | CPython 3.8 Linux glibc 2.38+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
01961d9971937e50933301a6568270d51bb618012ef289fd13d204b2abe835bc
|
|
BLAKE2b-256 checksum How to use checksums |
5f8dcfdc51ee11acac0031ec624259607cea0b3d067ba58233c65d807a22d691
|
| 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 17, 2026.
Transparency logRelease files / http_tls-0.3.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | http_tls-0.3.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f1e20fc1ce9e5aec59a91c123343f53f60f13f9a4e819c59e0880f942064fe1c
|
|
BLAKE2b-256 checksum How to use checksums |
ab4100e71488d0407a1a044809b7e82ed45ce9cc4f533763f392d767bf3ac6ed
|
| 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 17, 2026.
Transparency logRelease files / http_tls-0.3.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | http_tls-0.3.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
986bc0c03bbcaf8e47692aeeddf6122e2542237e6e44204f6b736404d243b88c
|
|
BLAKE2b-256 checksum How to use checksums |
eb4dbeff02c3784d02de55acca86e702919fde708f26c8db9f75db76227c416b
|
| 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 17, 2026.
Transparency logRelease files / http_tls-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl
| Download URL | http_tls-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.8 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc9acdc2f979932a70bc727ffdef185aaa1a4357ba246b1a5b6569fd0caa6ae9
|
|
BLAKE2b-256 checksum How to use checksums |
f12b77891be39c492970ee45127379fd0438a543c863ffedd204819a5fb3413d
|
| 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 17, 2026.
Transparency logSecurity for http-tls 0.3.0
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.3.0.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 17, 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.