wreq 1.3.2.4 → 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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +470 -50
  3. data/Cargo.toml +19 -16
  4. data/README.md +5 -12
  5. data/Rakefile +3 -9
  6. data/crates/wreq-util/Cargo.toml +1 -1
  7. data/crates/wreq-util/README.md +4 -2
  8. data/crates/wreq-util/examples/emulate.rs +7 -3
  9. data/crates/wreq-util/examples/tower_delay.rs +4 -4
  10. data/crates/wreq-util/src/emulate/macros.rs +197 -32
  11. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +116 -0
  12. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +65 -0
  13. data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +268 -0
  14. data/crates/wreq-util/src/emulate/profile/chrome.rs +2269 -0
  15. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +54 -48
  16. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +102 -92
  17. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +146 -155
  18. data/crates/wreq-util/src/emulate/profile/firefox.rs +440 -312
  19. data/crates/wreq-util/src/emulate/profile/okhttp.rs +2 -3
  20. data/crates/wreq-util/src/emulate/profile/opera/header.rs +29 -0
  21. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +50 -0
  22. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +103 -0
  23. data/crates/wreq-util/src/emulate/profile/opera.rs +299 -0
  24. data/crates/wreq-util/src/emulate/profile.rs +10 -10
  25. data/crates/wreq-util/src/emulate.rs +1 -34
  26. data/crates/wreq-util/src/tower/delay/layer.rs +5 -5
  27. data/crates/wreq-util/src/tower/delay.rs +4 -4
  28. data/crates/wreq-util/tests/client.rs +50 -187
  29. data/crates/wreq-util/tests/emulate_chrome.rs +0 -17
  30. data/crates/wreq-util/tests/emulate_firefox.rs +26 -36
  31. data/crates/wreq-util/tests/emulate_opera.rs +0 -24
  32. data/crates/wreq-util/tests/support/mod.rs +1 -1
  33. data/lib/wreq_ruby/client.rb +27 -13
  34. data/lib/wreq_ruby/emulate.rb +3 -28
  35. data/lib/wreq_ruby/http.rb +9 -2
  36. data/src/client/body/json.rs +1 -2
  37. data/src/client/resp.rs +1 -1
  38. data/src/client.rs +8 -4
  39. data/src/emulate.rs +5 -28
  40. data/src/error.rs +23 -3
  41. data/src/lib.rs +3 -2
  42. data/src/options.rs +17 -19
  43. data/{crates/serde-magnus/src → src/serde}/de/array_deserializer.rs +2 -2
  44. data/{crates/serde-magnus/src → src/serde}/de/array_enumerator.rs +1 -1
  45. data/{crates/serde-magnus/src → src/serde}/de/deserializer.rs +31 -25
  46. data/{crates/serde-magnus/src → src/serde}/de/enum_deserializer.rs +3 -3
  47. data/{crates/serde-magnus/src → src/serde}/de/hash_deserializer.rs +2 -2
  48. data/{crates/serde-magnus/src → src/serde}/de/number_deserializer.rs +2 -2
  49. data/{crates/serde-magnus/src → src/serde}/de/variant_deserializer.rs +20 -11
  50. data/src/serde/de.rs +33 -0
  51. data/src/serde/error.rs +146 -0
  52. data/src/serde/ser/enums.rs +14 -0
  53. data/{crates/serde-magnus/src → src/serde}/ser/map_serializer.rs +2 -2
  54. data/src/serde/ser/seq_serializer.rs +71 -0
  55. data/src/serde/ser/serializer.rs +194 -0
  56. data/{crates/serde-magnus/src → src/serde}/ser/struct_serializer.rs +4 -4
  57. data/src/serde/ser/struct_variant_serializer.rs +44 -0
  58. data/src/serde/ser/tuple_variant_serializer.rs +41 -0
  59. data/src/serde/ser.rs +18 -0
  60. data/{crates/serde-magnus/src → src/serde}/tests.rs +68 -19
  61. data/src/serde.rs +202 -0
  62. data/test/emulation_test.rb +104 -21
  63. data/test/option_validation_test.rb +13 -4
  64. data/wreq.gemspec +15 -3
  65. metadata +29 -35
  66. data/VERSION +0 -1
  67. data/crates/README.md +0 -6
  68. data/crates/serde-magnus/Cargo.toml +0 -29
  69. data/crates/serde-magnus/LICENSE +0 -19
  70. data/crates/serde-magnus/README.md +0 -147
  71. data/crates/serde-magnus/src/de/mod.rs +0 -554
  72. data/crates/serde-magnus/src/error.rs +0 -84
  73. data/crates/serde-magnus/src/lib.rs +0 -137
  74. data/crates/serde-magnus/src/options.rs +0 -151
  75. data/crates/serde-magnus/src/ser/enums.rs +0 -11
  76. data/crates/serde-magnus/src/ser/mod.rs +0 -428
  77. data/crates/serde-magnus/src/ser/seq_serializer.rs +0 -68
  78. data/crates/serde-magnus/src/ser/serializer.rs +0 -220
  79. data/crates/serde-magnus/src/ser/struct_variant_serializer.rs +0 -45
  80. data/crates/serde-magnus/src/ser/tuple_variant_serializer.rs +0 -38
  81. data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +0 -731
  82. data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +0 -418
  83. data/crates/wreq-util/src/emulate/profile/chromium/header.rs +0 -74
  84. data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +0 -59
  85. data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +0 -312
  86. data/crates/wreq-util/src/emulate/profile/chromium/tls.rs +0 -310
  87. data/crates/wreq-util/src/emulate/profile/chromium.rs +0 -9
  88. data/test/emulation_client_hello_test.rb +0 -142
