{"id":36234353,"url":"https://github.com/longcipher/hpx","last_synced_at":"2026-02-21T19:12:52.664Z","repository":{"id":331286442,"uuid":"1126047543","full_name":"longcipher/hpx","owner":"longcipher","description":"A high-performance HTTP client with tower middleware support","archived":false,"fork":false,"pushed_at":"2026-02-08T22:58:37.000Z","size":1307,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-09T04:27:28.017Z","etag":null,"topics":["boringssl","browser","browser-emulation","emulation","fastwebsockets","hft","high-performance","hpx","http","middleware","reqwest","rustls","tower","tower-http","tower-middleware","wreq"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/longcipher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-01T00:42:06.000Z","updated_at":"2026-02-08T22:40:11.000Z","dependencies_parsed_at":"2026-01-06T03:05:17.479Z","dependency_job_id":null,"html_url":"https://github.com/longcipher/hpx","commit_stats":null,"previous_names":["longcipher/hpx"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/longcipher/hpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Fhpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Fhpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Fhpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Fhpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/longcipher","download_url":"https://codeload.github.com/longcipher/hpx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Fhpx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29428830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boringssl","browser","browser-emulation","emulation","fastwebsockets","hft","high-performance","hpx","http","middleware","reqwest","rustls","tower","tower-http","tower-middleware","wreq"],"created_at":"2026-01-11T05:56:14.373Z","updated_at":"2026-02-21T19:12:52.655Z","avatar_url":"https://github.com/longcipher.png","language":"Rust","readme":"# hpx\n\n[![DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/longcipher/hpx)\n[![Context7](https://img.shields.io/badge/Website-context7.com-blue)](https://context7.com/longcipher/hpx)\n[![crates.io](https://img.shields.io/crates/v/hpx.svg)](https://crates.io/crates/hpx)\n[![docs.rs](https://docs.rs/hpx/badge.svg)](https://docs.rs/hpx)\n\n![hpx](https://socialify.git.ci/longcipher/hpx/image?font=Source+Code+Pro\u0026language=1\u0026name=1\u0026owner=1\u0026pattern=Circuit+Board\u0026theme=Auto)\n\nThis project is a fork of [wreq](https://github.com/0x676e67/wreq) and indirectly [reqwest](https://github.com/seanmonstar/reqwest), designed for the network layer of crypto exchange HFT high-performance applications. The primary goal of this fork is performance optimization.\n\nAn ergonomic all-in-one HTTP client for browser emulation with TLS, JA3/JA4, and HTTP/2 fingerprints.\n\n## Version\n\n| Crate | Version | Description |\n|-------|---------|-------------|\n| [`hpx`](https://crates.io/crates/hpx) | 2.2.0 | High Performance HTTP Client |\n| [`hpx-emulation`](https://crates.io/crates/hpx-emulation) | 2.2.0 | Browser emulation profiles |\n| [`hpx-transport`](https://crates.io/crates/hpx-transport) | 2.2.0 | Exchange SDK toolkit (auth, WebSocket, rate limiting) |\n| [`hpx-yawc`](https://crates.io/crates/hpx-yawc) | 2.2.0 | WebSocket library (RFC 6455 + compression) |\n| [`hpx-fastwebsockets`](https://crates.io/crates/hpx-fastwebsockets) | 2.2.0 | Fast minimal WebSocket implementation |\n\n## Features\n\n- **Browser Emulation**: Simulate various browser TLS/HTTP2 fingerprints (JA3/JA4)\n- **Content Handling**: Plain bodies, JSON, urlencoded, multipart, streaming\n- **Advanced Features**:\n  - Cookies Store\n  - Redirect Policy\n  - Original Header Preservation\n  - Rotating Proxies\n  - Certificate Store\n  - Tower Middleware Support\n  - Request/Response Hooks\n  - Retry Configuration\n  - Compression (gzip, brotli, deflate, zstd)\n  - Character Encoding Support\n- **WebSocket**: Upgrade support with switchable backends (yawc or fastwebsockets)\n- **TLS Backends**: BoringSSL (default) and Rustls\n\n## Architecture\n\n```text\n+-----------------------------------------------------------+\n|                        User API                           |\n| (Client, ClientBuilder, RequestBuilder, Response)         |\n+-----------------------------------------------------------+\n|                     Tower Middleware Stack                 |\n| (HooksLayer, RetryLayer, TimeoutLayer, DecompressionLayer)|\n+---------------------------+-------------------------------+\n|        hpx-core           |   hpx-ws (yawc/fastws)       |\n+---------------------------+                               |\n|      Connection Pool      |      WebSocket Handshake      |\n+-------------+-------------+-------------------------------+\n| TLS Backend | (Feature Switched: BoringSSL / Rustls)      |\n+-------------+---------------------------------------------+\n|                Transport (Tokio TCP Stream)                |\n+-----------------------------------------------------------+\n```\n\n## Installation\n\nAdd `hpx` to your `Cargo.toml`:\n\n```toml\n[dependencies]\nhpx = \"2.2.0\"\n```\n\nThe default features include **BoringSSL** TLS, **HTTP/1.1**, and **HTTP/2** support.\n\nFor browser emulation, add the utility crate:\n\n```toml\n[dependencies]\nhpx = \"2.2.0\"\nhpx-emulation = \"2.2.0\"\n```\n\nFor exchange/trading applications:\n\n```toml\n[dependencies]\nhpx = \"2.2.0\"\nhpx-transport = \"2.2.0\"\n```\n\n## Feature Flags\n\n### `hpx` Features\n\nThe `hpx` crate uses feature flags for fine-grained control. **Default features: `boring`, `http1`, `http2`**.\n\n| Feature | Default | Description |\n|---------|---------|-------------|\n| **TLS** | | |\n| `boring` | **Yes** | BoringSSL TLS backend |\n| `rustls-tls` | No | Rustls TLS backend (pure Rust) |\n| `webpki-roots` | No | WebPKI root certificates |\n| **HTTP** | | |\n| `http1` | **Yes** | HTTP/1.1 support |\n| `http2` | **Yes** | HTTP/2 support |\n| **Content** | | |\n| `json` | No | JSON request/response support |\n| `simd-json` | No | SIMD-accelerated JSON (enables `json`) |\n| `form` | No | x-www-form-urlencoded support |\n| `query` | No | URL query string serialization |\n| `multipart` | No | Multipart form data |\n| `stream` | No | Streaming request/response bodies |\n| `charset` | No | Character encoding support |\n| **Compression** | | |\n| `gzip` | No | Gzip decompression |\n| `brotli` | No | Brotli decompression |\n| `zstd` | No | Zstandard decompression |\n| `deflate` | No | Deflate decompression |\n| **WebSocket** | | |\n| `ws` | No | WebSocket support (alias for `ws-yawc`) |\n| `ws-yawc` | No | WebSocket via hpx-yawc backend |\n| `ws-fastwebsockets` | No | WebSocket via fastwebsockets backend |\n| **Networking** | | |\n| `cookies` | No | Cookie store support |\n| `socks` | No | SOCKS proxy support |\n| `hickory-dns` | No | Async DNS resolver (Hickory) |\n| `system-proxy` | No | System proxy configuration |\n| **Observability** | | |\n| `tracing` | No | Tracing/logging support |\n| **Other** | | |\n| `macros` | No | Tokio macros re-export |\n\n### WebSocket Backend Selection\n\nThe `ws` feature is an alias for `ws-yawc` (the default WebSocket backend). To use fastwebsockets instead:\n\n```toml\n[dependencies]\nhpx = { version = \"2.2.0\", features = [\"ws-fastwebsockets\"] }\n```\n\nWhen both `ws-yawc` and `ws-fastwebsockets` are enabled, fastwebsockets takes priority.\n\n### Common Feature Combinations\n\n**Minimal HTTP client:**\n\n```toml\nhpx = \"2.2.0\"  # default: boring + http1 + http2\n```\n\n**JSON API client:**\n\n```toml\nhpx = { version = \"2.2.0\", features = [\"json\", \"cookies\", \"gzip\"] }\n```\n\n**WebSocket client:**\n\n```toml\nhpx = { version = \"2.2.0\", features = [\"ws\"] }\n```\n\n**High-performance trading:**\n\n```toml\nhpx = { version = \"2.2.0\", features = [\"simd-json\", \"hickory-dns\", \"zstd\", \"ws\"] }\n```\n\n**Pure Rust (no C dependencies):**\n\n```toml\nhpx = { version = \"2.2.0\", default-features = false, features = [\"rustls-tls\", \"http1\", \"http2\"] }\n```\n\n**Full-featured:**\n\n```toml\nhpx = { version = \"2.2.0\", features = [\n    \"json\", \"form\", \"query\", \"multipart\", \"stream\",\n    \"cookies\", \"charset\",\n    \"gzip\", \"brotli\", \"zstd\", \"deflate\",\n    \"ws\", \"socks\", \"hickory-dns\",\n    \"tracing\",\n] }\n```\n\n### `hpx-emulation` Features\n\nDefault: `emulation`.\n\n| Feature | Default | Description |\n|---------|---------|-------------|\n| `emulation` | **Yes** | Browser emulation profiles (Chrome, Firefox, Safari, Opera, OkHttp) |\n| `emulation-compression` | No | Compression settings for emulation profiles |\n| `emulation-rand` | No | Random emulation profile selection |\n| `emulation-serde` | No | Serde serialization for emulation types |\n\n### `hpx-transport` Features\n\nDefault: `boring`, `ws-yawc`.\n\n| Feature | Default | Description |\n|---------|---------|-------------|\n| `boring` | **Yes** | TLS via BoringSSL |\n| `rustls` | No | TLS via Rustls |\n| `ws-yawc` | **Yes** | WebSocket backend via hpx-yawc |\n| `ws-fastwebsockets` | No | WebSocket backend via fastwebsockets |\n| `metrics` | No | OpenTelemetry OTLP gRPC metrics |\n| `sse` | No | Server-Sent Events transport |\n\n### `hpx-yawc` Features\n\nDefault: `rustls-ring`.\n\n| Feature | Default | Description |\n|---------|---------|-------------|\n| `rustls-ring` | **Yes** | TLS via rustls with ring crypto |\n| `rustls-aws-lc-rs` | No | TLS via rustls with AWS LC crypto |\n| `axum` | No | Axum WebSocket extractor |\n| `simd` | No | SIMD-accelerated UTF-8 validation |\n| `smol` | No | smol async runtime support |\n| `zlib` | No | Native zlib compression backend |\n\n## TLS Backend Configuration\n\n### BoringSSL (Default)\n\nBoringSSL is the default TLS backend, providing robust support for modern TLS features and extensive browser emulation capabilities. Recommended for most use cases, especially when browser fingerprinting is required.\n\n```toml\n[dependencies]\nhpx = \"2.2.0\"\n```\n\n### Rustls\n\nA pure Rust TLS implementation. Useful for environments where C dependencies are difficult to manage or when you prefer the safety guarantees of a pure Rust stack.\n\n\u003e **Note:** Switching to Rustls may affect the availability or behavior of certain browser emulation features that rely on specific BoringSSL capabilities.\n\n```toml\n[dependencies]\nhpx = { version = \"2.2.0\", default-features = false, features = [\"rustls-tls\", \"http1\", \"http2\"] }\n```\n\n## Usage Examples\n\n### Making a GET Request\n\n```rust\n#[tokio::main]\nasync fn main() -\u003e hpx::Result\u003c()\u003e {\n    let body = hpx::get(\"https://www.rust-lang.org\")\n        .send()\n        .await?\n        .text()\n        .await?;\n\n    println!(\"body = {body:?}\");\n    Ok(())\n}\n```\n\n### JSON Requests\n\nRequires the `json` feature.\n\n```rust\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize, Debug)]\nstruct User {\n    name: String,\n    email: String,\n}\n\n#[tokio::main]\nasync fn main() -\u003e hpx::Result\u003c()\u003e {\n    let user = User {\n        name: \"John Doe\".to_string(),\n        email: \"john@example.com\".to_string(),\n    };\n\n    let response = hpx::Client::new()\n        .post(\"https://jsonplaceholder.typicode.com/users\")\n        .json(\u0026user)\n        .send()\n        .await?;\n\n    println!(\"Status: {}\", response.status());\n    Ok(())\n}\n```\n\n### Browser Emulation\n\nRequires the `hpx-emulation` crate with default features.\n\n```rust\nuse hpx_emulation::Emulation;\n\n#[tokio::main]\nasync fn main() -\u003e hpx::Result\u003c()\u003e {\n    let resp = hpx::get(\"https://tls.peet.ws/api/all\")\n        .emulation(Emulation::Firefox136)\n        .send()\n        .await?;\n\n    println!(\"{}\", resp.text().await?);\n    Ok(())\n}\n```\n\n### WebSocket\n\nRequires the `ws` feature.\n\n```rust\nuse futures_util::{SinkExt, StreamExt, TryStreamExt};\nuse hpx::{header, ws::message::Message};\n\n#[tokio::main]\nasync fn main() -\u003e hpx::Result\u003c()\u003e {\n    let websocket = hpx::websocket(\"wss://echo.websocket.org\")\n        .header(header::USER_AGENT, env!(\"CARGO_PKG_NAME\"))\n        .send()\n        .await?;\n\n    let (mut tx, mut rx) = websocket.into_websocket().await?.split();\n\n    tokio::spawn(async move {\n        if let Err(err) = tx.send(Message::text(\"Hello, World!\")).await {\n            eprintln!(\"failed to send message: {err}\");\n        }\n    });\n\n    while let Some(message) = rx.try_next().await? {\n        if let Message::Text(text) = message {\n            println!(\"received: {text}\");\n        }\n    }\n\n    Ok(())\n}\n```\n\n### Cookies\n\nRequires the `cookies` feature.\n\n```rust\nuse hpx::cookie::Jar;\n\n#[tokio::main]\nasync fn main() -\u003e hpx::Result\u003c()\u003e {\n    let jar = Jar::default();\n\n    let client = hpx::Client::builder()\n        .cookie_provider(jar.clone())\n        .build()?;\n\n    let _resp = client\n        .get(\"https://httpbin.org/cookies/set/session/123\")\n        .send()\n        .await?;\n\n    println!(\"Cookies: {:?}\", jar.cookies(\"https://httpbin.org\"));\n    Ok(())\n}\n```\n\n### Transport Layer (Exchange SDK)\n\nFor cryptocurrency exchange integrations, use the `hpx-transport` crate:\n\n```rust\nuse hpx_transport::{\n    auth::ApiKeyAuth,\n    exchange::{RestClient, RestConfig},\n};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let config = RestConfig::new(\"https://api.example.com\")\n        .timeout(std::time::Duration::from_secs(30));\n\n    let auth = ApiKeyAuth::header(\"X-API-Key\", \"my-api-key\");\n    let client = RestClient::new(config, auth)?;\n\n    // Use the client...\n    Ok(())\n}\n```\n\n## Performance Optimization Tips\n\n- **`simd-json`**: Replaces `serde_json` with SIMD-accelerated JSON parsing\n- **`hickory-dns`**: High-performance async DNS resolver, avoids blocking system calls\n- **`zstd`**: Fastest compression/decompression ratio for most workloads\n- **Lock-free internals**: Uses `scc` concurrent containers and `arc-swap` for hot-path data\n\n## License\n\nApache-2.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongcipher%2Fhpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flongcipher%2Fhpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongcipher%2Fhpx/lists"}