Skip to main content

A Python HTTP client focused on mimicking browser fingerprints.

Reason this release was yanked:

release error on linux and macos

Project description

httpmorph

Build codecov PyPI version License: MIT

A Python HTTP client focused on mimicking browser fingerprints.

⚠️ Work in Progress - This library is in early development. Features and API may change.

Features

  • Requests-compatible API - Drop-in replacement for most Python requests use cases
  • High Performance - Native C implementation with BoringSSL for HTTP/HTTPS
  • HTTP/2 Support - Full HTTP/2 with ALPN negotiation via nghttp2 (httpx-like API)
  • Browser Fingerprinting - Realistic browser profiles (Chrome and it's variants)
  • TLS Fingerprinting - JA3 fingerprint generation and customization
  • Connection Pooling - Automatic connection reuse for better performance
  • Session Management - Persistent cookies and headers across requests

Installation

pip install httpmorph

Requirements

  • Python 3.8+
  • Windows, macOS, or Linux
  • BoringSSL (built automatically from source)
  • libnghttp2 (for HTTP/2)

Quick Start

import httpmorph

# Simple GET request
response = httpmorph.get('https://icanhazip.com')
print(response.status_code)
print(response.text)

# POST with JSON
response = httpmorph.post(
    'https://httpbin.org/post',
    json={'key': 'value'}
)

# Using sessions
session = httpmorph.Session(browser='chrome')
response = session.get('https://example.com')

# HTTP/2 support (httpx-like API)
client = httpmorph.Client(http2=True)
response = client.get('https://www.google.com')
print(response.http_version)  # '2.0'

Browser Profiles

Mimic real browser behavior with pre-configured profiles:

# Use Chrome fingerprint
response = httpmorph.get('https://example.com', browser='chrome')

# Use Firefox fingerprint
session = httpmorph.Session(browser='firefox')
response = session.get('https://example.com')

# Available browsers: chrome, firefox, safari, edge

Advanced Usage

HTTP/2 Support

httpmorph supports HTTP/2 with an httpx-like API:

# Enable HTTP/2 for a client (default is False)
client = httpmorph.Client(http2=True)
response = client.get('https://www.google.com')
print(response.http_version)  # '2.0'

# Enable HTTP/2 for a session
session = httpmorph.Session(browser='chrome', http2=True)
response = session.get('https://www.google.com')
print(response.http_version)  # '2.0'

# Per-request HTTP/2 override
client = httpmorph.Client(http2=False)  # Default disabled
response = client.get('https://www.google.com', http2=True)  # Enable for this request

Custom Headers

headers = {
    'User-Agent': 'MyApp/1.0',
    'Authorization': 'Bearer token123'
}
response = httpmorph.get('https://api.example.com', headers=headers)

File Uploads

files = {'file': ('report.pdf', open('report.pdf', 'rb'))}
response = httpmorph.post('https://httpbin.org/post', files=files)

Timeout Control

# Single timeout value
response = httpmorph.get('https://example.com', timeout=5)

# Separate connect and read timeouts
response = httpmorph.get('https://example.com', timeout=(3, 10))

SSL Verification

# Disable SSL verification (not recommended for production)
response = httpmorph.get('https://example.com', verify_ssl=False)

Authentication

# Basic authentication
response = httpmorph.get(
    'https://api.example.com',
    auth=('username', 'password')
)

Redirects

# Follow redirects (default behavior)
response = httpmorph.get('https://example.com/redirect')

# Don't follow redirects
response = httpmorph.get(
    'https://example.com/redirect',
    allow_redirects=False
)

# Check redirect history
print(len(response.history))  # Number of redirects

Sessions with Cookies

session = httpmorph.Session()

# Cookies persist across requests
session.get('https://example.com/login')
session.post('https://example.com/form', data={'key': 'value'})

# Access cookies
print(session.cookies)

API Compatibility

httpmorph aims for high compatibility with Python's requests library:

Feature Status
GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS Supported
JSON request/response Supported
Form data & file uploads Supported
Custom headers Supported
Authentication Supported
Cookies & sessions Supported
Redirects with history Supported
Timeout control Supported
SSL verification Supported
Streaming responses Supported
Exception hierarchy Supported

Response Object

response = httpmorph.get('https://httpbin.org/get')

# Status and headers
print(response.status_code)      # 200
print(response.ok)                # True
print(response.reason)            # 'OK'
print(response.headers)           # {'Content-Type': 'application/json', ...}

# Response body
print(response.text)              # Response as string
print(response.body)              # Response as bytes
print(response.json())            # Parse JSON response

# Request info
print(response.url)               # Final URL after redirects
print(response.history)           # List of redirect responses

# Timing
print(response.elapsed)           # Response time
print(response.total_time_us)     # Total time in microseconds

# TLS info
print(response.tls_version)       # TLS version used
print(response.tls_cipher)        # Cipher suite
print(response.ja3_fingerprint)   # JA3 fingerprint

Exception Handling

import httpmorph

try:
    response = httpmorph.get('https://example.com', timeout=5)
    response.raise_for_status()  # Raise exception for 4xx/5xx
except httpmorph.Timeout:
    print("Request timed out")
except httpmorph.ConnectionError:
    print("Failed to connect")
except httpmorph.HTTPError as e:
    print(f"HTTP error: {e.response.status_code}")
except httpmorph.RequestException as e:
    print(f"Request failed: {e}")

Performance

httpmorph is built for speed with a native C implementation and BoringSSL for optimized TLS operations.

Benchmark vs requests library (30-second test, macOS Apple Silicon):

  • Throughput: 49.4% faster on average (1,056 vs 707 req/s)
  • GET requests: 1,032 req/s vs 709 req/s (1.46x faster)
  • POST requests: 1,080 req/s vs 705 req/s (1.53x faster)
  • Latency: 33.1% lower on average (0.95ms vs 1.41ms)

See detailed benchmark results for full metrics including performance charts.

Performance Features

  • Native C implementation with minimal Python overhead
  • BoringSSL for optimized TLS operations
  • Connection pooling reduces handshake overhead
  • HTTP/2 multiplexing for concurrent requests
  • Efficient memory management

Platform Support

Platform Status
Windows ✅ Fully supported
macOS (Intel & Apple Silicon) ✅ Fully supported
Linux (x86_64, ARM64) ✅ Fully supported

All platforms use BoringSSL (Google's fork of OpenSSL) for consistent TLS behavior and advanced fingerprinting capabilities.

Building from Source

httpmorph uses BoringSSL (built from source) on all platforms for consistent TLS fingerprinting.

Prerequisites

Windows:

# Install build tools
choco install cmake golang nasm visualstudio2022buildtools -y

# Or install manually:
# - Visual Studio 2019+ (with C++ tools)
# - CMake 3.15+
# - Go 1.18+
# - NASM (for BoringSSL assembly optimizations)

macOS:

# Install dependencies
brew install cmake ninja libnghttp2

Linux:

# Ubuntu/Debian
sudo apt-get install cmake ninja-build libssl-dev pkg-config autoconf automake libtool

# Fedora/RHEL
sudo dnf install cmake ninja-build openssl-devel pkg-config autoconf automake libtool

Build Steps

# 1. Clone the repository
git clone https://github.com/arman-bd/httpmorph.git
cd httpmorph

# 2. Build vendor dependencies (BoringSSL, nghttp2, zlib)
./scripts/setup_vendors.sh  # On Windows: bash scripts/setup_vendors.sh

# 3. Build Python extensions
python setup.py build_ext --inplace

# 4. Install in development mode
pip install -e ".[dev]"

Note: The first build takes 5-10 minutes as it compiles BoringSSL from source. Subsequent builds are much faster (~30 seconds) as the vendor libraries are cached.

Development

# Clone and setup (includes building BoringSSL)
git clone https://github.com/arman-bd/httpmorph.git
cd httpmorph
./scripts/setup_vendors.sh

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=httpmorph --cov-report=html

# Run specific test markers
pytest tests/ -m "not slow"           # Skip slow tests
pytest tests/ -m "not proxy"          # Skip proxy tests (default in CI)
pytest tests/ -m proxy                # Only proxy tests
pytest tests/ -m integration          # Only integration tests
pytest tests/ -m fingerprint          # Only fingerprinting tests

Architecture

httpmorph combines the best of both worlds:

  • C Core: Low-level HTTP/TLS implementation for maximum performance
  • Python Wrapper: Clean, Pythonic API with requests compatibility
  • BoringSSL: Google's fork of OpenSSL, optimized and battle-tested
  • nghttp2: Standard-compliant HTTP/2 implementation

The library uses Cython to bridge Python and C, providing near-native performance with the ease of Python.

Contributing

Contributions are welcome! Areas where help is especially appreciated:

  • Windows compatibility
  • Additional browser profiles
  • Performance optimizations
  • Documentation improvements
  • Bug reports and fixes

Please open an issue or pull request on GitHub.

Testing

httpmorph has a comprehensive test suite with 270+ tests covering:

  • All HTTP methods and parameters
  • Redirect handling and history
  • Cookie and session management
  • Authentication and SSL
  • Error handling and timeouts
  • Unicode and encoding edge cases
  • Thread safety and memory management
  • Real-world integration tests

Run the test suite:

pytest tests/ -v

Acknowledgments

  • Built on BoringSSL (Google)
  • HTTP/2 support via nghttp2
  • Inspired by Python's requests library
  • Browser fingerprints based on real browser implementations

FAQ

Q: Why another HTTP client? A: httpmorph combines the performance of native C with browser fingerprinting capabilities, making it ideal for applications that need both speed and realistic browser behavior.

Q: Is it production-ready? A: No, httpmorph is still in active development and not yet recommended for production use.

Q: Can I use this as a drop-in replacement for requests? A: For most common use cases, yes! We've implemented the most widely-used requests API. Some advanced features may have slight differences.

Q: How do I report a bug? A: Please open an issue on GitHub with a minimal reproduction example and your environment details (OS, Python version, httpmorph version).

Support


httpmorph - Fast, compatible, and powerful HTTP for Python.

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.

httpmorph-0.2.0-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

httpmorph-0.2.0-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

httpmorph-0.2.0-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

httpmorph-0.2.0-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

httpmorph-0.2.0-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

httpmorph-0.2.0-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file httpmorph-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 20a80a1d76ce3e868e2436752bfc8204a601aa72e9e0ff258b4bfb32d6801de2
MD5 20194e3c39fce1ca9970030822f12fc6
BLAKE2b-256 fa61a6950b579f2c1c3d6057d0725685441a753cf982cac440f7b5860732d9f1

See more details on using hashes here.

File details

Details for the file httpmorph-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 691a85facb7165055290ff2bd304edee8cbc52904903b9c3f84eefa93ff924dc
MD5 52c9a10ee545b888eec883cea3cdb956
BLAKE2b-256 a8bf3f3db01ad2425a8cff599a829727503e52cdf46243e92b9837f28e0d96ba

See more details on using hashes here.

File details

Details for the file httpmorph-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7beaea090c9c8fc25641f5e39f85627d9e30b3062ad23969eab28fcb67145571
MD5 02582cfb68bd6ccd667bff518920f8de
BLAKE2b-256 cd283b26bd32c3eb3e54effa1e4076967b355295ae99ea4bfedab3a6cdbbc9d9

See more details on using hashes here.

File details

Details for the file httpmorph-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 657331efea6af9af30a2003c0003c65dbca65cb7e3d6dad4576df022bd073ee2
MD5 06a72c001a2e3dbc95e374b6488d8c6c
BLAKE2b-256 46d8aa833ff13aa9f6ad8892e9f78922aa4f45d0aec3f7629f15bae1c58a43ac

See more details on using hashes here.

File details

Details for the file httpmorph-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5cc2a329dc9aa3bf6736eccf8fcd39f33e7d7ff376c1ff8c324999c1dd769350
MD5 37459cd6770187674a2d74214782d3f9
BLAKE2b-256 1711c20bad6bf7ef7323ff6bcef853e1b8703870d585b567ca2d027ba109e59b

See more details on using hashes here.

File details

Details for the file httpmorph-0.2.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: httpmorph-0.2.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for httpmorph-0.2.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5c2a2fc878c0305e2460da9e7f9ec70f72f25ef30c2dbd089e8e6263e09e32e8
MD5 d73c64815deaddf106383447651887fc
BLAKE2b-256 f91138048ad406025ac747a699232755e315f772adee5340a948b12c261eabff

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