wreq 1.3.2.2 → 1.3.2.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +10 -10
  3. data/Cargo.toml +2 -2
  4. data/README.md +11 -4
  5. data/VERSION +1 -1
  6. data/crates/wreq-util/src/emulate/macros.rs +31 -197
  7. data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +731 -0
  8. data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +418 -0
  9. data/crates/wreq-util/src/emulate/profile/chromium/header.rs +74 -0
  10. data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +59 -0
  11. data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +312 -0
  12. data/crates/wreq-util/src/emulate/profile/{chrome → chromium}/tls.rs +146 -137
  13. data/crates/wreq-util/src/emulate/profile/chromium.rs +9 -0
  14. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +48 -54
  15. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +92 -102
  16. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +155 -146
  17. data/crates/wreq-util/src/emulate/profile/firefox.rs +312 -440
  18. data/crates/wreq-util/src/emulate/profile.rs +5 -7
  19. data/crates/wreq-util/src/emulate.rs +33 -1
  20. data/crates/wreq-util/tests/client.rs +187 -46
  21. data/crates/wreq-util/tests/emulate_chrome.rs +7 -0
  22. data/crates/wreq-util/tests/emulate_firefox.rs +15 -0
  23. data/crates/wreq-util/tests/emulate_opera.rs +24 -0
  24. data/lib/wreq_ruby/emulate.rb +27 -0
  25. data/src/emulate.rs +27 -0
  26. data/test/emulation_client_hello_test.rb +142 -0
  27. data/test/emulation_test.rb +21 -105
  28. metadata +9 -9
  29. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +0 -116
  30. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +0 -65
  31. data/crates/wreq-util/src/emulate/profile/chrome.rs +0 -2304
  32. data/crates/wreq-util/src/emulate/profile/opera/header.rs +0 -29
  33. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +0 -50
  34. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +0 -103
  35. data/crates/wreq-util/src/emulate/profile/opera.rs +0 -299
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83b9e661912eab9beba7aeb3168ee6c90382574aa0c000a5a77910dc2c0ef473
4
- data.tar.gz: 3374b9628173dfdcf4ad1c425d06563039a87888e2e64ebf500b30238c45eadc
3
+ metadata.gz: cc190acbbd70c1403c163513ddb2f581ad545fda507b8cf883d61b5788de548d
4
+ data.tar.gz: 976514bd19cc1fa386219ab267e1cc2b219e6c0b38f09d91d9d559e7013bf27d
5
5
  SHA512:
