Skip to main content

⚡ http_tls

Standalone Rust + BoringSSL HTTP client with byte-exact TLS (JA3/JA4) & HTTP/2 fingerprint impersonation, native Tokio async, streaming, multipart uploads, and WebSockets.
100% Drop-in replacement for requests, httpx, and curl_cffi — zero external C runtime dependencies.

CI & Release Wheels License: MIT Python Rust Fingerprint

English • Tiếng Việt


🌟 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:

  1. 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).
  2. 100% Drop-in for requests: Replace import requests with import http_tls as requests — zero code changes required.
  3. 100% Drop-in for curl_cffi: Fully compatible with from http_tls import requests, BrowserType.
  4. Blazing Fast (+32% Throughput): Multi-threaded Rust core with complete Python GIL release (py.allow_threads).
  5. Modern 2026 Presets: Ships with presets up to Chrome 152, Safari 27, Firefox 155, and Edge 152, plus dynamic version generation.
  6. 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

🏆 Complete Feature Comparison Matrix

Feature http_tls (v0.6.0) curl_cffi primp / rnet tls-client httpx requests
Standalone BoringSSL TLS / JA4 ✅ 100+ Presets + Custom JA3/TLS ✅ ✅ ✅ (Go utls) ❌ ❌
True Native Async + Sync gather() ✅ Tokio Async & Sync Parallel Batch 🔶 (Async only) 🔶 ❌ 🔶 ❌
HTTP/2 & Exact Header Order ✅ Akamai H2 + header_order ✅ ✅ ✅ ✅ ❌
Triple API (requests+httpx+cffi) ✅ base_url, history, hooks 🔶 ❌ ❌ 🔶 🔶
Hickory DNS + resolve + IPv6 Bind ✅ Async Rust DNS + Socket Bind 🔶 🔶 ❌ ❌ ❌
Playwright storage_state + Solver ✅ load/save_storage_state + Bridge ❌ ❌ ❌ ❌ ❌
Wireshark keylog + HAR 1.2 Export ✅ keylog_file + export_har() ❌ ❌ ❌ ❌ ❌
TLS-Impersonated WebSockets ✅ Sync & Async (ws_connect) ✅ ✅ ❌ ❌ ❌
Streaming + Multipart + mTLS + Digest ✅ Full Native Rust + RFC 7616 ✅ 🔶 🔶 ✅ ✅
Auto-Retry + Proxy Pool + WAF Detector ✅ retries, proxies_pool, challenge 🔶 🔶 ❌ 🔶 🔶
No Memory Leaks ✅ Rust RAII (Zero GC Lag) ✅ ✅ ❌ ✅ ✅

🚀 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: 100% Drop-in for httpx

Use standard httpx conventions (Client, AsyncClient, follow_redirects, resp.is_success, resp.read()):

import http_tls as httpx

with httpx.Client(follow_redirects=True, impersonate="chrome_152") as client:
    resp = client.get("https://httpbin.org/get")
    print("Success:", resp.is_success)  # True
    print("Content bytes:", len(resp.read()))

# Async Client
import asyncio

async def fetch():
    async with httpx.AsyncClient(follow_redirects=True) as client:
        r = await client.get("https://httpbin.org/status/200")
        print("Async Status:", r.status_code, "| is_success:", r.is_success)

asyncio.run(fetch())

Mode 4: 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())

🎛️ Standalone Rust + BoringSSL Architecture

As of v0.4.0, http_tls embeds BoringSSL (btls) and custom HTTP/2 frame emulation directly inside its Rust core (wreq + wreq-util + Tokio). Installing pip install http-tls alone delivers 100% byte-exact Chrome/Safari/Firefox/Edge/Opera/OkHttp JA3/JA4 fingerprints without requiring curl_cffi.

import http_tls

# Default: Standalone Rust BoringSSL engine (byte-exact JA4 + H2, zero external deps)
with http_tls.Session(impersonate="chrome_149") as s:
    resp = s.get("https://tls.peet.ws/api/all")
    print(resp.http_version, resp.json()["tls"]["ja4"])

# Multipart file upload
with http_tls.Session() as s:
    r = s.post(
        "https://httpbin.org/post",
        data={"note": "hello"},
        files={"file": ("demo.txt", b"payload", "text/plain")},
    )

# TLS-Impersonated WebSocket (sync & async)
with http_tls.Session(impersonate="chrome_149") as s:
    with s.ws_connect("wss://echo.websocket.org") as ws:
        ws.send_text("hello over BoringSSL Chrome TLS")
        print(ws.recv_text())

# Custom JA3 / TLS options, exact header order, DNS origin override & IPv6 binding
with http_tls.Session(
    base_url="https://api.example.com",
    header_order=["Host", "User-Agent", "Accept", "Accept-Language"],
    ja3="771,4865-4866-4867-49195-49199,0-23-65281,29-23-24,0",
    resolve={"api.example.com": "1.2.3.4"},
    local_address="2001:db8::1",
    retries=3,
    retry_on_challenge=True,
    rotate_impersonate=True,
    proxies_pool=["http://p1:8080", "http://p2:8080"],
    auth=http_tls.DigestAuth("user", "pass"),
    tls_info=True,
) as s:
    r = s.get("/v1/status")
    print(r.remote_addr, len(r.history), bool(r.peer_certificate))

