hpx 2.4.21

High Performance HTTP Client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
[package]
name = "hpx"
version.workspace = true
description = "High Performance HTTP Client"
keywords = ["http", "client", "websocket", "exchange", "crypto"]
categories = ["web-programming::http-client"]
repository = "https://github.com/longcipher/hpx"
authors = ["Akagi201 <akagi201@gmail.com>"]
license.workspace = true
edition.workspace = true
include = [
    "README.md",
    "LICENSE",
    "src/**/*.rs",
    "examples/**/*.rs",
    "tests/**/*.rs",
]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu"]

[features]
default = ["boring", "http1", "http2", "stream", "tracing"]

# Enable support for decoding text.
charset = ["dep:encoding_rs", "dep:mime"]

# Enable authentication middleware with bearer token, API key, and OAuth2 support.
auth = ["dep:async-trait"]

# Enable cookies store support.
cookies = ["dep:cookie", "dep:arc-swap"]

# Enable gzip compression support.
gzip = ["tower-http/decompression-gzip"]

# Enable Brotli compression support.
brotli = ["tower-http/decompression-br"]

# Enable Zstandard compression support.
zstd = ["tower-http/decompression-zstd"]

# Enable deflate compression support.
deflate = ["tower-http/decompression-deflate"]

# Enable URL query string serialization support.
query = ["dep:serde", "dep:serde_urlencoded"]

# Enable x-www-form-urlencoded form support.
form = ["dep:serde", "dep:serde_urlencoded"]

# Enable JSON support.
json = ["dep:serde", "dep:serde_json"]

# Enable SIMD-accelerated JSON support (requires json feature).
simd-json = ["json", "dep:simd-json"]

# Enable multipart/form-data support.
multipart = ["dep:mime_guess", "dep:sync_wrapper"]

# Enable hickory DNS resolver.
hickory-dns = ["dep:hickory-resolver"]

# Enable streaming support.
stream = ["tokio/fs", "dep:tokio-util", "dep:sync_wrapper"]

# Enable SOCKS proxy support.
socks = ["dep:tokio-socks", "hpx-yawc/socks"]

# Enable WebSocket support (defaults to yawc backend).
ws = ["ws-yawc"]

# Enable WebSocket support via yawc backend.
ws-yawc = ["dep:hpx-yawc", "hpx-yawc/proxy"]

# Enable webpki-roots for TLS certificate validation.
webpki-roots = ["dep:webpki-root-certs"]

# Use the system's proxy configuration.
system-proxy = ["dep:system-configuration", "dep:windows-registry"]

# Enable tracing logging.
tracing = ["http2/tracing", "dep:tracing"]

# Enable hotpath profiling instrumentation.
hotpath = ["dep:hotpath"]

# Enable BoringSSL support.
boring = [
    "dep:boring",
    "dep:tokio-boring",
    "dep:brotli",
    "dep:flate2",
]

# Enable Rustls support.
rustls-tls = [
    "dep:rustls",
    "dep:tokio-rustls",
    "dep:rustls-pki-types",
    "dep:webpki-roots",
    "dep:rustls-pemfile",
    "dep:const-oid",
    "dep:der",
    "dep:hmac",
    "dep:pkcs12",
    "dep:pkcs8",
    "dep:sha1",
    "dep:sha2",
]

# Enable HTTP/1 support.
http1 = ["dep:httparse", "dep:smallvec", "tracing", "stream"]

# Enable HTTP/2 support.
http2 = ["dep:http2"]

# Enable macros.
macros = ["tokio/macros"]

# Preset for low-latency HTTP/WebSocket clients. This enables the common
# compile-time pieces used by HFT-style clients without requiring users to
# remember every feature flag.
hft = [
    "auth",
    "boring",
    "hickory-dns",
    "http1",
    "http2",
    "simd-json",
    "stream",
    "tracing",
    "ws-yawc",
    "zstd",
]

# Preset for browser-like clients. Runtime fingerprints still come from
# ClientBuilder::emulation(...) or RequestBuilder::emulation(...), while this
# feature enables the compile-time support usually paired with that profile.
stealth = [
    "auth",
    "boring",
    "brotli",
    "charset",
    "cookies",
    "deflate",
    "gzip",
    "hickory-dns",
    "http1",
    "http2",
    "query",
    "stream",
    "tracing",
    "ws-yawc",
    "zstd",
]

[dependencies]
ahash = { workspace = true }
arc-swap = { workspace = true, optional = true }
async-trait = { workspace = true, optional = true }
boring = { workspace = true, optional = true }
brotli = { workspace = true, optional = true }
bytes = { workspace = true }
const-oid = { workspace = true, features = ["db"], optional = true }
der = { workspace = true, features = ["alloc", "oid"], optional = true }
flate2 = { workspace = true, optional = true }
futures-channel = { workspace = true }
futures-util = { workspace = true }
hmac = { workspace = true, optional = true }
http = { workspace = true }
http-body = { workspace = true }
http-body-util = { workspace = true }
http2 = { workspace = true, features = ["unstable"], optional = true }
httparse = { workspace = true, optional = true }
ipnet = { workspace = true }
parking_lot = { workspace = true }
percent-encoding = { workspace = true }
pin-project-lite = { workspace = true }
pkcs12 = { workspace = true, features = ["kdf"], optional = true }
pkcs8 = { workspace = true, features = [
    "3des",
    "sha1-insecure",
], optional = true }
rand.workspace = true
rustls = { workspace = true, optional = true, features = [
    "std",
    "tls12",
    "ring",
] }
rustls-pemfile = { workspace = true, optional = true }
rustls-pki-types = { workspace = true, optional = true }
scc = { workspace = true }
schnellru = { workspace = true }
smallvec = { workspace = true, features = [
    "const_generics",
    "const_new",
], optional = true }
socket2 = { workspace = true, features = ["all"] }
tokio = { workspace = true, features = [
    "net",
    "time",
    "rt",
    "io-util",
    "sync",
] }
tokio-boring = { workspace = true, optional = true }
tokio-rustls = { workspace = true, optional = true, features = ["ring"] }
tower = { workspace = true, features = ["timeout", "util", "retry"] }
url = { workspace = true }
want = { workspace = true }
webpki-roots = { workspace = true, optional = true }