@@ -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>(())
@@ -66,6 +66,9 @@ fn check_header_order<'a>(
66
66
  previous = Some(position);
67
67
  }
68
68
 
69
+ assert!(request.contains("\r\nupgrade-insecure-requests: 1\r\n"));
70
+ assert!(request.contains("\r\nsec-fetch-user: ?1\r\n"));
71
+
69
72
  stream
70
73
  .write_all(b"HTTP/1.1 200 OK\r\ncontent-length: 0\r\nconnection: close\r\n\r\n")
71
74
  .await
@@ -73,216 +76,76 @@ fn check_header_order<'a>(
73
76
  })
74
77
  }
75
78
 
76
- async fn assert_emulation_headers(
77
- emulation: impl wreq::IntoEmulation,
78
- expected: &'static [&'static str],
79
- ) {
79
+ async fn assert_emulation_headers(profile: Profile, expected: &'static [&'static str]) {
80
80
  let server = server::low_level_with_response(move |request, stream| {
81
81
  check_header_order(request, stream, expected)
82
82
  });
83
- Client::builder()
84
- .emulation(emulation)
85
- .no_proxy()
83
+ let response = Client::builder_tokio()
84
+ .emulation(profile)
86
85
  .build()
87
86
  .expect("client")
88
87
  .get(format!("http://{}/headers", server.addr()))
89
88
  .send()
90
89
  .await
91
90
  .expect("request");
92
- }
93
-
94
- #[tokio::test]
95
- async fn test_edge158_mobile_headers() {
96
- for (platform, platform_hint, user_agent) in [
97
- (
98
- Platform::Android,
99
- "\"Android\"",
100
- "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Mobile Safari/537.36 EdgA/158.0.0.0",
101
- ),
102
- (
103
- Platform::IOS,
104
- "\"iOS\"",
105
- "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 EdgiOS/158.0.0.0 Mobile/15E148 Safari/605.1.15",
106
- ),
107
- ] {
108
- let server = server::http(move |request| async move {
109
- let headers = request.headers();
110
- assert_eq!(headers["user-agent"], user_agent);
111
- assert_eq!(headers["sec-ch-ua-platform"], platform_hint);
112
- assert_eq!(headers["sec-ch-ua-mobile"], "?1");
113
- if platform == Platform::Android {
114
- assert!(!headers["accept"].to_str().unwrap().contains("image/jxl"));
115
- }
116
- http::Response::default()
117
- });
118
91
 
119
- Client::builder()
120
- .emulation(
121
- Emulation::builder()
122
- .profile(Emulation::Edge158)
123
- .platform(platform)
124
- .build(),
125
- )
126
- .no_proxy()
127
- .build()
128
- .unwrap()
129
- .get(format!("http://{}/", server.addr()))
130
- .send()
131
- .await
132
- .unwrap();
133
- }
92
+ assert_eq!(response.status(), wreq::StatusCode::OK);
134
93
  }
135
94
 
136
95
  #[tokio::test]