# Endgame v0.6.0: Parallel Tokio gather() for Sync code, Playwright storage_state, HAR 1.2 & Wireshark KeyLog
with http_tls.Session(
    impersonate="chrome_149",
    storage_state="playwright_state.json",  # optional: load cf_clearance + cookies + UA
    record_har=True,
    keylog_file="sslkeys.log",              # decrypt TLS traffic in Wireshark
) as s:
    # Fire 50 URLs in parallel on Rust Tokio from plain synchronous Python (no async/await needed!)
    responses = s.gather([f"https://httpbin.org/get?i={i}" for i in range(50)], concurrency=25)
    s.save_storage_state("playwright_state.json")
    s.export_har("session_trace.har")

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")

Unlike other libraries where clearing cookies leaves underlying session engine cookies intact, http_tls performs deep synchronization, wiping cookies from both Python memory and the native Rust/C core:

import http_tls as requests

session = requests.Session()
session.get("https://site.com/login")  # Sets session cookies

# Deep-clear: resets cookies across Python dict, libcurl, and Rust Tokio Jar
session.cookies.clear()  # or session.clear_cookies()

# Subsequent requests will be sent as a completely clean, anonymous session
resp = session.get("https://site.com/profile")

🎯 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), and http_tls will 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

  1. Cloudflare CDN / Basic WAF: Passes automatically with 200 OK.
  2. Cloudflare Bot Management (Super Bot Fight Mode): http_tls matches Chrome's JA4 and HTTP/2 settings, preventing 403 blocks.
  3. Turnstile / Managed Challenge ("Just a moment..."):
    • Recommended: Pair http_tls with clean Residential Proxies so Cloudflare skips the challenge.
    • Alternative: Solve Turnstile once via headless browser (playwright/nodriver) and pass the cf_clearance cookie into http_tls.Session(cookies={"cf_clearance": "..."}).

🇻🇳 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:

  1. Thay thế requests:
    import http_tls as requests
    resp = requests.get("https://httpbin.org/get")
    print(resp.json())
    
  2. Thay thế curl_cffi:
    from http_tls import requests, BrowserType
    resp = requests.get("https://target.com", impersonate=BrowserType.chrome152)
    
  3. Thay thế httpx (Hỗ trợ Async & Client):
    import http_tls as httpx
    with httpx.Client(follow_redirects=True) as client:
        resp = client.get("https://httpbin.org/get")
        print(resp.is_success, resp.status_code)
    
  4. 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"))
    
  5. 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'...
    
  6. Xóa sạch phiên và Cookie (Deep Clear):
    session = requests.Session()
    session.cookies.clear()  # Xóa sạch cả Python dict lẫn session ngầm của Rust và libcurl
    
  7. 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.6.1

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

Source distribution (sdist)

Source distribution for http-tls 0.6.1
File Size Uploaded Provenance Actions
http_tls-0.6.1.tar.gz 80.2 kB With provenance Details for http_tls-0.6.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for http-tls 0.6.1
File Actions
http_tls-0.6.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for http_tls-0.6.1-cp38-abi3-win_amd64.whl
http_tls-0.6.1-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details for http_tls-0.6.1-cp38-abi3-manylinux_2_28_x86_64.whl
http_tls-0.6.1-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details for http_tls-0.6.1-cp38-abi3-manylinux_2_28_aarch64.whl
http_tls-0.6.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for http_tls-0.6.1-cp38-abi3-macosx_11_0_arm64.whl
http_tls-0.6.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for http_tls-0.6.1-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 21.4 MB

Release files / http_tls-0.6.1.tar.gz

Download URL http_tls-0.6.1.tar.gz
Size 80.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0d2b8107c2ff9139d72a483915f4314fe045be9d4e1e3af64721a16b056a0334
BLAKE2b-256 checksum
How to use checksums
8c0b39f25ce44b190106aab36165ddc173b3603fa7c4dca4fde0bb2e4a2aa1c2
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 log

Release files / http_tls-0.6.1-cp38-abi3-win_amd64.whl

Download URL http_tls-0.6.1-cp38-abi3-win_amd64.whl
Size 4.5 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5b487bb81473dc083baf3f1e862b48645476c6a3d8b45cc121cf9a26c1eb78cc
BLAKE2b-256 checksum
How to use checksums
c833b30a06d11d7bc5f8558d7b4e8c1b7855ca22220643c4786502a00d2c6b55
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 log

Release files / http_tls-0.6.1-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL http_tls-0.6.1-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
e8f4e002fca016d6cd493f2dde119008c58b7b302eb02b2ee78aeb619b2ad985
BLAKE2b-256 checksum
How to use checksums
acbf5788b0e73ca001560385fa9b23d3d886fca5869ad64ca20aa34b433f1d9e
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 log

Release files / http_tls-0.6.1-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL http_tls-0.6.1-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
1d56046994210b3e33538a3a9a1c91b8edbffcec61f5a464f5db31e4471616d7
BLAKE2b-256 checksum
How to use checksums
7e2965ea9b655610dc2c64df209a6edfa24d6c59f73a4bd82b74b613cc09c294
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 log

Release files / http_tls-0.6.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL http_tls-0.6.1-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
bae5b846e2e592584cb9fa8b9cb2f1c8cf399d9eb4f842805167b765559ce334
BLAKE2b-256 checksum
How to use checksums
3d3c8485f76904245da3154e7e370cb9ad80a2d0f14cd8e3a78dfde50d8038bf
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 log

Release files / http_tls-0.6.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL http_tls-0.6.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 4.1 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
23971ed89bdb0a3c452a1ddf1d31a94acb78a4b59f0a65eb5507e0af22dff6b7
BLAKE2b-256 checksum
How to use checksums
286a5d7acb6525bf9791229d6189fdb6e98c8397a200992b88b0c2fd1daba096
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 log

Security for http-tls 0.6.1

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.

Select from 6 files

Attestation for http_tls-0.6.1.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 log

A 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.

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