wreq 1.3.2.1 → 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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +40 -52
  3. data/Cargo.toml +11 -8
  4. data/README.md +12 -5
  5. data/VERSION +1 -1
  6. data/crates/README.md +5 -0
  7. data/crates/wreq-util/Cargo.toml +1 -0
  8. data/crates/wreq-util/src/emulate/macros.rs +31 -197
  9. data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +731 -0
  10. data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +418 -0
  11. data/crates/wreq-util/src/emulate/profile/chromium/header.rs +74 -0
  12. data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +59 -0
  13. data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +312 -0
  14. data/crates/wreq-util/src/emulate/profile/{chrome → chromium}/tls.rs +146 -137
  15. data/crates/wreq-util/src/emulate/profile/chromium.rs +9 -0
  16. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +48 -54
  17. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +92 -102
  18. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +155 -146
  19. data/crates/wreq-util/src/emulate/profile/firefox.rs +312 -440
  20. data/crates/wreq-util/src/emulate/profile.rs +5 -7
  21. data/crates/wreq-util/src/emulate.rs +34 -1
  22. data/crates/wreq-util/tests/client.rs +187 -46
  23. data/crates/wreq-util/tests/emulate_chrome.rs +17 -0
  24. data/crates/wreq-util/tests/emulate_firefox.rs +15 -0
  25. data/crates/wreq-util/tests/emulate_opera.rs +24 -0
  26. data/lib/wreq_ruby/emulate.rb +28 -0
  27. data/src/emulate.rs +28 -5
  28. data/test/emulation_client_hello_test.rb +142 -0
  29. data/test/emulation_test.rb +21 -104
  30. data/wreq.gemspec +1 -1
  31. metadata +11 -10
  32. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +0 -116
  33. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +0 -65
  34. data/crates/wreq-util/src/emulate/profile/chrome.rs +0 -2269
  35. data/crates/wreq-util/src/emulate/profile/opera/header.rs +0 -29
  36. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +0 -50
  37. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +0 -103
  38. 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: 4904997a67f3a784ebec0a831167a66379a85701ebb53a44a5976c9ae461abb2
4
- data.tar.gz: 382fefd57517ab36bab824c3edae19f6d28c4fecbadfda2c4f125d6443f367cf
3
+ metadata.gz: cc190acbbd70c1403c163513ddb2f581ad545fda507b8cf883d61b5788de548d
4
+ data.tar.gz: 976514bd19cc1fa386219ab267e1cc2b219e6c0b38f09d91d9d559e7013bf27d
5
5
  SHA512:
