wreq 1.3.2.1 → 1.3.5

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.
data/Cargo.toml CHANGED
@@ -5,7 +5,7 @@ authors = ["SearchApi <support@searchapi.io>"]
5
5
  homepage = "https://github.com/SearchApi/wreq-ruby"
6
6
  repository = "https://github.com/SearchApi/wreq-ruby"
7
7
  edition = "2024"
8
- version = "1.3.2"
8
+ version = "1.3.5"
9
9
  rust-version = "1.98"
10
10
 
11
11
  [lib]
@@ -20,6 +20,8 @@ tokio = { version = "1.53.1", features = ["full"] }
20
20
  # Keep the existing trust store independent of wreq's default feature selection.
21
21
  wreq = { version = "0.16.1", default-features = false, features = [
22
22
  "tokio-rt",
23
+ "http2",
24
+ "http3",
23
25
  "chromium-roots",
24
26
  "query",
25
27
  "form",
@@ -67,9 +69,15 @@ opt-level = 3
67
69
  strip = true
68
70
 
69
71
  [patch.crates-io]
70
- http2 = { git = "https://github.com/0x676e67/http2", rev = "29b3bdfc7560d6f84119c103311afa147488b6f0" }
72
+ # Keep transport patches aligned with wreq's demo/brave-galileo-ac7w3r branch.
73
+ http2 = { git = "https://github.com/0x676e67/http2", rev = "ce505e52ce9c25fb055412cb39b1caaa7a1f70a8" }
74
+ http3 = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" }
75
+ http3-datagram = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" }
76
+ http3-quic = { git = "https://github.com/0x676e67/http3", rev = "5bd394f3dfb8bc63591627a229c34c02caadc3af" }
77
+ quic = { git = "https://github.com/0x676e67/quic", rev = "b3d74044e874c5e785f462e3032faaf021cb6958" }
78
+ netty = { git = "https://github.com/0x676e67/netty", rev = "0e1e53c0d9e500b253361cf6997559c44d7717b5" }
71
79
  btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
72
80
  btls-sys = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
73
81
  tokio-btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
74
- wreq = { git = "https://github.com/0x676e67/wreq", rev = "74fc1469b5c54b3fb93037e48f136b569d0fe418" }
82
+ wreq = { git = "https://github.com/0x676e67/wreq", rev = "18d500474139c6740c841d3263f82a7eb1ac4883" }
75
83
  wreq-util = { path = "crates/wreq-util" }
@@ -23,6 +23,7 @@ tokio-rt = ["wreq/tokio-rt"]
23
23
  compio-rt = ["wreq/compio-rt"]
24
24
 
25
25
  emulation = [
26
+ "wreq/http2",
26
27
  "dep:typed-builder",
27
28
  "dep:brotli",
28
29
  "dep:flate2",
@@ -20,12 +20,14 @@ See the [crate documentation](https://docs.rs/wreq-util/latest/wreq_util) for mo
20
20
 
21
21
  ## Example
22
22
 
23
+ This vendored copy uses the development wreq revision pinned in the [root Cargo.toml](../../Cargo.toml). Building it independently requires the same Git patches.
24
+
23
25
  The following example uses the [Tokio](https://tokio.rs) runtime with optional features enabled by adding this to your `Cargo.toml`:
24
26
 
25
27
  ```toml
26
28
  [dependencies]
27
29
  tokio = { version = "1", features = ["full"] }
28
- wreq = "6.0.0-rc"
30
+ wreq = "0.16.1"
29
31
  wreq-util = "3.0.0-rc"
30
32
  ```
31
33
 
@@ -38,7 +40,7 @@ use wreq_util::Emulation;
38
40
  #[tokio::main]
39
41
  async fn main() -> wreq::Result<()> {
40
42
  // Build a client
41
- let client = Client::builder()
43
+ let client = Client::builder_tokio()
42
44
  .emulation(Emulation::Chrome147)
43
45
  .build()?;
44
46
 
@@ -2,8 +2,10 @@ use wreq_util::{Emulation, Platform, Profile};
2
2
 
3
3
  #[tokio::main]
4
4
  async fn main() -> Result<(), wreq::Error> {
5
+ let client = wreq::Client::builder_tokio().build()?;
5
6
  // Example 1: Basic emulation - Safari26
6
- let text = wreq::get("https://pingly.us.kg/api/all")
7
+ let text = client
8
+ .get("https://pingly.us.kg/api/all")
7
9
  .emulation(Emulation::Safari26)
8
10
  .send()
9
11
  .await?
@@ -12,7 +14,8 @@ async fn main() -> Result<(), wreq::Error> {
12
14
  println!("{}\n", text);
13
15
 
14
16
  // Example 2: Advanced emulation with options - OkHttp5
15
- let text = wreq::get("https://pingly.us.kg/api/all")
17
+ let text = client
18
+ .get("https://pingly.us.kg/api/all")
16
19
  .emulation(
17
20
  Emulation::builder()
18
21
  .profile(Profile::OkHttp5)
@@ -27,7 +30,8 @@ async fn main() -> Result<(), wreq::Error> {
27
30
  println!("{}\n", text);
28
31
 
29
32
  // Example 3: Random device emulation
30
- let text = wreq::get("https://pingly.us.kg/api/all")
33
+ let text = client
34
+ .get("https://pingly.us.kg/api/all")
31
35
  .emulation(Emulation::random())
32
36
  .send()
33
37
  .await?
@@ -5,7 +5,7 @@ use wreq_util::tower::delay::{DelayLayer, JitterDelayLayer};
5
5
  #[tokio::main]
6
6
  async fn main() -> Result<(), wreq::Error> {
7
7
  // Build a client with a 1 second delay between requests
8
- let client = Client::builder()
8
+ let client = Client::builder_tokio()
9
9
  .layer(DelayLayer::new(Duration::from_secs(1)))
10
10
  .tls_cert_verification(false)
11
11
  .build()?;
@@ -52,7 +52,7 @@ async fn basic_jitter_delay() -> Result<(), wreq::Error> {
52
52
  println!("=== Basic Jittered Delay ===\n");
53
53
 
54
54
  // Build a client with jittered delay: base 1s ± 50% (range: 0.5s to 1.5s)
55
- let client = Client::builder()
55
+ let client = Client::builder_tokio()
56
56
  .layer(JitterDelayLayer::new(Duration::from_secs(1), 0.5))
57
57
  .tls_cert_verification(false)
58
58
  .build()?;
@@ -100,7 +100,7 @@ async fn basic_jitter_delay() -> Result<(), wreq::Error> {
100
100
  async fn conditional_jitter_delay() -> Result<(), wreq::Error> {
101
101
  println!("=== Conditional Jittered Delay (using `JitterDelayLayer::when`) ===\n");
102
102
 
103
- let client = Client::builder()
103
+ let client = Client::builder_tokio()
104
104
  .layer(JitterDelayLayer::new(Duration::from_millis(800), 0.3).when(
105
105
  |req: &http::Request<_>| {
106
106
  // Only apply delay to POST requests
@@ -149,7 +149,7 @@ async fn conditional_fixed_delay() -> Result<(), wreq::Error> {
149
149
  println!("=== Conditional Fixed Delay (using `DelayLayer::when`) ===\n");
150
150
 
151
151
  // Build a client that only delays requests to specific paths
152
- let client = Client::builder()
152
+ let client = Client::builder_tokio()
153
153
  .layer(
154
154
  DelayLayer::new(Duration::from_secs(1)).when(|req: &http::Request<_>| {
155
155
  // Only apply delay to /delay/* endpoints
@@ -202,7 +202,6 @@ macro_rules! standard_mod_generator {
202
202
  default_headers: Option<HeaderMap>,
203
203
  ) -> wreq::Emulation {
204
204
  build_standard_emulation(
205
- stringify!($mod_name),
206
205
  $tls_options,
207
206
  http2.then(|| $http2_options),
208
207
  default_headers,
@@ -1,6 +1,6 @@
1
- macro_rules! headers_stream_dependency {
1
+ macro_rules! headers_priority {
2
2
  () => {
3
- StreamDependency::new(StreamId::zero(), 255, true)
3
+ HeadersPriority::new(HeadersDependency::Root, 255, true)
4
4
  };
5
5
  }
6
6
 
@@ -41,7 +41,7 @@ macro_rules! http2_options {
41
41
  .initial_connection_window_size(15728640)
42
42
  .max_header_list_size(262144)
43
43
  .header_table_size(65536)
44
- .headers_stream_dependency(headers_stream_dependency!())
44
+ .headers_priority(headers_priority!())
45
45
  .headers_pseudo_order(pseudo_order!())
46
46
  .settings_order(settings_order!())
47
47
  };
@@ -232,47 +232,14 @@ impl From<ChromeTlsConfig> for TlsOptions {
232
232
  #[cfg(test)]
233
233
  mod tests {
234
234
  use super::*;
235
- use wreq::IntoEmulation;
236
235
 
237
236
  #[test]
238
- fn chrome_profiles_retain_trust_anchor_order_when_cloned() {
239
- for profile in [
240
- crate::Profile::Chrome152,
241
- crate::Profile::Chrome153,
242
- crate::Profile::Chrome154,
243
- crate::Profile::Chrome155,
244
- crate::Profile::Chrome156,
245
- crate::Profile::Chrome157,
246
- ] {
247
- let native = profile.into_emulation();
248
- let cloned = native.clone();
249
- let ids = native.tls_options.unwrap().trust_anchors.unwrap();
250
- assert_eq!(ids.len(), CHROME_TRUST_ANCHORS.len());
251
- assert_eq!(ids, cloned.tls_options.unwrap().trust_anchors.unwrap());
252
- let decoded = decode_ids(&ids);
253
- let mut expected = chromium_roots::trust_anchor_ids();
254
- expected.sort_unstable();
255
- if matches!(
256
- profile,
257
- crate::Profile::Chrome154
258
- | crate::Profile::Chrome155
259
- | crate::Profile::Chrome156
260
- | crate::Profile::Chrome157
261
- ) {
262
- assert_eq!(decoded, expected);
263
- }
264
- let mut actual = decoded;
265
- actual.sort_unstable();
266
- assert_eq!(actual, expected);
267
- }
268
- assert!(
269
- crate::Profile::Chrome151
270
- .into_emulation()
271
- .tls_options
272
- .unwrap()
273
- .trust_anchors
274
- .is_none()
275
- );
237
+ fn sorted_trust_anchors_match_chromium_root_store() {
238
+ let encoded = sorted_trust_anchors();
239
+ let mut expected = chromium_roots::trust_anchor_ids();
240
+ expected.sort_unstable();
241
+ assert_eq!(decode_ids(&encoded), expected);
242
+ assert_eq!(encoded.len(), CHROME_TRUST_ANCHORS.len());
276
243
  }
277
244
 
278
245
  #[test]
@@ -1,9 +1,9 @@
1
- macro_rules! headers_stream_dependency {
1
+ macro_rules! headers_priority {
2
2
  (1) => {
3
- StreamDependency::new(StreamId::zero(), 41, false)
3
+ HeadersPriority::new(HeadersDependency::Root, 41, false)
4
4
  };
5
5
  (2) => {
6
- StreamDependency::new(StreamId::from(13), 41, false)
6
+ HeadersPriority::new(HeadersDependency::Declared(StreamId::from(13)), 41, false)
7
7
  };
8
8
  }
9
9
 
@@ -52,28 +52,28 @@ macro_rules! http2_options {
52
52
  .initial_stream_id(3)
53
53
  .header_table_size(65536)
54
54
  .enable_push(false)
55
- .headers_stream_dependency(headers_stream_dependency!(1))
55
+ .headers_priority(headers_priority!(1))
56
56
  .build()
57
57
  };
58
58
  (2) => {
59
59
  http2_options!(@base Http2Options::builder())
60
60
  .initial_stream_id(15)
61
61
  .header_table_size(65536)
62
- .headers_stream_dependency(headers_stream_dependency!(2))
62
+ .headers_priority(headers_priority!(2))
63
63
  .priorities(
64
64
  Priorities::builder()
65
65
  .extend([
66
66
  Priority::new(
67
67
  StreamId::from(3),
68
- StreamDependency::new(StreamId::zero(), 200, false),
68
+ StreamDependency::new(StreamId::from(0), 200, false),
69
69
  ),
70
70
  Priority::new(
71
71
  StreamId::from(5),
72
- StreamDependency::new(StreamId::zero(), 100, false),
72
+ StreamDependency::new(StreamId::from(0), 100, false),
73
73
  ),
74
74
  Priority::new(
75
75
  StreamId::from(7),
76
- StreamDependency::new(StreamId::zero(), 0, false),
76
+ StreamDependency::new(StreamId::from(0), 0, false),
77
77
  ),
78
78
  Priority::new(
79
79
  StreamId::from(9),
@@ -85,7 +85,7 @@ macro_rules! http2_options {
85
85
  ),
86
86
  Priority::new(
87
87
  StreamId::from(13),
88
- StreamDependency::new(StreamId::zero(), 240, false),
88
+ StreamDependency::new(StreamId::from(0), 240, false),
89
89
  ),
90
90
  ])
91
91
  .build(),
@@ -98,7 +98,7 @@ macro_rules! http2_options {
98
98
  .header_table_size(65536)
99
99
  .enable_push(false)
100
100
  .max_concurrent_streams(0)
101
- .headers_stream_dependency(headers_stream_dependency!(1))
101
+ .headers_priority(headers_priority!(1))
102
102
  .build()
103
103
  };
104
104
  (4) => {
@@ -107,7 +107,7 @@ macro_rules! http2_options {
107
107
  .header_table_size(4096)
108
108
  .enable_push(false)
109
109
  .initial_window_size(32768)
110
- .headers_stream_dependency(headers_stream_dependency!(1))
110
+ .headers_priority(headers_priority!(1))
111
111
  .build()
112
112
  };
113
113
  }
@@ -69,14 +69,13 @@ macro_rules! mod_generator {
69
69
  use super::*;
70
70
 
71
71
  pub fn emulation(emulation: Emulation) -> wreq::Emulation {
72
- build_emulation(stringify!($mod_name), emulation, $cipher, $ua)
72
+ build_emulation(emulation, $cipher, $ua)
73
73
  }
74
74
  }
75
75
  };
76
76
  }
77
77
 
78
78
  fn build_emulation(
79
- group: &'static str,
80
79
  emulation: Emulation,
81
80
  cipher_list: &'static str,
82
81
  user_agent: &'static str,
@@ -127,7 +126,7 @@ fn build_emulation(
127
126
  headers
128
127
  });
129
128
 
130
- build_standard_emulation(group, tls_options, http2_options, headers)
129
+ build_standard_emulation(tls_options, http2_options, headers)
131
130
  }
132
131
 
133
132
  mod_generator!(
@@ -1,6 +1,6 @@
1
- macro_rules! headers_stream_dependency {
1
+ macro_rules! headers_priority {
2
2
  () => {
3
- StreamDependency::new(StreamId::zero(), 255, true)
3
+ HeadersPriority::new(HeadersDependency::Root, 255, true)
4
4
  };
5
5
  }
6
6
 
@@ -42,7 +42,7 @@ macro_rules! http2_options {
42
42
  .max_header_list_size(262144)
43
43
  .header_table_size(65536)
44
44
  .enable_push(false)
45
- .headers_stream_dependency(headers_stream_dependency!())
45
+ .headers_priority(headers_priority!())
46
46
  .headers_pseudo_order(pseudo_order!())
47
47
  .settings_order(settings_order!())
48
48
  .build()
@@ -10,11 +10,10 @@ 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, PseudoOrder, SettingId, SettingsOrder,
17
- StreamDependency, StreamId,
15
+ HeadersDependency, HeadersPriority, Http2Options, Priorities, Priority, PseudoId,
16
+ PseudoOrder, SettingId, SettingsOrder, StreamDependency, StreamId,
18
17
  },
19
18
  tls::{
20
19
  AlpnProtocol, AlpsProtocol, EchGrease, EchGreaseAead, ExtensionType, KeyShare, Tls13Cipher,
@@ -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().tls_options(tls_options);
34
+ let mut builder = wreq::Emulation::builder().config(tls_options);
37
35
 
38
36
  if let Some(http2_options) = http2_options {
39
- builder = builder.http2_options(http2_options);
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(Group::new(group))
44
+ builder.build()
47
45
  }
@@ -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::middleware::delay::JitterDelayLayer;
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::builder()
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::middleware::delay::DelayLayer;
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::middleware::delay::JitterDelayLayer;
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::middleware::delay::JitterDelayLayer;
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::middleware::delay::DelayLayer;
13
+ //! use wreq_util::tower::delay::DelayLayer;
14
14
  //!
15
- //! let client = Client::builder()
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::middleware::delay::JitterDelayLayer;
26
+ //! use wreq_util::tower::delay::JitterDelayLayer;
27
27
  //!
28
- //! let client = Client::builder()
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::builder()
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| req.headers().get(name).and_then(|value| value.to_str().ok());
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::builder()
120
+ let res = Client::builder_tokio()
117
121
  .emulation(
118
122
  Emulation::builder()
119
123
  .profile(Emulation::Chrome151)
@@ -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
- fn accept_language(profile: Profile) -> String {
153
- Emulation::builder()
154
- .profile(profile)
155
- .platform(Platform::Linux)
156
- .build()
157
- .into_emulation()
158
- .headers
159
- .get("accept-language")
160
- .and_then(|value| value.to_str().ok())
161
- .unwrap_or_default()
162
- .to_owned()
163
- }
164
-
165
- for (name, profile) in PRE_147 {
166
- assert_eq!("en-US,en;q=0.5", accept_language(*profile), "{name}");
167
- }
168
- for (name, profile) in POST_147 {
169
- assert_eq!("en-US,en;q=0.9", accept_language(*profile), "{name}");
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::builder()
17
+ Client::builder_tokio()
18
18
  .connect_timeout(Duration::from_secs(60))
19
19
  .build()
20
20
  .unwrap()
@@ -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/2 client functionality with support for connection pooling,
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
@@ -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] Time in seconds before idle
114
- # connections in the pool are evicted and closed. Helps free up
115
- # resources for long-running applications.
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 number of idle
118
- # connections to maintain per host in the connection pool. Connections
119
- # beyond this limit will be closed immediately after use.
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] Total maximum size of the connection
122
- # pool across all hosts. Once reached, new requests may need to wait
123
- # for existing connections to become available.
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 SOCKS5 proxies. Format: "protocol://host:port"
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
@@ -267,6 +267,9 @@ module Wreq
267
267
  # for HTTP/2 and automatic default headers. The actual implementation is
268
268
  # provided by Rust.
269
269
  #
270
+ # Profiles configure TLS over TCP, HTTP/2 and request headers. They do not
271
+ # configure HTTP/3 or QUIC fingerprints; HTTP/3 uses the backend defaults.
272
+ #
270
273
  # Construction generates the native configuration once. For Chrome 152/153,
271
274
  # the TLS trust_anchors extension's ID order is randomized at construction;
272
275
  # Chrome 154 and later sort those IDs by their raw bytes instead. Reusing this object
@@ -42,7 +42,7 @@ module Wreq
42
42
 
43
43
  # Value-based equality. Returns true when both represent the same HTTP method.
44
44
  # @param other [Object]
45
- # @return [Boolean]
45
+ # @return [Boolean]
46
46
  unless method_defined?(:==)
47
47
  def ==(other)
48
48
  end
@@ -77,7 +77,14 @@ module Wreq
77
77
  HTTP_10 = nil # @return [Wreq::Version] HTTP/1.0
78
78
  HTTP_11 = nil # @return [Wreq::Version] HTTP/1.1
79
79
  HTTP_2 = nil # @return [Wreq::Version] HTTP/2
80
- HTTP_3 = nil # @return [Wreq::Version] HTTP/3
80
+ # Select HTTP/3 over QUIC with `version: Wreq::Version::HTTP_3` on a request.
81
+ # To use it by default, construct a client with `http3_only: true` instead.
82
+ # Requires an HTTPS URL and a reachable UDP endpoint. There is no automatic
83
+ # Alt-Svc discovery or fallback to HTTP/1.1 or HTTP/2.
84
+ # HTTP CONNECT proxies cannot carry these requests; use a direct connection,
85
+ # a SOCKS5 UDP relay or a `quic://` MASQUE proxy.
86
+ # @return [Wreq::Version] HTTP/3
87
+ HTTP_3 = nil
81
88
  end
82
89
 
83
90
  # Returns a string representation of the HTTP version.