6
- metadata.gz: 07605b1c3a078167a403c09a3a1989cfc1cfd3f83b386934b09b8b10a8577814b3178d7fe80974bd93ca5c7400f301713e6c882a32328fa0523e7de29d1a6788
7
- data.tar.gz: b3473b6442025a140c8150ba66189ec0f5f07238a67668735244ee874bc710672ce4fe63bbf0b1bdbe2f16a6c9b20485a885384b916de1de438e2fe40f3d90ac
6
+ metadata.gz: be30774979b7bb61ab6dd1b12a76013566fd967e41a62060075f6058b4dcfb7975caa3b310e2b55e99cfc194b6bd1645d7938939b71b3a450e931153f0c49a9a
7
+ data.tar.gz: 7b9d1d54f1b736c39e0c5122f01e77965d4d2972ee8555185782e96dd608ddf0d6f82d1869533c941a6f81e129e14080be086984d1bbc9d354a2f4d406ef3cfc
data/Cargo.lock CHANGED
@@ -699,9 +699,9 @@ dependencies = [
699
699
 
700
700
  [[package]]
701
701
  name = "magnus"
702
- version = "0.8.2"
702
+ version = "0.9.4"
703
703
  source = "registry+https://github.com/rust-lang/crates.io-index"
704
- checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
704
+ checksum = "3c5f2dd2017d172e2fde9969a35f10f1374a4dd79b37a17f1847f83201883de7"
705
705
  dependencies = [
706
706
  "bytes",
707
707
  "magnus-macros",
@@ -712,9 +712,9 @@ dependencies = [
712
712
 
713
713
  [[package]]
714
714
  name = "magnus-macros"
715
- version = "0.8.0"
715
+ version = "0.9.1"
716
716
  source = "registry+https://github.com/rust-lang/crates.io-index"
717
- checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
717
+ checksum = "9dafde2eeb66f090e0f326112323eb8324b12cb32b5d1210e541d3df6b0ce77e"
718
718
  dependencies = [
719
719
  "proc-macro2",
720
720
  "quote",
@@ -888,18 +888,18 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
888
888
 
889
889
  [[package]]
890
890
  name = "rb-sys"
891
- version = "0.9.128"
891
+ version = "0.9.130"
892
892
  source = "registry+https://github.com/rust-lang/crates.io-index"
893
- checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
893
+ checksum = "02faf625bb10ba893e3ae620f19c9fb1b5f8fcae0fe4eb86bb3f2230fad75edb"
894
894
  dependencies = [
895
895
  "rb-sys-build",
896
896
  ]
897
897
 
898
898
  [[package]]
899
899
  name = "rb-sys-build"
900
- version = "0.9.128"
900
+ version = "0.9.130"
901
901
  source = "registry+https://github.com/rust-lang/crates.io-index"
902
- checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
902
+ checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
903
903
  dependencies = [
904
904
  "bindgen 0.72.1",
905
905
  "lazy_static",
@@ -1229,9 +1229,9 @@ dependencies = [
1229
1229
 
1230
1230
  [[package]]
1231
1231
  name = "tokio"
1232
- version = "1.53.1"
1232
+ version = "1.54.1"
1233
1233
  source = "registry+https://github.com/rust-lang/crates.io-index"
1234
- checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
1234
+ checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
1235
1235
  dependencies = [
1236
1236
  "bytes",
1237
1237
  "libc",
data/Cargo.toml CHANGED
@@ -14,7 +14,7 @@ doc = false
14
14
  name = "wreq_ruby"
15
15
 
16
16
  [dependencies]
17
- magnus = { version = "0.8.2", features = ["bytes"] }
17
+ magnus = { version = "0.9.0", features = ["bytes"] }
18
18
  rb-sys = { version = "0.9.128", default-features = false }
19
19
  tokio = { version = "1.53.1", features = ["full"] }
20
20
  # Keep the existing trust store independent of wreq's default feature selection.
@@ -54,7 +54,7 @@ futures-util = { version = "0.3.33", default-features = false }
54
54
  forkguard = { version = "0.1.3", features = ["atfork"] }
55
55
 
56
56
  [dev-dependencies]
57
- magnus = { version = "0.8.2", features = ["embed"] }
57
+ magnus = { version = "0.9.0", features = ["embed"] }
58
58
 
59
59
  [build-dependencies]
60
60
  rb-sys-env = "0.2.2"
data/README.md CHANGED
@@ -89,14 +89,21 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ
89
89
  - <details>
90
90
  <summary>Available browser emulations</summary>
91
91
 
92
+ Edge 149–158 provide request-header presets for Windows, macOS, Linux, Android, and iOS.
93
+ Firefox 153–160 provide Android and iPhone presets for `User-Agent` and `Accept-Language`.
94
+ Both use the same TLS and HTTP/2 settings as the corresponding desktop Firefox preset.
95
+ Opera 116–140 provide desktop request-header presets for Windows, macOS, and Linux.
96
+
92
97
  | **Browser** | **Versions** |
93
98
  | ----------- | ------------ |
94
99
  | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156`, `Chrome157`, `Chrome158` |
95
- | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` |
96
- | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` |
100
+ | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`–`Edge158` |
101
+ | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152`, `Firefox153`–`Firefox160` |
97
102
  | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` |
98
- | **OkHttp** | `Opera116`, `Opera117`, `Opera118`, `Opera119`, `Opera120`, `Opera121`, `Opera122`, `Opera123`, `Opera124`, `Opera125`, `Opera126`, `Opera127`, `Opera128`, `Opera129`, `Opera130` |
99
- | **Opera** | `Opera116`, `Opera117`, `Opera118`, `Opera119` |
103
+ | **OkHttp** | `OkHttp3_9`, `OkHttp3_11`, `OkHttp3_13`, `OkHttp3_14`, `OkHttp4_9`, `OkHttp4_10`, `OkHttp4_12`, `OkHttp5` |
104
+ | **Opera** | `Opera116`–`Opera140` |
105
+
106
+ Opera 132–140 use the corresponding Chromium desktop TLS and HTTP/2 defaults with Opera-branded request headers.
100
107
 
101
108
  </details>
102
109
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2.2
1
+ 1.3.2.3
@@ -84,103 +84,6 @@ macro_rules! define_enum {
84
84
  };
85
85
  }
86
86
 
87
- macro_rules! header_chrome_sec_ch_ua {
88
- ($headers:expr, $ua:expr, $platform:expr, $is_mobile:expr) => {
89
- let mobile = if $is_mobile { "?1" } else { "?0" };
90
- $headers.insert("sec-ch-ua", HeaderValue::from_static($ua));
91
- $headers.insert("sec-ch-ua-mobile", HeaderValue::from_static(mobile));
92
- $headers.insert("sec-ch-ua-platform", HeaderValue::from_static($platform));
93
- };
94
- }
95
-
96
- macro_rules! header_chrome_sec_fetch {
97
- ($headers:expr) => {
98
- $headers.insert("sec-fetch-site", HeaderValue::from_static("none"));
99
- $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate"));
100
- $headers.insert("sec-fetch-user", HeaderValue::from_static("?1"));
101
- $headers.insert("sec-fetch-dest", HeaderValue::from_static("document"));
102
- };
103
- }
104
-
105
- macro_rules! header_chrome_ua {
106
- ($headers:expr, $ua:expr) => {
107
- $headers.insert(USER_AGENT, HeaderValue::from_static($ua));
108
- };
109
- }
110
-
111
- macro_rules! header_chrome_accept {
112
- ($headers:expr) => {
113
- $headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"));
114
- };
115
- }
116
-
117
- macro_rules! header_chrome_accept_encoding {
118
- ($headers:expr) => {
119
- #[cfg(feature = "emulation-compression")]
120
- $headers.insert(
121
- ACCEPT_ENCODING,
122
- HeaderValue::from_static("gzip, deflate, br"),
123
- );
124
- $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
125
- };
126
- (zstd, $headers:expr) => {
127
- #[cfg(feature = "emulation-compression")]
128
- $headers.insert(
129
- ACCEPT_ENCODING,
130
- HeaderValue::from_static("gzip, deflate, br, zstd"),
131
- );
132
- $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
133
- };
134
- (zstd_only, $headers:expr) => {
135
- #[cfg(feature = "emulation-compression")]
136
- $headers.insert(
137
- ACCEPT_ENCODING,
138
- HeaderValue::from_static("gzip, deflate, br, zstd"),
139
- );
140
- };
141
- }
142
-
143
- macro_rules! header_firefox_sec_fetch {
144
- ($headers:expr) => {
145
- $headers.insert("sec-fetch-dest", HeaderValue::from_static("document"));
146
- $headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate"));
147
- $headers.insert("sec-fetch-site", HeaderValue::from_static("none"));
148
- $headers.insert("sec-fetch-user", HeaderValue::from_static("?1"));
149
- };
150
- }
151
-
152
- macro_rules! header_firefox_accept {
153
- ($headers:expr) => {
154
- header_firefox_accept!(@build $headers, "en-US,en;q=0.5", "gzip, deflate, br");
155
- };
156
- (zstd, $headers:expr) => {
157
- header_firefox_accept!(@build $headers, "en-US,en;q=0.5", "gzip, deflate, br, zstd");
158
- };
159
- // Firefox 147 changed the generated q-value from dividing 1.0 across the list to
160
- // decrementing by 0.1 per entry, so a two-entry list became q=0.9 (Bugzilla 2000765,
161
- // landed in 0e050ae5116d).
162
- (zstd_q09, $headers:expr) => {
163
- header_firefox_accept!(@build $headers, "en-US,en;q=0.9", "gzip, deflate, br, zstd");
164
- };
165
- (@build $headers:expr, $accept_language:expr, $accept_encoding:expr) => {
166
- $headers.insert(
167
- ACCEPT,
168
- HeaderValue::from_static(
169
- "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
170
- ),
171
- );
172
- $headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static($accept_language));
173
- #[cfg(feature = "emulation-compression")]
174
- $headers.insert(ACCEPT_ENCODING, HeaderValue::from_static($accept_encoding));
175
- };
176
- }
177
-
178
- macro_rules! header_firefox_ua {
179
- ($headers:expr, $ua:expr) => {
180
- $headers.insert(USER_AGENT, HeaderValue::from_static($ua));
181
- };
182
- }
183
-
184
87
  macro_rules! join {
185
88
  ($sep:expr, $first:expr $(, $rest:expr)*) => {
186
89
  concat!($first $(, $sep, $rest)*)
@@ -231,84 +134,22 @@ macro_rules! fixed_headers {
231
134
  macro_rules! platform_headers {
232
135
  (
233
136
  $emulation:expr,
234
- $header_initializer:ident,
235
- [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*]
137
+ $header_preset:path,
138
+ $brands:literal,
139
+ [($default_os:ident, $default_ua:literal) $(, ($other_os:ident, $other_ua:literal))* $(,)?]
236
140
  ) => {{
237
141
  #[allow(unreachable_patterns)]
238
142
  $emulation.headers.then(|| {
239
- match $emulation.platform {
240
- $(
241
- Platform::$other_os => $header_initializer(
242
- $other_sec_ch_ua,
243
- $other_ua,
244
- $emulation.platform,
245
- ),
246
- )*
247
- _ => $header_initializer(
248
- $default_sec_ch_ua,
249
- $default_ua,
250
- Platform::$default_os,
251
- ),
252
- }
253
- })
254
- }};
255
- }
256
-
257
- macro_rules! firefox_platform_headers {
258
- ($emulation:expr, $header_initializer:ident, [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*]) => {{
259
- #[allow(unreachable_patterns)]
260
- $emulation.headers.then(|| {
261
- match $emulation.platform {
262
- $(
263
- Platform::$other_os => $header_initializer($other_ua),
264
- )*
265
- _ => $header_initializer($default_ua),
266
- }
143
+ let (ua, platform) = match $emulation.platform {
144
+ $( Platform::$other_os => ($other_ua, Platform::$other_os), )*
145
+ _ => ($default_ua, Platform::$default_os),
146
+ };
147
+ ($header_preset).build($brands, ua, platform)
267
148
  })
268
149
  }};
269
150
  }
270
151
 
271
152
  macro_rules! mod_generator {
272
- (
273
- $mod_name:ident,
274
- $tls_options:expr,
275
- $http2_options:expr,
276
- $header_initializer:ident,
277
- [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*]
278
- ) => {
279
- standard_mod_generator!(
280
- $mod_name,
281
- $tls_options,
282
- $http2_options,
283
- |emulation: &Emulation| {
284
- platform_headers!(
285
- emulation,
286
- $header_initializer,
287
- [($default_os, $default_sec_ch_ua, $default_ua) $(, ($other_os, $other_sec_ch_ua, $other_ua))*]
288
- )
289
- }
290
- );
291
- };
292
- (
293
- $mod_name:ident,
294
- $tls_options:expr,
295
- $http2_options:expr,
296
- $header_initializer:ident,
297
- [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*]
298
- ) => {
299
- standard_mod_generator!(
300
- $mod_name,
301
- $tls_options,
302
- $http2_options,
303
- |emulation: &Emulation| {
304
- firefox_platform_headers!(
305
- emulation,
306
- $header_initializer,
307
- [($default_os, $default_ua) $(, ($other_os, $other_ua))*]
308
- )
309
- }
310
- );
311
- };
312
153
  (
313
154
  $mod_name:ident,
314
155
  $tls_options:expr,
@@ -327,48 +168,41 @@ macro_rules! mod_generator {
327
168
  $mod_name:ident,
328
169
  $build_emulation:expr,
329
170
  $header_initializer:ident,
330
- [($default_os:ident, $default_sec_ch_ua:tt, $default_ua:tt) $(, ($other_os:ident, $other_sec_ch_ua:tt, $other_ua:tt))*]
171
+ $ua:expr
331
172
  ) => {
332
173
  standard_mod_generator!(
333
174
  $mod_name,
334
175
  $build_emulation,
335
- |emulation: &Emulation| {
336
- platform_headers!(
337
- emulation,
338
- $header_initializer,
339
- [($default_os, $default_sec_ch_ua, $default_ua) $(, ($other_os, $other_sec_ch_ua, $other_ua))*]
340
- )
341
- }
176
+ |emulation: &Emulation| fixed_headers!(emulation, $header_initializer, $ua)
342
177
  );
343
178
  };
179
+ }
180
+
181
+ macro_rules! chromium_profile {
344
182
  (
345
- $mod_name:ident,
346
- $build_emulation:expr,
347
- $header_initializer:ident,
348
- [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, $other_ua:tt))*]
183
+ $name:ident,
184
+ tls: $tls:path,
185
+ http2: $http2:path,
186
+ headers: $headers:path,
187
+ brands: $brands:literal,
188
+ $platforms:tt $(,)?
349
189
  ) => {
350
190
  standard_mod_generator!(
351
- $mod_name,
352
- $build_emulation,
353
- |emulation: &Emulation| {
354
- firefox_platform_headers!(
355
- emulation,
356
- $header_initializer,
357
- [($default_os, $default_ua) $(, ($other_os, $other_ua))*]
358
- )
359
- }
191
+ $name,
192
+ ($tls).build(),
193
+ ($http2).build(),
194
+ |emulation: &Emulation| platform_headers!(emulation, $headers, $brands, $platforms)
360
195
  );
361
196
  };
362
197
  (
363
- $mod_name:ident,
364
- $build_emulation:expr,
365
- $header_initializer:ident,
366
- $ua:expr
198
+ $name:ident,
199
+ transport: $transport:path,
200
+ headers: $headers:path,
201
+ brands: $brands:literal,
202
+ $platforms:tt $(,)?
367
203
  ) => {
368
- standard_mod_generator!(
369
- $mod_name,
370
- $build_emulation,
371
- |emulation: &Emulation| fixed_headers!(emulation, $header_initializer, $ua)
372
- );
204
+ standard_mod_generator!($name, $transport, |emulation: &Emulation| {
205
+ platform_headers!(emulation, $headers, $brands, $platforms)
206
+ });
373
207
  };
374
208
  }