wreq 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +495 -57
- data/Cargo.toml +18 -6
- data/README.md +1 -1
- data/crates/wreq-util/CHANGELOG.md +1 -0
- data/crates/wreq-util/Cargo.toml +3 -1
- data/crates/wreq-util/README.md +4 -2
- data/crates/wreq-util/examples/emulate.rs +7 -3
- data/crates/wreq-util/examples/tower_delay.rs +4 -4
- data/crates/wreq-util/src/emulate/macros.rs +0 -1
- data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +3 -3
- data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +17 -39
- data/crates/wreq-util/src/emulate/profile/chrome.rs +71 -0
- data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +11 -11
- data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +9 -14
- data/crates/wreq-util/src/emulate/profile/okhttp.rs +9 -15
- data/crates/wreq-util/src/emulate/profile/opera/http2.rs +3 -3
- data/crates/wreq-util/src/emulate/profile/opera/tls.rs +11 -5
- data/crates/wreq-util/src/emulate/profile/safari/tls.rs +14 -15
- data/crates/wreq-util/src/emulate/profile.rs +7 -9
- data/crates/wreq-util/src/emulate.rs +3 -1
- data/crates/wreq-util/src/tower/delay/layer.rs +5 -5
- data/crates/wreq-util/src/tower/delay.rs +4 -4
- data/crates/wreq-util/tests/client.rs +7 -3
- data/crates/wreq-util/tests/emulate_chrome.rs +20 -0
- data/crates/wreq-util/tests/emulate_firefox.rs +26 -21
- data/crates/wreq-util/tests/emulate_safari.rs +1 -1
- data/crates/wreq-util/tests/support/mod.rs +16 -13
- data/lib/wreq.rb +9 -9
- data/lib/wreq_ruby/client.rb +39 -25
- data/lib/wreq_ruby/emulate.rb +7 -2
- data/lib/wreq_ruby/http.rb +9 -2
- data/src/client.rs +8 -4
- data/src/emulate.rs +2 -0
- data/test/emulation_test.rb +3 -1
- data/test/option_validation_test.rb +13 -4
- metadata +1 -1
|
@@ -19,7 +19,7 @@ macro_rules! tls_options {
|
|
|
19
19
|
.curves($curves)
|
|
20
20
|
.cipher_list($cipher_list)
|
|
21
21
|
.sigalgs_list($sigalgs_list)
|
|
22
|
-
.
|
|
22
|
+
.tls13_cipher_list(TLS13_CIPHER_LIST)
|
|
23
23
|
.min_tls_version(wreq::tls::TlsVersion::TLS_1_2)
|
|
24
24
|
.max_tls_version(wreq::tls::TlsVersion::TLS_1_3)
|
|
25
25
|
.build()
|
|
@@ -33,9 +33,6 @@ pub const CURVES_2: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-38
|
|
|
33
33
|
|
|
34
34
|
pub const CIPHER_LIST_1: &str = join!(
|
|
35
35
|
":",
|
|
36
|
-
"TLS_AES_128_GCM_SHA256",
|
|
37
|
-
"TLS_AES_256_GCM_SHA384",
|
|
38
|
-
"TLS_CHACHA20_POLY1305_SHA256",
|
|
39
36
|
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
40
37
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
41
38
|
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
@@ -62,9 +59,6 @@ pub const CIPHER_LIST_1: &str = join!(
|
|
|
62
59
|
);
|
|
63
60
|
pub const CIPHER_LIST_2: &str = join!(
|
|
64
61
|
":",
|
|
65
|
-
"TLS_AES_128_GCM_SHA256",
|
|
66
|
-
"TLS_AES_256_GCM_SHA384",
|
|
67
|
-
"TLS_CHACHA20_POLY1305_SHA256",
|
|
68
62
|
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
69
63
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
70
64
|
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
@@ -85,9 +79,6 @@ pub const CIPHER_LIST_2: &str = join!(
|
|
|
85
79
|
);
|
|
86
80
|
pub const CIPHER_LIST_3: &str = join!(
|
|
87
81
|
":",
|
|
88
|
-
"TLS_AES_256_GCM_SHA384",
|
|
89
|
-
"TLS_CHACHA20_POLY1305_SHA256",
|
|
90
|
-
"TLS_AES_128_GCM_SHA256",
|
|
91
82
|
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
92
83
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
93
84
|
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
@@ -107,6 +98,12 @@ pub const CIPHER_LIST_3: &str = join!(
|
|
|
107
98
|
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
|
|
108
99
|
);
|
|
109
100
|
|
|
101
|
+
pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[
|
|
102
|
+
Tls13Cipher::AES_256_GCM_SHA384,
|
|
103
|
+
Tls13Cipher::CHACHA20_POLY1305_SHA256,
|
|
104
|
+
Tls13Cipher::AES_128_GCM_SHA256,
|
|
105
|
+
];
|
|
106
|
+
|
|
110
107
|
pub const SIGALGS_LIST_1: &str = join!(
|
|
111
108
|
":",
|
|
112
109
|
"ecdsa_secp256r1_sha256",
|
|
@@ -155,23 +152,25 @@ pub struct SafariTlsConfig {
|
|
|
155
152
|
cipher_list: &'static str,
|
|
156
153
|
|
|
157
154
|
#[builder(default, setter(strip_option))]
|
|
158
|
-
|
|
155
|
+
tls13_cipher_list: Option<&'static [Tls13Cipher]>,
|
|
159
156
|
}
|
|
160
157
|
|
|
161
158
|
impl From<SafariTlsConfig> for TlsOptions {
|
|
162
159
|
fn from(val: SafariTlsConfig) -> Self {
|
|
163
|
-
TlsOptions::builder()
|
|
160
|
+
let mut builder = TlsOptions::builder()
|
|
164
161
|
.session_ticket(false)
|
|
165
162
|
.grease_enabled(true)
|
|
166
163
|
.enable_ocsp_stapling(true)
|
|
167
164
|
.enable_signed_cert_timestamps(true)
|
|
168
|
-
.preserve_tls13_cipher_list(val.preserve_tls13_cipher_list)
|
|
169
165
|
.curves_list(val.curves)
|
|
170
166
|
.sigalgs_list(val.sigalgs_list)
|
|
171
167
|
.cipher_list(val.cipher_list)
|
|
172
168
|
.min_tls_version(val.min_tls_version)
|
|
173
169
|
.max_tls_version(val.max_tls_version)
|
|
174
|
-
.certificate_compressors(CERTIFICATE_COMPRESSORS)
|
|
175
|
-
|
|
170
|
+
.certificate_compressors(CERTIFICATE_COMPRESSORS);
|
|
171
|
+
if let Some(ciphers) = val.tls13_cipher_list {
|
|
172
|
+
builder = builder.tls13_cipher_list(ciphers);
|
|
173
|
+
}
|
|
174
|
+
builder.build()
|
|
176
175
|
}
|
|
177
176
|
}
|
|
@@ -10,15 +10,14 @@ use typed_builder::TypedBuilder;
|
|
|
10
10
|
#[cfg(feature = "emulation-compression")]
|
|
11
11
|
use wreq::header::ACCEPT_ENCODING;
|
|
12
12
|
use wreq::{
|
|
13
|
-
Group,
|
|
14
13
|
header::{ACCEPT, ACCEPT_LANGUAGE, HeaderMap, HeaderName, HeaderValue, USER_AGENT},
|
|
15
14
|
http2::{
|
|
16
|
-
Http2Options, Priorities, Priority, PseudoId,
|
|
17
|
-
StreamDependency, StreamId,
|
|
15
|
+
HeadersDependency, HeadersPriority, Http2Options, Priorities, Priority, PseudoId,
|
|
16
|
+
PseudoOrder, SettingId, SettingsOrder, StreamDependency, StreamId,
|
|
18
17
|
},
|
|
19
18
|
tls::{
|
|
20
|
-
AlpnProtocol, AlpsProtocol, ExtensionType, KeyShare,
|
|
21
|
-
compress::CertificateCompressor,
|
|
19
|
+
AlpnProtocol, AlpsProtocol, EchGrease, EchGreaseAead, ExtensionType, KeyShare, Tls13Cipher,
|
|
20
|
+
TlsOptions, TlsVersion, compress::CertificateCompressor,
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
|
|
@@ -28,20 +27,19 @@ use super::{
|
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
fn build_standard_emulation(
|
|
31
|
-
group: &'static str,
|
|
32
30
|
tls_options: TlsOptions,
|
|
33
31
|
http2_options: Option<Http2Options>,
|
|
34
32
|
default_headers: Option<HeaderMap>,
|
|
35
33
|
) -> wreq::Emulation {
|
|
36
|
-
let mut builder = wreq::Emulation::builder().
|
|
34
|
+
let mut builder = wreq::Emulation::builder().config(tls_options);
|
|
37
35
|
|
|
38
36
|
if let Some(http2_options) = http2_options {
|
|
39
|
-
builder = builder.
|
|
37
|
+
builder = builder.config(http2_options);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
if let Some(headers) = default_headers {
|
|
43
41
|
builder = builder.headers(headers);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
builder.build(
|
|
44
|
+
builder.build()
|
|
47
45
|
}
|
|
@@ -66,6 +66,8 @@ define_enum!(
|
|
|
66
66
|
Chrome153 => ("chrome_153", v153::emulation),
|
|
67
67
|
Chrome154 => ("chrome_154", v154::emulation),
|
|
68
68
|
Chrome155 => ("chrome_155", v155::emulation),
|
|
69
|
+
Chrome156 => ("chrome_156", v156::emulation),
|
|
70
|
+
Chrome157 => ("chrome_157", v157::emulation),
|
|
69
71
|
|
|
70
72
|
// Edge versions
|
|
71
73
|
Edge101 => ("edge_101", edge101::emulation),
|
|
@@ -221,7 +223,7 @@ impl Platform {
|
|
|
221
223
|
/// Conversion through [`wreq::IntoEmulation`] creates a native configuration,
|
|
222
224
|
/// including a randomized Trust Anchor ID order for Chrome 152/153 profiles.
|
|
223
225
|
/// Client-level emulation retains that order for subsequent connections.
|
|
224
|
-
/// Chrome 154
|
|
226
|
+
/// Chrome 154–156 sort the IDs by their raw bytes instead.
|
|
225
227
|
#[derive(Default, Clone, TypedBuilder)]
|
|
226
228
|
pub struct Emulation {
|
|
227
229
|
/// Whether to change the profile (browser/okhttp) information.
|
|
@@ -29,10 +29,10 @@ pub struct DelayLayerWith<P> {
|
|
|
29
29
|
/// ```no_run
|
|
30
30
|
/// use std::time::Duration;
|
|
31
31
|
/// use wreq::Client;
|
|
32
|
-
/// use wreq_util::
|
|
32
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
33
33
|
///
|
|
34
34
|
/// // Creates delays in range [0.8s, 1.2s] (1s ± 20%)
|
|
35
|
-
/// let client = Client::
|
|
35
|
+
/// let client = Client::builder_tokio()
|
|
36
36
|
/// .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2))
|
|
37
37
|
/// .build()?;
|
|
38
38
|
/// # Ok::<(), wreq::Error>(())
|
|
@@ -71,7 +71,7 @@ impl DelayLayer {
|
|
|
71
71
|
/// ```ignore
|
|
72
72
|
/// use std::time::Duration;
|
|
73
73
|
/// use http::Request;
|
|
74
|
-
/// use wreq_util::
|
|
74
|
+
/// use wreq_util::tower::delay::DelayLayer;
|
|
75
75
|
///
|
|
76
76
|
/// // Only delay POST requests
|
|
77
77
|
/// let layer = DelayLayer::new(Duration::from_secs(1))
|
|
@@ -129,7 +129,7 @@ impl JitterDelayLayer {
|
|
|
129
129
|
///
|
|
130
130
|
/// ```
|
|
131
131
|
/// use std::time::Duration;
|
|
132
|
-
/// use wreq_util::
|
|
132
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
133
133
|
///
|
|
134
134
|
/// // Creates delays in range [800ms, 1200ms]
|
|
135
135
|
/// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2);
|
|
@@ -151,7 +151,7 @@ impl JitterDelayLayer {
|
|
|
151
151
|
/// ```ignore
|
|
152
152
|
/// use std::time::Duration;
|
|
153
153
|
/// use http::Request;
|
|
154
|
-
/// use wreq_util::
|
|
154
|
+
/// use wreq_util::tower::delay::JitterDelayLayer;
|
|
155
155
|
///
|
|
156
156
|
/// // Only delay requests to paths starting with "/slow"
|
|
157
157
|
/// let layer = JitterDelayLayer::new(Duration::from_secs(1), 0.2)
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
//! ```no_run
|
|
11
11
|
//! use std::time::Duration;
|
|
12
12
|
//! use wreq::Client;
|
|
13
|
-
//! use wreq_util::
|
|
13
|
+
//! use wreq_util::tower::delay::DelayLayer;
|
|
14
14
|
//!
|
|
15
|
-
//! let client = Client::
|
|
15
|
+
//! let client = Client::builder_tokio()
|
|
16
16
|
//! .layer(DelayLayer::new(Duration::from_secs(1)))
|
|
17
17
|
//! .build()?;
|
|
18
18
|
//! # Ok::<(), wreq::Error>(())
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
//! ```no_run
|
|
24
24
|
//! use std::time::Duration;
|
|
25
25
|
//! use wreq::Client;
|
|
26
|
-
//! use wreq_util::
|
|
26
|
+
//! use wreq_util::tower::delay::JitterDelayLayer;
|
|
27
27
|
//!
|
|
28
|
-
//! let client = Client::
|
|
28
|
+
//! let client = Client::builder_tokio()
|
|
29
29
|
//! .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.2))
|
|
30
30
|
//! .build()?;
|
|
31
31
|
//! # Ok::<(), wreq::Error>(())
|
|
@@ -80,7 +80,7 @@ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static
|
|
|
80
80
|
let server = server::low_level_with_response(move |request, stream| {
|
|
81
81
|
check_header_order(request, stream, expected)
|
|
82
82
|
});
|
|
83
|
-
let response = Client::
|
|
83
|
+
let response = Client::builder_tokio()
|
|
84
84
|
.emulation(profile)
|
|
85
85
|
.build()
|
|
86
86
|
.expect("client")
|
|
@@ -95,7 +95,11 @@ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static
|
|
|
95
95
|
#[tokio::test]
|
|
96
96
|
async fn test_client_emulation_device() {
|
|
97
97
|
let server = server::http(move |req| async move {
|
|
98
|
-
let header = |name|
|
|
98
|
+
let header = |name| {
|
|
99
|
+
req.headers()
|
|
100
|
+
.get(name)
|
|
101
|
+
.and_then(|value| value.to_str().ok())
|
|
102
|
+
};
|
|
99
103
|
|
|
100
104
|
assert_eq!(
|
|
101
105
|
header("user-agent"),
|
|
@@ -113,7 +117,7 @@ async fn test_client_emulation_device() {
|
|
|
113
117
|
});
|
|
114
118
|
|
|
115
119
|
let url = format!("http://{}/ua", server.addr());
|
|
116
|
-
let res = Client::
|
|
120
|
+
let res = Client::builder_tokio()
|
|
117
121
|
.emulation(
|
|
118
122
|
Emulation::builder()
|
|
119
123
|
.profile(Emulation::Chrome151)
|
|
@@ -315,3 +315,23 @@ test_emulation!(
|
|
|
315
315
|
],
|
|
316
316
|
"52d84b11737d980aef856699f885ca86"
|
|
317
317
|
);
|
|
318
|
+
|
|
319
|
+
test_emulation!(
|
|
320
|
+
test_chrome156,
|
|
321
|
+
Emulation::Chrome156,
|
|
322
|
+
[
|
|
323
|
+
"t13d1517h2_8daaf6152771_cb7bf5808d99",
|
|
324
|
+
"t13d1518h2_8daaf6152771_e2d80978ab2e"
|
|
325
|
+
],
|
|
326
|
+
"52d84b11737d980aef856699f885ca86"
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
test_emulation!(
|
|
330
|
+
test_chrome157,
|
|
331
|
+
Emulation::Chrome157,
|
|
332
|
+
[
|
|
333
|
+
"t13d1517h2_8daaf6152771_cb7bf5808d99",
|
|
334
|
+
"t13d1518h2_8daaf6152771_e2d80978ab2e"
|
|
335
|
+
],
|
|
336
|
+
"52d84b11737d980aef856699f885ca86"
|
|
337
|
+
);
|
|
@@ -118,9 +118,8 @@ test_emulation!(
|
|
|
118
118
|
///
|
|
119
119
|
/// Every profile is listed rather than a range, so adding one is a deliberate choice about
|
|
120
120
|
/// which side of 147 it falls on.
|
|
121
|
-
#[test]
|
|
122
|
-
fn firefox_accept_language_matches_the_profile_version() {
|
|
123
|
-
use wreq::IntoEmulation;
|
|
121
|
+
#[tokio::test]
|
|
122
|
+
async fn firefox_accept_language_matches_the_profile_version() {
|
|
124
123
|
use wreq_util::{Platform, Profile};
|
|
125
124
|
|
|
126
125
|
const PRE_147: &[(&str, Profile)] = &[
|
|
@@ -149,23 +148,29 @@ fn firefox_accept_language_matches_the_profile_version() {
|
|
|
149
148
|
("Firefox152", Emulation::Firefox152),
|
|
150
149
|
];
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
let server = support::server::http(|request| async move {
|
|
152
|
+
let mut response = http::Response::default();
|
|
153
|
+
response.headers_mut().insert(
|
|
154
|
+
"accept-language",
|
|
155
|
+
request.headers()["accept-language"].clone(),
|
|
156
|
+
);
|
|
157
|
+
response
|
|
158
|
+
});
|
|
159
|
+
let client = wreq::Client::builder_tokio().no_proxy().build().unwrap();
|
|
160
|
+
for (profiles, expected) in [(PRE_147, "en-US,en;q=0.5"), (POST_147, "en-US,en;q=0.9")] {
|
|
161
|
+
for (name, profile) in profiles {
|
|
162
|
+
let response = client
|
|
163
|
+
.get(format!("http://{}/", server.addr()))
|
|
164
|
+
.emulation(
|
|
165
|
+
Emulation::builder()
|
|
166
|
+
.profile(*profile)
|
|
167
|
+
.platform(Platform::Linux)
|
|
168
|
+
.build(),
|
|
169
|
+
)
|
|
170
|
+
.send()
|
|
171
|
+
.await
|
|
172
|
+
.unwrap();
|
|
173
|
+
assert_eq!(response.headers()["accept-language"], expected, "{name}");
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
}
|
|
@@ -14,7 +14,7 @@ pub static DEFAULT_USER_AGENT: &str =
|
|
|
14
14
|
pub static TEST_SEMAPHORE: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(1));
|
|
15
15
|
|
|
16
16
|
pub static CLIENT: LazyLock<Client> = LazyLock::new(|| {
|
|
17
|
-
Client::
|
|
17
|
+
Client::builder_tokio()
|
|
18
18
|
.connect_timeout(Duration::from_secs(60))
|
|
19
19
|
.build()
|
|
20
20
|
.unwrap()
|
|
@@ -36,18 +36,21 @@ macro_rules! test_emulation {
|
|
|
36
36
|
|
|
37
37
|
assert_eq!(resp.status(), wreq::StatusCode::OK);
|
|
38
38
|
let content = resp.text().await.unwrap();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
let fingerprint: serde_json::Value = serde_json::from_str(&content)
|
|
40
|
+
.unwrap_or_else(|error| panic!("invalid fingerprint JSON: {error}\n{content}"));
|
|
41
|
+
|
|
42
|
+
let actual_ja4 = fingerprint["ja4"].as_str();
|
|
43
|
+
assert!(
|
|
44
|
+
actual_ja4.is_some_and(|value| $ja4.contains(&value)),
|
|
45
|
+
"JA4 fingerprint mismatch: expected {:?}, got {actual_ja4:?}\n{content}",
|
|
46
|
+
$ja4
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
assert_eq!(
|
|
50
|
+
fingerprint["akamai_hash"].as_str(),
|
|
51
|
+
Some($akamai_hash),
|
|
52
|
+
"HTTP/2 fingerprint mismatch:\n{content}"
|
|
53
|
+
);
|
|
51
54
|
|
|
52
55
|
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
|
|
53
56
|
}
|
data/lib/wreq.rb
CHANGED
|
@@ -76,7 +76,7 @@ unless defined?(Wreq)
|
|
|
76
76
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
77
77
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
78
78
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
79
|
-
# @param read_timeout [Integer, nil]
|
|
79
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
80
80
|
# @param proxy [String, nil] Proxy server URI
|
|
81
81
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
82
82
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -110,7 +110,7 @@ unless defined?(Wreq)
|
|
|
110
110
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
111
111
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
112
112
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
113
|
-
# @param read_timeout [Integer, nil]
|
|
113
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
114
114
|
# @param proxy [String, nil] Proxy server URI
|
|
115
115
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
116
116
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -144,7 +144,7 @@ unless defined?(Wreq)
|
|
|
144
144
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
145
145
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
146
146
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
147
|
-
# @param read_timeout [Integer, nil]
|
|
147
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
148
148
|
# @param proxy [String, nil] Proxy server URI
|
|
149
149
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
150
150
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -178,7 +178,7 @@ unless defined?(Wreq)
|
|
|
178
178
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
179
179
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
180
180
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
181
|
-
# @param read_timeout [Integer, nil]
|
|
181
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
182
182
|
# @param proxy [String, nil] Proxy server URI
|
|
183
183
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
184
184
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -212,7 +212,7 @@ unless defined?(Wreq)
|
|
|
212
212
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
213
213
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
214
214
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
215
|
-
# @param read_timeout [Integer, nil]
|
|
215
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
216
216
|
# @param proxy [String, nil] Proxy server URI
|
|
217
217
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
218
218
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -246,7 +246,7 @@ unless defined?(Wreq)
|
|
|
246
246
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
247
247
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
248
248
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
249
|
-
# @param read_timeout [Integer, nil]
|
|
249
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
250
250
|
# @param proxy [String, nil] Proxy server URI
|
|
251
251
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
252
252
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -280,7 +280,7 @@ unless defined?(Wreq)
|
|
|
280
280
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
281
281
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
282
282
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
283
|
-
# @param read_timeout [Integer, nil]
|
|
283
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
284
284
|
# @param proxy [String, nil] Proxy server URI
|
|
285
285
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
286
286
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -314,7 +314,7 @@ unless defined?(Wreq)
|
|
|
314
314
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
315
315
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
316
316
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
317
|
-
# @param read_timeout [Integer, nil]
|
|
317
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
318
318
|
# @param proxy [String, nil] Proxy server URI
|
|
319
319
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
320
320
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -348,7 +348,7 @@ unless defined?(Wreq)
|
|
|
348
348
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
349
349
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
350
350
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
351
|
-
# @param read_timeout [Integer, nil]
|
|
351
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
352
352
|
# @param proxy [String, nil] Proxy server URI
|
|
353
353
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
354
354
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
data/lib/wreq_ruby/client.rb
CHANGED
|
@@ -5,7 +5,7 @@ unless defined?(Wreq)
|
|
|
5
5
|
# HTTP client with extensive configuration options.
|
|
6
6
|
#
|
|
7
7
|
# This class wraps a native Rust implementation providing high-performance
|
|
8
|
-
# HTTP/1.1 and HTTP/
|
|
8
|
+
# HTTP/1.1, HTTP/2 and HTTP/3 client functionality with support for connection pooling,
|
|
9
9
|
# compression, redirects, proxies, and fine-grained timeout controls.
|
|
10
10
|
#
|
|
11
11
|
# The client is thread-safe and maintains an internal connection pool for
|
|
@@ -84,8 +84,8 @@ unless defined?(Wreq)
|
|
|
84
84
|
# from the overall timeout.
|
|
85
85
|
#
|
|
86
86
|
# @param read_timeout [Integer, nil] Maximum time in seconds to wait
|
|
87
|
-
#
|
|
88
|
-
#
|
|
87
|
+
# for response headers or each body chunk. Time spent by the caller
|
|
88
|
+
# between body reads is excluded. Defaults to no read timeout.
|
|
89
89
|
#
|
|
90
90
|
# @param tcp_keepalive [Integer, nil] Time in seconds that a connection
|
|
91
91
|
# must be idle before TCP keepalive probes are sent. Helps detect
|
|
@@ -110,25 +110,37 @@ unless defined?(Wreq)
|
|
|
110
110
|
# allowing the reuse of local addresses in TIME_WAIT state. Useful for
|
|
111
111
|
# reducing port exhaustion in high-throughput scenarios.
|
|
112
112
|
#
|
|
113
|
-
# @param pool_idle_timeout [Integer, nil]
|
|
114
|
-
#
|
|
115
|
-
#
|
|
113
|
+
# @param pool_idle_timeout [Integer, nil] Idle connection reuse timeout in
|
|
114
|
+
# seconds. Defaults to 90 when omitted or nil. Does not expire a busy
|
|
115
|
+
# HTTP/2 or HTTP/3 connection.
|
|
116
116
|
#
|
|
117
|
-
# @param pool_max_idle_per_host [Integer, nil] Maximum
|
|
118
|
-
# connections
|
|
119
|
-
#
|
|
117
|
+
# @param pool_max_idle_per_host [Integer, nil] Maximum idle HTTP/1
|
|
118
|
+
# connections retained per compatibility group, which includes the host
|
|
119
|
+
# and connection configuration. Defaults to unlimited when omitted or
|
|
120
|
+
# nil; 0 disables connection reuse. Does not limit active connections.
|
|
120
121
|
#
|
|
121
|
-
# @param pool_max_size [Integer, nil]
|
|
122
|
-
#
|
|
123
|
-
#
|
|
122
|
+
# @param pool_max_size [Integer, nil] Maximum compatibility groups retaining
|
|
123
|
+
# idle HTTP/1 or shared HTTP/2 and HTTP/3 connections. Defaults to unlimited
|
|
124
|
+
# when omitted, nil or 0. A full pool evicts the least recently used idle
|
|
125
|
+
# group; it does not make requests wait or limit physical connections.
|
|
124
126
|
#
|
|
125
127
|
# @param http1_only [Boolean, nil] Force the client to use HTTP/1.1 only,
|
|
126
128
|
# even if HTTP/2 is available. Useful for compatibility with servers
|
|
127
|
-
# that have problematic HTTP/2 implementations.
|
|
129
|
+
# that have problematic HTTP/2 implementations. Cannot be combined with
|
|
130
|
+
# http2_only or http3_only. An explicit request version overrides this
|
|
131
|
+
# preference.
|
|
128
132
|
#
|
|
129
133
|
# @param http2_only [Boolean, nil] Force the client to use HTTP/2 only.
|
|
130
134
|
# Requests to servers that don't support HTTP/2 will fail. Cannot be
|
|
131
|
-
# combined with http1_only.
|
|
135
|
+
# combined with http1_only or http3_only. An explicit request version
|
|
136
|
+
# overrides this preference, including HTTP/3 over QUIC.
|
|
137
|
+
#
|
|
138
|
+
# @param http3_only [Boolean, nil] Use HTTP/3 over QUIC without falling back
|
|
139
|
+
# to TCP. Defaults to false when omitted or nil. Requires HTTPS and UDP
|
|
140
|
+
# connectivity. Cannot be combined with http1_only or http2_only. An
|
|
141
|
+
# explicit HTTP/1 or HTTP/2 request version overrides this preference.
|
|
142
|
+
# HTTP/HTTPS proxies, including environment proxies, cannot carry HTTP/3;
|
|
143
|
+
# use no_proxy: true, a SOCKS5 UDP proxy, or a QUIC MASQUE proxy instead.
|
|
132
144
|
#
|
|
133
145
|
# @param https_only [Boolean, nil] Reject plain HTTP connections and
|
|
134
146
|
# only allow HTTPS. Provides an additional layer of security by
|
|
@@ -149,7 +161,9 @@ unless defined?(Wreq)
|
|
|
149
161
|
# environment.
|
|
150
162
|
#
|
|
151
163
|
# @param proxy [String, nil] Proxy server URI to use for all requests.
|
|
152
|
-
# Supports HTTP, HTTPS, and
|
|
164
|
+
# Supports HTTP, HTTPS, SOCKS and QUIC proxies. HTTP/3 can use SOCKS5 UDP
|
|
165
|
+
# ASSOCIATE or a `quic://` MASQUE proxy, but not HTTP CONNECT proxies.
|
|
166
|
+
# Format: "protocol://host:port"
|
|
153
167
|
# Example: "http://proxy.example.com:8080"
|
|
154
168
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable.
|
|
155
169
|
# @param interface [String, nil] Bind sockets to a network interface on
|
|
@@ -196,7 +210,7 @@ unless defined?(Wreq)
|
|
|
196
210
|
# client = Wreq::Client.new(
|
|
197
211
|
# timeout: 30, # 30 seconds total
|
|
198
212
|
# connect_timeout: 5, # 5 seconds to connect
|
|
199
|
-
# read_timeout: 10 # 10 seconds
|
|
213
|
+
# read_timeout: 10 # 10 seconds for headers or each body read
|
|
200
214
|
# )
|
|
201
215
|
#
|
|
202
216
|
# @example Client with redirect handling
|
|
@@ -280,7 +294,7 @@ unless defined?(Wreq)
|
|
|
280
294
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
281
295
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
282
296
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
283
|
-
# @param read_timeout [Integer, nil]
|
|
297
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
284
298
|
# @param proxy [String, nil] Proxy server URI
|
|
285
299
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
286
300
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -316,7 +330,7 @@ unless defined?(Wreq)
|
|
|
316
330
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
317
331
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
318
332
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
319
|
-
# @param read_timeout [Integer, nil]
|
|
333
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
320
334
|
# @param proxy [String, nil] Proxy server URI
|
|
321
335
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
322
336
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -350,7 +364,7 @@ unless defined?(Wreq)
|
|
|
350
364
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
351
365
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
352
366
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
353
|
-
# @param read_timeout [Integer, nil]
|
|
367
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
354
368
|
# @param proxy [String, nil] Proxy server URI
|
|
355
369
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
356
370
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -384,7 +398,7 @@ unless defined?(Wreq)
|
|
|
384
398
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
385
399
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
386
400
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
387
|
-
# @param read_timeout [Integer, nil]
|
|
401
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
388
402
|
# @param proxy [String, nil] Proxy server URI
|
|
389
403
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
390
404
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -418,7 +432,7 @@ unless defined?(Wreq)
|
|
|
418
432
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
419
433
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
420
434
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
421
|
-
# @param read_timeout [Integer, nil]
|
|
435
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
422
436
|
# @param proxy [String, nil] Proxy server URI
|
|
423
437
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
424
438
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -452,7 +466,7 @@ unless defined?(Wreq)
|
|
|
452
466
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
453
467
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
454
468
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
455
|
-
# @param read_timeout [Integer, nil]
|
|
469
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
456
470
|
# @param proxy [String, nil] Proxy server URI
|
|
457
471
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
458
472
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -486,7 +500,7 @@ unless defined?(Wreq)
|
|
|
486
500
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
487
501
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
488
502
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
489
|
-
# @param read_timeout [Integer, nil]
|
|
503
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
490
504
|
# @param proxy [String, nil] Proxy server URI
|
|
491
505
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
492
506
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -520,7 +534,7 @@ unless defined?(Wreq)
|
|
|
520
534
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
521
535
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
522
536
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
523
|
-
# @param read_timeout [Integer, nil]
|
|
537
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
524
538
|
# @param proxy [String, nil] Proxy server URI
|
|
525
539
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
526
540
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
@@ -554,7 +568,7 @@ unless defined?(Wreq)
|
|
|
554
568
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
555
569
|
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
556
570
|
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
557
|
-
# @param read_timeout [Integer, nil]
|
|
571
|
+
# @param read_timeout [Integer, nil] Timeout for headers or each body chunk (seconds)
|
|
558
572
|
# @param proxy [String, nil] Proxy server URI
|
|
559
573
|
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
560
574
|
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|