6
- metadata.gz: 0d317290dc792e19064e2894bf9453dd8bb8a7c041276b2a40de24c35990778c6bf7e080e1e1596f2a866059e7f8b39f8bd532bbee078bfec4ac19662a25385e
7
- data.tar.gz: dab55c9ac1a4a8fa17c000b960fcbe5911fe26963971c0fd6ea2fad34e9103d9e2ed4e064023befde9856e2ab31450b9b7fd8aef694146cfdf438fa8f4bde524
6
+ metadata.gz: be30774979b7bb61ab6dd1b12a76013566fd967e41a62060075f6058b4dcfb7975caa3b310e2b55e99cfc194b6bd1645d7938939b71b3a450e931153f0c49a9a
7
+ data.tar.gz: 7b9d1d54f1b736c39e0c5122f01e77965d4d2972ee8555185782e96dd608ddf0d6f82d1869533c941a6f81e129e14080be086984d1bbc9d354a2f4d406ef3cfc
data/Cargo.lock CHANGED
@@ -124,7 +124,7 @@ dependencies = [
124
124
  [[package]]
125
125
  name = "btls"
126
126
  version = "0.5.6"
127
- source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91"
127
+ source = "git+https://github.com/0x676e67/btls?branch=main#8879c026b548c25441f83ff58b39d7e22ba1b5b1"
128
128
  dependencies = [
129
129
  "bitflags",
130
130
  "btls-sys",
@@ -136,7 +136,7 @@ dependencies = [
136
136
  [[package]]
137
137
  name = "btls-sys"
138
138
  version = "0.5.6"
139
- source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91"
139
+ source = "git+https://github.com/0x676e67/btls?branch=main#8879c026b548c25441f83ff58b39d7e22ba1b5b1"
140
140
  dependencies = [
141
141
  "bindgen 0.73.2",
142
142
  "cmake",
@@ -483,7 +483,7 @@ dependencies = [
483
483
  [[package]]
484
484
  name = "http2"
485
485
  version = "0.5.20"
486
- source = "git+https://github.com/0x676e67/http2?rev=29b3bdfc7560d6f84119c103311afa147488b6f0#29b3bdfc7560d6f84119c103311afa147488b6f0"
486
+ source = "git+https://github.com/0x676e67/http2?branch=master#3219d38910c22105ea7fc5464696f26589432e9c"
487
487
  dependencies = [
488
488
  "atomic-waker",
489
489
  "bytes",
@@ -610,9 +610,9 @@ dependencies = [
610
610
 
611
611
  [[package]]
612
612
  name = "indexmap"
613
- version = "2.14.0"
613
+ version = "2.14.2"
614
614
  source = "registry+https://github.com/rust-lang/crates.io-index"
615
- checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
615
+ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
616
616
  dependencies = [
617
617
  "equivalent",
618
618
  "hashbrown",
@@ -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",
@@ -760,6 +760,25 @@ dependencies = [
760
760
  "windows-sys",
761
761
  ]
762
762
 
763
+ [[package]]
764
+ name = "netty"
765
+ version = "0.2.5"
766
+ source = "git+https://github.com/0x676e67/netty?branch=main#314db585d85e7ea9c15535f458e7324b800fc702"
767
+ dependencies = [
768
+ "bytes",
769
+ "futures-channel",
770
+ "futures-util",
771
+ "http",
772
+ "http-body",
773
+ "http2",
774
+ "httparse",
775
+ "pin-project-lite",
776
+ "smallvec",
777
+ "tokio",
778
+ "tokio-util",
779
+ "want",
780
+ ]
781
+
763
782
  [[package]]
764
783
  name = "nom"
765
784
  version = "7.1.3"
@@ -869,18 +888,18 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
869
888
 
870
889
  [[package]]
871
890
  name = "rb-sys"
872
- version = "0.9.128"
891
+ version = "0.9.130"
873
892
  source = "registry+https://github.com/rust-lang/crates.io-index"
874
- checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
893
+ checksum = "02faf625bb10ba893e3ae620f19c9fb1b5f8fcae0fe4eb86bb3f2230fad75edb"
875
894
  dependencies = [
876
895
  "rb-sys-build",
877
896
  ]
878
897
 
879
898
  [[package]]
880
899
  name = "rb-sys-build"
881
- version = "0.9.128"
900
+ version = "0.9.130"
882
901
  source = "registry+https://github.com/rust-lang/crates.io-index"
883
- checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
902
+ checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
884
903
  dependencies = [
885
904
  "bindgen 0.72.1",
886
905
  "lazy_static",
@@ -1020,10 +1039,11 @@ dependencies = [
1020
1039
 
1021
1040
  [[package]]
1022
1041
  name = "serde_json"
1023
- version = "1.0.151"
1042
+ version = "1.0.154"
1024
1043
  source = "registry+https://github.com/rust-lang/crates.io-index"
1025
- checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
1044
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
1026
1045
  dependencies = [
1046
+ "foldhash",
1027
1047
  "indexmap",
1028
1048
  "itoa",
1029
1049
  "memchr",
@@ -1209,9 +1229,9 @@ dependencies = [
1209
1229
 
1210
1230
  [[package]]
1211
1231
  name = "tokio"
1212
- version = "1.53.1"
1232
+ version = "1.54.1"
1213
1233
  source = "registry+https://github.com/rust-lang/crates.io-index"
1214
- checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
1234
+ checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
1215
1235
  dependencies = [
1216
1236
  "bytes",
1217
1237
  "libc",
@@ -1227,7 +1247,7 @@ dependencies = [
1227
1247
  [[package]]
1228
1248
  name = "tokio-btls"
1229
1249
  version = "0.5.6"
1230
- source = "git+https://github.com/0x676e67/btls?rev=5ec1c113a03626a5877b34dd6d2ea8d440897a91#5ec1c113a03626a5877b34dd6d2ea8d440897a91"
1250
+ source = "git+https://github.com/0x676e67/btls?branch=main#8879c026b548c25441f83ff58b39d7e22ba1b5b1"
1231
1251
  dependencies = [
1232
1252
  "btls",
1233
1253
  "btls-sys",
@@ -1430,7 +1450,7 @@ dependencies = [
1430
1450
  [[package]]
1431
1451
  name = "wreq"
1432
1452
  version = "0.16.1"
1433
- source = "git+https://github.com/0x676e67/wreq?rev=74fc1469b5c54b3fb93037e48f136b569d0fe418#74fc1469b5c54b3fb93037e48f136b569d0fe418"
1453
+ source = "git+https://github.com/0x676e67/wreq?branch=main#85d0528f10ceba32ca444d3343b61c291ef8c1d4"
1434
1454
  dependencies = [
1435
1455
  "btls",
1436
1456
  "btls-sys",
@@ -1448,6 +1468,7 @@ dependencies = [
1448
1468
  "libc",
1449
1469
  "lru",
1450
1470
  "mime",
1471
+ "netty",
1451
1472
  "percent-encoding",
1452
1473
  "pin-project-lite",
1453
1474
  "serde",
@@ -1462,39 +1483,6 @@ dependencies = [
1462
1483
  "tower",
1463
1484
  "tower-http",
1464
1485
  "url",
1465
- "wreq-proto",
1466
- "wreq-rt",
1467
- ]
1468
-
1469
- [[package]]
1470
- name = "wreq-proto"
1471
- version = "0.2.5"
1472
- source = "registry+https://github.com/rust-lang/crates.io-index"
1473
- checksum = "a43942f024bb303f1042c9aa3c87fa1d9149f507c65db6e5220a11ccdb207387"
1474
- dependencies = [
1475
- "bytes",
1476
- "futures-channel",
1477
- "futures-util",
1478
- "http",
1479
- "http-body",
1480
- "http2",
1481
- "httparse",
1482
- "pin-project-lite",
1483
- "smallvec",
1484
- "tokio",
1485
- "tokio-util",
1486
- "want",
1487
- ]
1488
-
1489
- [[package]]
1490
- name = "wreq-rt"
1491
- version = "0.2.2-rc.4"
1492
- source = "registry+https://github.com/rust-lang/crates.io-index"
1493
- checksum = "99e9bce67a3fa3dd3f1503f066d86661c9caf399a763d3bd184da7afaf886c8b"
1494
- dependencies = [
1495
- "pin-project-lite",
1496
- "tokio",
1497
- "wreq-proto",
1498
1486
  ]
1499
1487
 
1500
1488
  [[package]]
data/Cargo.toml CHANGED
@@ -6,7 +6,7 @@ homepage = "https://github.com/SearchApi/wreq-ruby"
6
6
  repository = "https://github.com/SearchApi/wreq-ruby"
7
7
  edition = "2024"
8
8
  version = "1.3.2"
9
- rust-version = "1.98"
9
+ rust-version = "1.100"
10
10
 
11
11
  [lib]
12
12
  crate-type = ["cdylib"]
@@ -14,12 +14,13 @@ 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.
21
21
  wreq = { version = "0.16.1", default-features = false, features = [
22
22
  "tokio-rt",
23
+ "http2",
23
24
  "chromium-roots",
24
25
  "query",
25
26
  "form",
@@ -53,7 +54,7 @@ futures-util = { version = "0.3.33", default-features = false }
53
54
  forkguard = { version = "0.1.3", features = ["atfork"] }
54
55
 
55
56
  [dev-dependencies]
56
- magnus = { version = "0.8.2", features = ["embed"] }
57
+ magnus = { version = "0.9.0", features = ["embed"] }
57
58
 
58
59
  [build-dependencies]
59
60
  rb-sys-env = "0.2.2"
@@ -67,9 +68,11 @@ opt-level = 3
67
68
  strip = true
68
69
 
69
70
  [patch.crates-io]
70
- http2 = { git = "https://github.com/0x676e67/http2", rev = "29b3bdfc7560d6f84119c103311afa147488b6f0" }
71
- btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
72
- btls-sys = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
73
- tokio-btls = { git = "https://github.com/0x676e67/btls", rev = "5ec1c113a03626a5877b34dd6d2ea8d440897a91" }
74
- wreq = { git = "https://github.com/0x676e67/wreq", rev = "74fc1469b5c54b3fb93037e48f136b569d0fe418" }
71
+ # Match the Git patches used by wreq main; Cargo.lock pins the exact revisions.
72
+ btls = { git = "https://github.com/0x676e67/btls", branch = "main" }
73
+ btls-sys = { git = "https://github.com/0x676e67/btls", branch = "main" }
74
+ tokio-btls = { git = "https://github.com/0x676e67/btls", branch = "main" }
75
+ http2 = { git = "https://github.com/0x676e67/http2", branch = "master" }
76
+ netty = { git = "https://github.com/0x676e67/netty", branch = "main" }
77
+ wreq = { git = "https://github.com/0x676e67/wreq", branch = "main" }
75
78
  wreq-util = { path = "crates/wreq-util" }
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
- | **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` |
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` |
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` |
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.1
1
+ 1.3.2.3
data/crates/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Local Rust dependencies
2
+
3
+ - [`wreq-util`](wreq-util/) is a local copy of [0x676e67/wreq-util](https://github.com/0x676e67/wreq-util). The root [`Cargo.toml`](../Cargo.toml) resolves it from `crates/wreq-util` through `[patch.crates-io]`.
4
+
5
+ When building or testing `wreq-util` on its own, use the Git dependency patches from the root manifest of the same branch. Cargo does not inherit those patches from the parent package.
@@ -29,6 +29,7 @@ emulation = [
29
29
  "dep:zstd",
30
30
  "dep:chromium-roots",
31
31
  "wreq/chromium-roots",
32
+ "wreq/http2",
32
33
  ]
33
34
  emulation-serde = ["dep:serde"]
34
35
  emulation-compression = []
@@ -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
  }