# Optional deps...

## serde
serde = { workspace = true, features = ["derive"], optional = true }
serde_json = { workspace = true, optional = true }
serde_urlencoded = { workspace = true, optional = true }
simd-json = { workspace = true, optional = true }

## multipart
mime_guess = { workspace = true, optional = true }

## charset
encoding_rs = { workspace = true, optional = true }
mime = { workspace = true, optional = true }

## sync wrapper
sync_wrapper = { workspace = true, features = ["futures"], optional = true }

## webpki root certs
webpki-root-certs = { workspace = true, optional = true }

## cookies
cookie = { workspace = true, optional = true }

## tower http
tower-http = { workspace = true, optional = true }

## tokio util
tokio-util = { workspace = true, features = ["io"], optional = true }

## socks
tokio-socks = { workspace = true, optional = true }

## websocket
hpx-yawc = { workspace = true, optional = true }

## hickory-dns
hickory-resolver = { workspace = true, optional = true }

## hotpath
hotpath = { workspace = true, optional = true }

## tracing
base64 = { workspace = true }
sha1 = { workspace = true, optional = true }
sha2 = { workspace = true, optional = true }
tracing = { workspace = true, features = ["std"], optional = true }

## windows system proxy
[target.'cfg(windows)'.dependencies]
windows-registry = { workspace = true, optional = true }

## macOS system proxy
[target.'cfg(target_os = "macos")'.dependencies]
system-configuration = { workspace = true, optional = true }

## interface binding
[target.'cfg(unix)'.dependencies]
libc = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
futures = { workspace = true, features = ["std"] }
hyper = { workspace = true, features = ["http1", "http2", "server"] }
hyper-util = { workspace = true, features = [
    "http1",
    "http2",
    "server-auto",
    "server-graceful",
    "tokio",
] }
pretty_env_logger = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tokio-test = { workspace = true }
tower = { workspace = true, features = ["limit"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
zstd = { workspace = true }

[[test]]
name = "cookie"
path = "tests/cookie.rs"
required-features = ["cookies"]

[[test]]
name = "gzip"
path = "tests/gzip.rs"
required-features = ["gzip", "stream"]

[[test]]
name = "brotli"
path = "tests/brotli.rs"
required-features = ["brotli", "stream"]

[[test]]
name = "zstd"
path = "tests/zstd.rs"
required-features = ["zstd", "stream"]

[[test]]
name = "deflate"
path = "tests/deflate.rs"
required-features = ["deflate", "stream"]

[[test]]
name = "multipart"
path = "tests/multipart.rs"
required-features = ["multipart", "stream"]

[[test]]
name = "retry"
path = "tests/retry.rs"

[[example]]
name = "json_dynamic"
path = "examples/json_dynamic.rs"
required-features = ["json"]

[[example]]
name = "json_typed"
path = "examples/json_typed.rs"
required-features = ["json"]

[[example]]
name = "tor_socks"
path = "examples/tor_socks.rs"
required-features = ["socks"]

[[example]]
name = "form"
path = "examples/form.rs"
required-features = ["form"]

[[example]]
name = "connect_via_lower_priority_tokio_runtime"
path = "examples/connect_via_lower_priority_tokio_runtime.rs"
required-features = ["tracing"]

[[example]]
name = "emulation"
path = "examples/emulation.rs"
required-features = ["gzip", "brotli", "zstd", "deflate", "tracing"]

[[example]]
name = "cert_store"
path = "examples/cert_store.rs"
required-features = ["webpki-roots"]

[[example]]
name = "request_with_redirect"
path = "examples/request_with_redirect.rs"

[[example]]
name = "request_with_version"
path = "examples/request_with_version.rs"

[[example]]
name = "request_with_proxy"
path = "examples/request_with_proxy.rs"
required-features = ["socks"]

[[example]]
name = "request_with_emulation"
path = "examples/request_with_emulation.rs"
required-features = ["gzip", "brotli", "zstd", "deflate", "tracing"]

[[example]]
name = "request_with_local_address"
path = "examples/request_with_local_address.rs"

[[example]]
name = "request_with_interface"
path = "examples/request_with_interface.rs"

[[example]]
name = "http1_websocket"
path = "examples/http1_websocket.rs"
required-features = ["ws", "futures-util/std"]

[[example]]
name = "http2_websocket"
path = "examples/http2_websocket.rs"
required-features = ["ws", "futures-util/std"]

[[example]]
name = "keylog"
path = "examples/keylog.rs"

[[example]]
name = "unix_socket"
path = "examples/unix_socket.rs"

[[example]]
name = "tower_delay"
path = "examples/tower_delay.rs"

[[example]]
name = "tower_jitter_delay"
path = "examples/tower_jitter_delay.rs"

# Benchmarks
[[bench]]
name = "json_parsing"
harness = false
required-features = ["json"]

[[bench]]
name = "http_throughput"
harness = false

[[bench]]
name = "connection_pool"
harness = false

[[bench]]
name = "contention"
harness = false