137
- async fn test_linux_navigation_emulation_headers() {
138
- let linux = |profile| {
139
- Emulation::builder()
140
- .profile(profile)
141
- .platform(Platform::Linux)
142
- .build()
143
- };
144
- assert_emulation_headers(linux(Profile::Chrome152), CHROMIUM_HEADER_ORDER).await;
96
+ async fn test_client_emulation_device() {
97
+ let server = server::http(move |req| async move {
98
+ let header = |name| {
99
+ req.headers()
100
+ .get(name)
101
+ .and_then(|value| value.to_str().ok())
102
+ };
145
103
 
146
- let server = server::http(|request| async move {
147
- assert_eq!(request.version(), http::Version::HTTP_2);
148
- let mut response = http::Response::default();
149
- response
150
- .headers_mut()
151
- .insert("user-agent", request.headers()["user-agent"].clone());
152
- response
104
+ assert_eq!(
105
+ header("user-agent"),
106
+ Some(
107
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36"
108
+ )
109
+ );
110
+ assert_eq!(
111
+ header("sec-ch-ua"),
112
+ Some(r#""Not=A?Brand";v="99", "Google Chrome";v="151", "Chromium";v="151""#)
113
+ );
114
+ assert_eq!(header("sec-ch-ua-mobile"), Some("?0"));
115
+ assert_eq!(header("sec-ch-ua-platform"), Some("\"Linux\""));
116
+ http::Response::default()
153
117
  });
154
- let client = Client::builder()
155
- .http2_only()
156
- .no_proxy()
118
+
119
+ let url = format!("http://{}/ua", server.addr());
120
+ let res = Client::builder_tokio()
121
+ .emulation(
122
+ Emulation::builder()
123
+ .profile(Emulation::Chrome151)
124
+ .platform(Platform::Linux)
125
+ .http2(true)
126
+ .build(),
127
+ )
157
128
  .build()
158
- .expect("client");
159
- for (profile, major) in [
160
- (Profile::Firefox150, 150),
161
- (Profile::Firefox151, 151),
162
- (Profile::Firefox152, 152),
163
- ] {
164
- let response = client
165
- .get(format!("http://{}/headers", server.addr()))
166
- .emulation(linux(profile))
167
- .send()
168
- .await
169
- .expect("request");
170
- let expected = format!(
171
- "Mozilla/5.0 (X11; Linux x86_64; rv:{major}.0) Gecko/20100101 Firefox/{major}.0"
172
- );
173
- assert_eq!(response.headers()["user-agent"], expected, "{profile:?}");
174
- }
129
+ .expect("Unable to build client")
130
+ .get(&url)
131
+ .send()
132
+ .await
133
+ .expect("request");
134
+
135
+ assert_eq!(res.status(), wreq::StatusCode::OK);
175
136
  }
176
137
 
177
138
  #[tokio::test]
178
- async fn test_firefox_default_header_order() {
179
- assert_emulation_headers(Emulation::Firefox109, FIREFOX_HEADER_ORDER).await;
139
+ async fn test_chrome_default_header_order() {
140
+ assert_emulation_headers(Emulation::Chrome133, CHROMIUM_HEADER_ORDER).await;
180
141
  }
181
142
 
182
143
  #[tokio::test]
183
- async fn test_firefox_mobile_headers() {
184
- let server = server::http(|request| async move {
185
- let mut response = http::Response::default();
186
- for name in ["user-agent", "accept-language"] {
187
- response
188
- .headers_mut()
189
- .insert(name, request.headers()[name].clone());
190
- }
191
- response
192
- });
193
- let client = Client::builder()
194
- .http2_only()
195
- .no_proxy()
196
- .build()
197
- .expect("client");
198
-
199
- for (profile, platform, user_agent, language) in [
200
- (
201
- Profile::Firefox160,
202
- Platform::Android,
203
- "Mozilla/5.0 (Android 16; Mobile; rv:160.0) Gecko/160.0 Firefox/160.0",
204
- "en-US",
205
- ),
206
- (
207
- Profile::Firefox153,
208
- Platform::IOS,
209
- "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/153.3 Mobile/15E148 Safari/604.1",
210
- "en-US,en;q=0.9",
211
- ),
212
- ] {
213
- let response = client
214
- .get(format!("http://{}/headers", server.addr()))
215
- .emulation(
216
- Emulation::builder()
217
- .profile(profile)
218
- .platform(platform)
219
- .build(),
220
- )
221
- .send()
222
- .await
223
- .expect("request");
224
- assert_eq!(response.headers()["user-agent"], user_agent, "{profile:?}");
225
- assert_eq!(
226
- response.headers()["accept-language"],
227
- language,
228
- "{profile:?}"
229
- );
230
- }
144
+ async fn test_firefox_default_header_order() {
145
+ assert_emulation_headers(Emulation::Firefox109, FIREFOX_HEADER_ORDER).await;
231
146
  }
232
147
 
233
148
  #[tokio::test]
234
- async fn test_opera_linux_headers() {
235
- for (profile, expected_user_agent) in [
236
- (
237
- Emulation::Opera138,
238
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0",
239
- ),
240
- (
241
- Emulation::Opera139,
242
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0",
243
- ),
244
- (
245
- Emulation::Opera140,
246
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0",
247
- ),
248
- ] {
249
- let server = server::http(move |request| async move {
250
- assert_eq!(request.version(), http::Version::HTTP_2);
251
- assert_eq!(
252
- request.headers()["user-agent"],
253
- expected_user_agent,
254
- "{profile:?}"
255
- );
256
- assert_eq!(
257
- request.headers()["sec-ch-ua-platform"],
258
- "\"Linux\"",
259
- "{profile:?}"
260
- );
261
- if profile == Profile::Opera140 {
262
- assert!(
263
- request.headers()["accept"]
264
- .to_str()
265
- .unwrap()
266
- .contains("image/jxl,image/avif")
267
- );
268
- }
269
- http::Response::default()
270
- });
271
-
272
- Client::builder()
273
- .emulation(
274
- Emulation::builder()
275
- .profile(profile)
276
- .platform(Platform::Linux)
277
- .build(),
278
- )
279
- .http2_only()
280
- .no_proxy()
281
- .build()
282
- .expect("client")
283
- .get(format!("http://{}/", server.addr()))
284
- .send()
285
- .await
286
- .expect("request");
287
- }
149
+ async fn test_opera_default_header_order() {
150
+ assert_emulation_headers(Emulation::Opera116, CHROMIUM_HEADER_ORDER).await;
288
151
  }
@@ -335,20 +335,3 @@ test_emulation!(
335
335
  ],
336
336
  "52d84b11737d980aef856699f885ca86"
337
337
  );
338
-
339
- test_emulation!(
340
- test_chrome158,
341
- Emulation::Chrome158,
342
- [
343
- "t13d1517h2_8daaf6152771_cb7bf5808d99",
344
- "t13d1518h2_8daaf6152771_e2d80978ab2e"
345
- ],
346
- "52d84b11737d980aef856699f885ca86"
347
- );
348
-
349
- test_emulation!(
350
- test_edge158,
351
- Emulation::Edge158,
352
- ["t13d1516h2_8daaf6152771_806a8c22fdea"],
353
- "52d84b11737d980aef856699f885ca86"
354
- );
@@ -112,22 +112,14 @@ test_emulation!(
112
112
  "6ea73faa8fc5aac76bded7bd238f6433"
113
113
  );
114
114
 
115
- test_emulation!(
116
- test_firefox_160,
117
- Emulation::Firefox160,
118
- ["t13d1517h2_8daaf6152771_3cbfd9057e0d"],
119
- "6ea73faa8fc5aac76bded7bd238f6433"
120
- );
121
-
122
115
  /// Firefox 147 changed the generated `Accept-Language` q-value: the list used to divide 1.0
123
116
  /// across its entries, giving `q=0.5` for two, and now decrements by 0.1 per entry, giving
124
117
  /// `q=0.9`. See Bugzilla 2000765, landed in mozilla-firefox 0e050ae5116d.
125
118
  ///
126
119
  /// Every profile is listed rather than a range, so adding one is a deliberate choice about
127
120
  /// which side of 147 it falls on.
128
- #[test]
129
- fn firefox_accept_language_matches_the_profile_version() {
130
- use wreq::IntoEmulation;
121
+ #[tokio::test]
122
+ async fn firefox_accept_language_matches_the_profile_version() {
131
123
  use wreq_util::{Platform, Profile};
132
124
 
133
125
  const PRE_147: &[(&str, Profile)] = &[
@@ -154,33 +146,31 @@ fn firefox_accept_language_matches_the_profile_version() {
154
146
  ("Firefox150", Emulation::Firefox150),
155
147
  ("Firefox151", Emulation::Firefox151),
156
148
  ("Firefox152", Emulation::Firefox152),
157
- ("Firefox153", Emulation::Firefox153),
158
- ("Firefox154", Emulation::Firefox154),
159
- ("Firefox155", Emulation::Firefox155),
160
- ("Firefox156", Emulation::Firefox156),
161
- ("Firefox157", Emulation::Firefox157),
162
- ("Firefox158", Emulation::Firefox158),
163
- ("Firefox159", Emulation::Firefox159),
164
- ("Firefox160", Emulation::Firefox160),
165
149
  ];
166
150
 
167
- fn accept_language(profile: Profile) -> String {
168
- Emulation::builder()
169
- .profile(profile)
170
- .platform(Platform::Linux)
171
- .build()
172
- .into_emulation()
173
- .headers
174
- .get("accept-language")
175
- .and_then(|value| value.to_str().ok())
176
- .unwrap_or_default()
177
- .to_owned()
178
- }
179
-
180
- for (name, profile) in PRE_147 {
181
- assert_eq!("en-US,en;q=0.5", accept_language(*profile), "{name}");
182
- }
183
- for (name, profile) in POST_147 {
184
- 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
+ }
185
175
  }
186
176
  }
@@ -111,27 +111,3 @@ test_emulation!(
111
111
  ["t13d1516h2_8daaf6152771_02713d6af862"],
112
112
  "52d84b11737d980aef856699f885ca86"
113
113
  );
114
-
115
- test_emulation!(
116
- test_opera132,
117
- Emulation::Opera132,
118
- ["t13d1516h2_8daaf6152771_d8a2da3f94cd"],
119
- "52d84b11737d980aef856699f885ca86"
120
- );
121
-
122
- test_emulation!(
123
- test_opera134,
124
- Emulation::Opera134,
125
- ["t13d1516h2_8daaf6152771_806a8c22fdea"],
126
- "52d84b11737d980aef856699f885ca86"
127
- );
128
-
129
- test_emulation!(
130
- test_opera140,
131
- Emulation::Opera140,
132
- [
133
- "t13d1517h2_8daaf6152771_cb7bf5808d99",
134
- "t13d1518h2_8daaf6152771_e2d80978ab2e"
135
- ],
136
- "52d84b11737d980aef856699f885ca86"
137
- );
@@ -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
@@ -69,7 +69,6 @@ module Wreq
69
69
  Chrome155 = nil
70
70
  Chrome156 = nil
71
71
  Chrome157 = nil
72
- Chrome158 = nil
73
72
 
74
73
  Edge101 = nil
75
74
  Edge122 = nil
@@ -90,16 +89,6 @@ module Wreq
90
89
  Edge146 = nil
91
90
  Edge147 = nil
92
91
  Edge148 = nil
93
- Edge149 = nil
94
- Edge150 = nil
95
- Edge151 = nil
96
- Edge152 = nil
97
- Edge153 = nil
98
- Edge154 = nil
99
- Edge155 = nil
100
- Edge156 = nil
101
- Edge157 = nil
102
- Edge158 = nil
103
92
 
104
93
  Firefox109 = nil
105
94
  Firefox117 = nil
@@ -122,14 +111,6 @@ module Wreq
122
111
  Firefox150 = nil
123
112
  Firefox151 = nil
124
113
  Firefox152 = nil
125
- Firefox153 = nil
126
- Firefox154 = nil
127
- Firefox155 = nil
128
- Firefox156 = nil
129
- Firefox157 = nil
130
- Firefox158 = nil
131
- Firefox159 = nil
132
- Firefox160 = nil
133
114
 
134
115
  SafariIos17_2 = nil
135
116
  SafariIos17_4_1 = nil
@@ -186,15 +167,6 @@ module Wreq
186
167
  Opera129 = nil
187
168
  Opera130 = nil
188
169
  Opera131 = nil
189
- Opera132 = nil
190
- Opera133 = nil
191
- Opera134 = nil
192
- Opera135 = nil
193
- Opera136 = nil
194
- Opera137 = nil
195
- Opera138 = nil
196
- Opera139 = nil
197
- Opera140 = nil
198
170
  end
199
171
 
200
172
  unless method_defined?(:to_s)
@@ -295,6 +267,9 @@ module Wreq
295
267
  # for HTTP/2 and automatic default headers. The actual implementation is
296
268
  # provided by Rust.
297
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
+ #
298
273
  # Construction generates the native configuration once. For Chrome 152/153,
299
274
  # the TLS trust_anchors extension's ID order is randomized at construction;
300
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.
@@ -9,9 +9,8 @@
9
9
 
10
10
  use ::serde::{Deserialize, Serialize};
11
11
  use magnus::{Error, Ruby, TryConvert, Value};
12
- use serde_magnus::deserialize_json;
13
12
 
14
- use crate::error::json_serialization_error;
13
+ use crate::{error::json_serialization_error, serde::deserialize_json};
15
14
 
16
15
  /// An owned JSON tree shared by request and response conversion.
17
16
  ///
data/src/client/resp.rs CHANGED
@@ -262,7 +262,7 @@ impl Response {
262
262
  let response = rb_self.response(ruby, false)?;
263
263
  let json =
264
264
  rt::block_on(ruby, response.json::<Json>())?.map_err(|err| wreq_error(ruby, err))?;
265
- serde_magnus::serialize(ruby, &json)
265
+ crate::serde::serialize(ruby, &json)
266
266
  }
267
267
 
268
268
  /// Yield response body chunks to the given Ruby block.