Skip to main content

Browser fingerprint emulation HTTP client with HTTP/1.1, HTTP/2, and HTTP/3 support

Project description

HTTPCloak Python

Browser fingerprint emulation HTTP client with HTTP/1.1, HTTP/2, and HTTP/3 support.

Installation

pip install httpcloak

Quick Start

Synchronous Usage

from httpcloak import Session

# Create a session with Chrome fingerprint
session = Session(preset="chrome-143")

# Make requests
response = session.get("https://www.cloudflare.com/cdn-cgi/trace")
print(response.status_code)
print(response.text)

# POST request
response = session.post("https://api.example.com/data", body={"key": "value"})

# Custom headers
response = session.get("https://example.com", headers={"X-Custom": "value"})

# With proxy
session = Session(preset="chrome-143", proxy="http://user:pass@host:port")

Asynchronous Usage

import asyncio
from httpcloak import Session

async def main():
    session = Session(preset="chrome-143")

    # Async GET
    response = await session.get_async("https://example.com")
    print(response.text)

    # Async POST
    response = await session.post_async("https://api.example.com/data", body={"key": "value"})

    # Multiple concurrent requests
    responses = await asyncio.gather(
        session.get_async("https://example.com/1"),
        session.get_async("https://example.com/2"),
        session.get_async("https://example.com/3"),
    )

asyncio.run(main())

Cookie Management

from httpcloak import Session

session = Session()

# Get all cookies
cookies = session.get_cookies()
print(cookies)

# Set a cookie
session.set_cookie("session_id", "abc123")

# Access cookies as property
print(session.cookies)

Available Presets

from httpcloak import available_presets

print(available_presets())
# ['chrome-143', 'chrome-143-windows', 'chrome-143-linux', 'chrome-143-macos',
#  'chrome-131', 'firefox-133', 'safari-18', ...]

Response Object

response = session.get("https://example.com")

response.status_code  # int: HTTP status code
response.headers      # dict: Response headers
response.body         # bytes: Raw response body
response.text         # str: Response body as text
response.final_url    # str: Final URL after redirects
response.protocol     # str: Protocol used (http/1.1, h2, h3)

Error Handling

from httpcloak import Session, HTTPCloakError

try:
    session = Session()
    response = session.get("https://example.com")
except HTTPCloakError as e:
    print(f"Request failed: {e}")

Context Manager

from httpcloak import Session

with Session(preset="chrome-143") as session:
    response = session.get("https://example.com")
    print(response.text)
# Session automatically closed

Proxy Support

HTTPCloak supports HTTP, SOCKS5, and HTTP/3 (MASQUE) proxies with full fingerprint preservation.

HTTP Proxy

from httpcloak import Session

# Basic HTTP proxy
session = Session(preset="chrome-143", proxy="http://host:port")

# With authentication
session = Session(preset="chrome-143", proxy="http://user:pass@host:port")

# HTTPS proxy
session = Session(preset="chrome-143", proxy="https://user:pass@host:port")

SOCKS5 Proxy

from httpcloak import Session

# SOCKS5 proxy (with DNS resolution on proxy)
session = Session(preset="chrome-143", proxy="socks5h://host:port")

# With authentication
session = Session(preset="chrome-143", proxy="socks5h://user:pass@host:port")

response = session.get("https://www.cloudflare.com/cdn-cgi/trace")
print(response.protocol)  # h3 (HTTP/3 through SOCKS5!)

HTTP/3 MASQUE Proxy

MASQUE (RFC 9484) enables HTTP/3 connections through compatible proxies:

from httpcloak import Session

# MASQUE proxy (auto-detected for known providers like Bright Data)
session = Session(preset="chrome-143", proxy="https://user:pass@brd.superproxy.io:10001")

response = session.get("https://www.cloudflare.com/cdn-cgi/trace")
print(response.protocol)  # h3

Advanced Features

Encrypted Client Hello (ECH)

ECH encrypts the SNI (Server Name Indication) to prevent traffic analysis. Works with all Cloudflare domains:

from httpcloak import Session

# Enable ECH for Cloudflare domains
session = Session(preset="chrome-143", ech_config_domain="cloudflare-ech.com")

response = session.get("https://www.cloudflare.com/cdn-cgi/trace")
print(response.text)
# Output includes: sni=encrypted, http=http/3

Domain Fronting (Connect-To)

Connect to one server while requesting a different domain:

from httpcloak import Session

# Connect to claude.ai's IP but request www.cloudflare.com
session = Session(
    preset="chrome-143",
    connect_to={"www.cloudflare.com": "claude.ai"}
)

response = session.get("https://www.cloudflare.com/cdn-cgi/trace")

Combined: SOCKS5 + ECH

Get HTTP/3 with encrypted SNI through a SOCKS5 proxy:

from httpcloak import Session

session = Session(
    preset="chrome-143",
    proxy="socks5h://user:pass@host:port",
    ech_config_domain="cloudflare-ech.com"
)

response = session.get("https://www.cloudflare.com/cdn-cgi/trace")
# Response shows: http=http/3, sni=encrypted

Platform Support

  • Linux (x64, arm64)
  • macOS (x64, arm64)
  • Windows (x64, arm64)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

httpcloak-1.5.2-py3-none-win_amd64.whl (4.1 MB view details)

Uploaded Python 3Windows x86-64

httpcloak-1.5.2-py3-none-manylinux_2_17_x86_64.whl (4.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

httpcloak-1.5.2-py3-none-manylinux_2_17_aarch64.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

httpcloak-1.5.2-py3-none-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

httpcloak-1.5.2-py3-none-macosx_10_9_x86_64.whl (4.1 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file httpcloak-1.5.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: httpcloak-1.5.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for httpcloak-1.5.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a006c3b974ed2cecaf4aa559c4837601d01c02cb1868c0a588226a905d08a7a6
MD5 a193cd87376ca4bcc3cc0054bbdce748
BLAKE2b-256 674c435c066dbfb2460c15919f498a4d43e70a461fbe0def05f65c95369fc62d

See more details on using hashes here.

File details

Details for the file httpcloak-1.5.2-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for httpcloak-1.5.2-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 85ea35d4a31436316ce355555851427266d5d6d251b362b4911a6c3b4779fab3
MD5 1bf5bed285f92942fdb095b9e218a539
BLAKE2b-256 fc0a959cfa8309f8330eced4b35fd0d9f0bed8032d071c35668d2a1fb81a816c

See more details on using hashes here.

File details

Details for the file httpcloak-1.5.2-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for httpcloak-1.5.2-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 4cd89a6ce79bb691af1c60a26a1a9f40da860d3f7c731c5c241c23d51b594cb6
MD5 86a3dde4acc6fa463b4b69904ce8efb5
BLAKE2b-256 d55ffd6f98e35315997757d943b669c7f7b905e11be1862334c03cba0fc0f980

See more details on using hashes here.

File details

Details for the file httpcloak-1.5.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for httpcloak-1.5.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5051bf6b8697dbe5f50d2d97ab433016ac7d63c0c89db87a426ac9e78410215
MD5 b382b7ff841b787cfc062d0eab492ac1
BLAKE2b-256 70cc229fed34bf974ec6aa9c45069078d1f4bbdf5fadc46425a12fe75ed14645

See more details on using hashes here.

File details

Details for the file httpcloak-1.5.2-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for httpcloak-1.5.2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ad41a24a769ca8fd924e1b9be20ae74349f6fa6ef577861b35273edda312495a
MD5 73e93452f1374eb353c3a8ba85970935
BLAKE2b-256 c5051202044d09f6a760e0b7ba8a50aec9a5d7063af995e4a738b72863a90695

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page