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
@@ -0,0 +1,418 @@
1
+ use super::super::{Emulation, HeaderMap, Platform, build_standard_emulation};
2
+ use super::{
3
+ chrome::{v100, v117, v124, v131, v132, v150},
4
+ header, http2, tls,
5
+ };
6
+
7
+ macro_rules! edge_profile {
8
+ (
9
+ $name:ident,
10
+ transport: $transport:path,
11
+ brands: $brands:literal,
12
+ $platforms:tt $(,)?
13
+ ) => {
14
+ edge_profile!(
15
+ $name,
16
+ transport: $transport,
17
+ headers: header::Preset::ZstdWithPriority,
18
+ brands: $brands,
19
+ $platforms
20
+ );
21
+ };
22
+ (
23
+ $name:ident,
24
+ transport: $transport:path,
25
+ headers: $headers:path,
26
+ brands: $brands:literal,
27
+ $platforms:tt $(,)?
28
+ ) => {
29
+ standard_mod_generator!($name, $transport, |emulation: &Emulation| {
30
+ platform_headers!(emulation, $headers, $brands, $platforms)
31
+ });
32
+ };
33
+ (
34
+ $name:ident,
35
+ tls: $tls:path,
36
+ http2: $http2:path,
37
+ brands: $brands:literal,
38
+ $platforms:tt $(,)?
39
+ ) => {
40
+ standard_mod_generator!($name, ($tls).build(), ($http2).build(), |emulation: &Emulation| {
41
+ platform_headers!(emulation, header::Preset::ZstdWithPriority, $brands, $platforms)
42
+ });
43
+ };
44
+ }
45
+
46
+ edge_profile!(
47
+ edge101,
48
+ transport: v100::build_emulation,
49
+ headers: header::Preset::Legacy,
50
+ brands: r#""Not A;Brand";v="99", "Chromium";v="101", "Microsoft Edge";v="101""#,
51
+ [
52
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47"),
53
+ (Android, "Mozilla/5.0 (Linux; Android 10; ONEPLUS A6003) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.31"),
54
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"),
55
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"),
56
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/101.0.4951.64 Mobile Safari/537.36 Edg/101.0.1210.53")
57
+ ]
58
+ );
59
+
60
+ edge_profile!(
61
+ edge122,
62
+ transport: v117::build_emulation,
63
+ headers: header::Preset::Legacy,
64
+ brands: r#""Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122""#,
65
+ [
66
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"),
67
+ (Android, "Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6268.219 Safari/537.36 Edg/122.0.2238.82"),
68
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"),
69
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"),
70
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0")
71
+ ]
72
+ );
73
+
74
+ edge_profile!(
75
+ edge127,
76
+ transport: v124::build_emulation,
77
+ brands: r#""Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127""#,
78
+ [
79
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"),
80
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6332.205 Safari/537.36 Edg/127.0.2322.67"),
81
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"),
82
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"),
83
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0")
84
+ ]
85
+ );
86
+
87
+ edge_profile!(
88
+ edge131,
89
+ transport: v131::build_emulation,
90
+ brands: r#""Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24""#,
91
+ [
92
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"),
93
+ (Android, "Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.200 Mobile Safari/537.36 EdgA/131.0.2903.87"),
94
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"),
95
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"),
96
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0")
97
+ ]
98
+ );
99
+
100
+ // Unlike Chrome 134, this Edge preset retains the earlier ALPS codepoint.
101
+ edge_profile!(
102
+ edge134,
103
+ transport: v131::build_emulation,
104
+ brands: r#""Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134""#,
105
+ [
106
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0"),
107
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0"),
108
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0"),
109
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0"),
110
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/134.0.0.0")
111
+ ]
112
+ );
113
+
114
+ edge_profile!(
115
+ edge135,
116
+ transport: v132::build_emulation,
117
+ brands: r#""Chromium";v="135", "Not:A-Brand";v="24", "Microsoft Edge";v="135""#,
118
+ [
119
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0"),
120
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0"),
121
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0"),
122
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0"),
123
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/135.0.0.0")
124
+ ]
125
+ );
126
+
127
+ edge_profile!(
128
+ edge136,
129
+ transport: v132::build_emulation,
130
+ brands: r#""Chromium";v="136", "Not:A-Brand";v="24", "Microsoft Edge";v="136""#,
131
+ [
132
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"),
133
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"),
134
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"),
135
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0"),
136
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/136.0.0.0")
137
+ ]
138
+ );
139
+
140
+ edge_profile!(
141
+ edge137,
142
+ transport: v132::build_emulation,
143
+ brands: r#""Chromium";v="137", "Not:A-Brand";v="24", "Microsoft Edge";v="137""#,
144
+ [
145
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0"),
146
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0"),
147
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0"),
148
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0"),
149
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/137.0.0.0")
150
+ ]
151
+ );
152
+
153
+ edge_profile!(
154
+ edge138,
155
+ transport: v132::build_emulation,
156
+ brands: r#""Chromium";v="138", "Not=A?Brand";v="24", "Microsoft Edge";v="138""#,
157
+ [
158
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0"),
159
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0"),
160
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0"),
161
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0"),
162
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/138.0.0.0")
163
+ ]
164
+ );
165
+
166
+ edge_profile!(
167
+ edge139,
168
+ transport: v132::build_emulation,
169
+ brands: r#""Chromium";v="139", "Not=A?Brand";v="24", "Microsoft Edge";v="139""#,
170
+ [
171
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0"),
172
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0"),
173
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0"),
174
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0"),
175
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/139.0.0.0")
176
+ ]
177
+ );
178
+
179
+ edge_profile!(
180
+ edge140,
181
+ transport: v132::build_emulation,
182
+ brands: r#""Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140""#,
183
+ [
184
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0"),
185
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0"),
186
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0"),
187
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0"),
188
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/140.0.0.0")
189
+ ]
190
+ );
191
+
192
+ edge_profile!(
193
+ edge141,
194
+ transport: v132::build_emulation,
195
+ brands: r#""Chromium";v="141", "Not=A?Brand";v="24", "Microsoft Edge";v="141""#,
196
+ [
197
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0"),
198
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0"),
199
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0"),
200
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0"),
201
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/141.0.0.0")
202
+ ]
203
+ );
204
+
205
+ edge_profile!(
206
+ edge142,
207
+ transport: v132::build_emulation,
208
+ brands: r#""Chromium";v="142", "Microsoft Edge";v="142", "Not_A Brand";v="99""#,
209
+ [
210
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"),
211
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36 Edg/142.0.0.0"),
212
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"),
213
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"),
214
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0")
215
+ ]
216
+ );
217
+
218
+ edge_profile!(
219
+ edge143,
220
+ transport: v132::build_emulation,
221
+ brands: r#""Chromium";v="143", "Microsoft Edge";v="143", "Not_A Brand";v="99""#,
222
+ [
223
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0"),
224
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36 Edg/143.0.0.0"),
225
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0"),
226
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0"),
227
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0")
228
+ ]
229
+ );
230
+
231
+ edge_profile!(
232
+ edge144,
233
+ transport: v132::build_emulation,
234
+ brands: r#""Not(A:Brand";v="8", "Chromium";v="144", "Microsoft Edge";v="144""#,
235
+ [
236
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0"),
237
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Mobile Safari/537.36 Edg/144.0.0.0"),
238
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0"),
239
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0"),
240
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0")
241
+ ]
242
+ );
243
+
244
+ edge_profile!(
245
+ edge145,
246
+ transport: v132::build_emulation,
247
+ brands: r#""Chromium";v="145", "Not;A=Brand";v="24", "Microsoft Edge";v="145""#,
248
+ [
249
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0"),
250
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Mobile Safari/537.36 Edg/145.0.0.0"),
251
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0"),
252
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0"),
253
+ (IOS, "Mozilla/5.0 (iPhone; CPU iPhone OS 18_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0")
254
+ ]
255
+ );
256
+
257
+ edge_profile!(
258
+ edge146,
259
+ transport: v132::build_emulation,
260
+ brands: r#""Chromium";v="146", "Not(A:Brand";v="24", "Microsoft Edge";v="146""#,
261
+ [
262
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109"),
263
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.178 Mobile Safari/537.36 EdgA/146.0.3856.97"),
264
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109"),
265
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.3856.109"),
266
+ (IOS, "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/146.0.3856.102 Mobile/15E148 Safari/605.1.15")
267
+ ]
268
+ );
269
+
270
+ edge_profile!(
271
+ edge147,
272
+ transport: v132::build_emulation,
273
+ brands: r#""Microsoft Edge";v="147", "Not.A/Brand";v="8", "Chromium";v="147""#,
274
+ [
275
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51"),
276
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.7727.55 Mobile Safari/537.36 EdgA/147.0.3912.51"),
277
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51"),
278
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.3912.51"),
279
+ (IOS, "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/147.0.3912.51 Mobile/15E148 Safari/605.1.15")
280
+ ]
281
+ );
282
+
283
+ edge_profile!(
284
+ edge148,
285
+ transport: v132::build_emulation,
286
+ brands: r#""Chromium";v="148", "Microsoft Edge";v="148", "Not/A)Brand";v="99""#,
287
+ [
288
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0"),
289
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0"),
290
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0"),
291
+ (Android, "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36 EdgA/148.0.0.0"),
292
+ (IOS, "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/148.0.0.0 Mobile/15E148 Safari/605.1.15")
293
+ ]
294
+ );
295
+
296
+ // Unlike newer Chrome, Edge does not advertise JPEG XL in navigation requests.
297
+ edge_profile!(
298
+ edge149,
299
+ transport: v132::build_emulation,
300
+ brands: r#""Microsoft Edge";v="149", "Chromium";v="149", "Not)A;Brand";v="24""#,
301
+ [
302
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0"),
303
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0"),
304
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0"),
305
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36 EdgA/149.0.0.0"),
306
+ (IOS, "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/149.0.0.0 Mobile/15E148 Safari/605.1.15")
307
+ ]
308
+ );
309
+ edge_profile!(
310
+ edge150,
311
+ transport: v150::build_emulation,
312
+ brands: r#""Not;A=Brand";v="8", "Chromium";v="150", "Microsoft Edge";v="150""#,
313
+ [
314
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0"),
315
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0"),
316
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0"),
317
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36 EdgA/150.0.0.0"),
318
+ (IOS, "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/150.0.0.0 Mobile/15E148 Safari/605.1.15")
319
+ ]
320
+ );
321
+ edge_profile!(
322
+ edge151,
323
+ transport: v150::build_emulation,
324
+ brands: r#""Not=A?Brand";v="99", "Microsoft Edge";v="151", "Chromium";v="151""#,
325
+ [
326
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0"),
327
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0"),
328
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0"),
329
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Mobile Safari/537.36 EdgA/151.0.0.0"),
330
+ (IOS, "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/151.0.0.0 Mobile/15E148 Safari/605.1.15")
331
+ ]
332
+ );
333
+ // Edge enables TLS signature-algorithm GREASE without sending Trust Anchor IDs.
334
+ edge_profile!(
335
+ edge152,
336
+ tls: tls::Preset::EdgeSignatureGrease,
337
+ http2: http2::Preset::NoPush,
338
+ brands: r#""Chromium";v="152", "Not?A_Brand";v="24", "Microsoft Edge";v="152""#,
339
+ [
340
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 Edg/152.0.0.0"),
341
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 Edg/152.0.0.0"),
342
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 Edg/152.0.0.0"),
343
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Mobile Safari/537.36 EdgA/152.0.0.0"),
344
+ (IOS, "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/152.0.0.0 Mobile/15E148 Safari/605.1.15")
345
+ ]
346
+ );
347
+ edge_profile!(
348
+ edge153,
349
+ transport: edge152::build_emulation,
350
+ brands: r#""Microsoft Edge";v="153", "Not_A Brand";v="8", "Chromium";v="153""#,
351
+ [
352
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 Edg/153.0.0.0"),
353
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 Edg/153.0.0.0"),
354
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 Edg/153.0.0.0"),
355
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Mobile Safari/537.36 EdgA/153.0.0.0"),
356
+ (IOS, "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/153.0.0.0 Mobile/15E148 Safari/605.1.15")
357
+ ]
358
+ );
359
+ edge_profile!(
360
+ edge154,
361
+ transport: edge152::build_emulation,
362
+ brands: r#""Chromium";v="154", "Microsoft Edge";v="154", "Not A(Brand";v="99""#,
363
+ [
364
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 Edg/154.0.0.0"),
365
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 Edg/154.0.0.0"),
366
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 Edg/154.0.0.0"),
367
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Mobile Safari/537.36 EdgA/154.0.0.0"),
368
+ (IOS, "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/154.0.0.0 Mobile/15E148 Safari/605.1.15")
369
+ ]
370
+ );
371
+ edge_profile!(
372
+ edge155,
373
+ transport: edge152::build_emulation,
374
+ brands: r#""Microsoft Edge";v="155", "Chromium";v="155", "Not(A:Brand";v="24""#,
375
+ [
376
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 Edg/155.0.0.0"),
377
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 Edg/155.0.0.0"),
378
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 Edg/155.0.0.0"),
379
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Mobile Safari/537.36 EdgA/155.0.0.0"),
380
+ (IOS, "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/155.0.0.0 Mobile/15E148 Safari/605.1.15")
381
+ ]
382
+ );
383
+ edge_profile!(
384
+ edge156,
385
+ transport: edge152::build_emulation,
386
+ brands: r#""Not:A-Brand";v="8", "Chromium";v="156", "Microsoft Edge";v="156""#,
387
+ [
388
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36 Edg/156.0.0.0"),
389
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36 Edg/156.0.0.0"),
390
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36 Edg/156.0.0.0"),
391
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Mobile Safari/537.36 EdgA/156.0.0.0"),
392
+ (IOS, "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/156.0.0.0 Mobile/15E148 Safari/605.1.15")
393
+ ]
394
+ );
395
+ edge_profile!(
396
+ edge157,
397
+ transport: edge152::build_emulation,
398
+ brands: r#""Not-A.Brand";v="99", "Microsoft Edge";v="157", "Chromium";v="157""#,
399
+ [
400
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0"),
401
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0"),
402
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0"),
403
+ (Android, "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Mobile Safari/537.36 EdgA/157.0.0.0"),
404
+ (IOS, "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/157.0.0.0 Mobile/15E148 Safari/605.1.15")
405
+ ]
406
+ );
407
+ edge_profile!(
408
+ edge158,
409
+ transport: edge152::build_emulation,
410
+ brands: r#""Chromium";v="158", "Not.A/Brand";v="24", "Microsoft Edge";v="158""#,
411
+ [
412
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36 Edg/158.0.0.0"),
413
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36 Edg/158.0.0.0"),
414
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36 Edg/158.0.0.0"),
415
+ (Android, "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"),
416
+ (IOS, "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")
417
+ ]
418
+ );
@@ -0,0 +1,74 @@
1
+ #[cfg(feature = "emulation-compression")]
2
+ use super::super::ACCEPT_ENCODING;
3
+ use super::super::{ACCEPT, ACCEPT_LANGUAGE, HeaderMap, HeaderValue, Platform, USER_AGENT};
4
+
5
+ const DEFAULT_ACCEPT: &str = "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";
6
+ const JXL_ACCEPT: &str = "text/html,application/xhtml+xml,application/xml;q=0.9,image/jxl,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
7
+
8
+ #[derive(Clone, Copy)]
9
+ pub(super) enum Preset {
10
+ Legacy,
11
+ Zstd,
12
+ ZstdWithPriority,
13
+ Jxl,
14
+ EarlyLanguage,
15
+ }
16
+
17
+ impl Preset {
18
+ pub(super) fn build(
19
+ self,
20
+ brands: &'static str,
21
+ ua: &'static str,
22
+ platform: Platform,
23
+ ) -> HeaderMap {
24
+ // Chrome 152 keeps the regular Accept-Language position on Linux.
25
+ let early_language =
26
+ matches!(self, Self::EarlyLanguage) && !matches!(platform, Platform::Linux);
27
+ let language = "en-US,en;q=0.9";
28
+ let mobile = if platform.is_mobile() { "?1" } else { "?0" };
29
+
30
+ // Chrome 155+ enables JPEG XL in Blink, not in the iOS WebKit profile.
31
+ // https://chromium.googlesource.com/chromium/src/+/cfaadc5a132d78e1828635aa8405a499f3e14864/content/common/content_constants_internal.h
32
+ let accept = if matches!(self, Self::Jxl) && !matches!(platform, Platform::IOS) {
33
+ JXL_ACCEPT
34
+ } else {
35
+ DEFAULT_ACCEPT
36
+ };
37
+
38
+ let mut headers = HeaderMap::new();
39
+ headers.insert("sec-ch-ua", HeaderValue::from_static(brands));
40
+ headers.insert("sec-ch-ua-mobile", HeaderValue::from_static(mobile));
41
+ headers.insert(
42
+ "sec-ch-ua-platform",
43
+ HeaderValue::from_static(platform.platform()),
44
+ );
45
+ if early_language {
46
+ headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static(language));
47
+ }
48
+ headers.insert("upgrade-insecure-requests", HeaderValue::from_static("1"));
49
+ headers.insert(USER_AGENT, HeaderValue::from_static(ua));
50
+ headers.insert(ACCEPT, HeaderValue::from_static(accept));
51
+ headers.insert("sec-fetch-site", HeaderValue::from_static("none"));
52
+ headers.insert("sec-fetch-mode", HeaderValue::from_static("navigate"));
53
+ headers.insert("sec-fetch-user", HeaderValue::from_static("?1"));
54
+ headers.insert("sec-fetch-dest", HeaderValue::from_static("document"));
55
+ #[cfg(feature = "emulation-compression")]
56
+ headers.insert(
57
+ ACCEPT_ENCODING,
58
+ HeaderValue::from_static(match self {
59
+ Self::Legacy => "gzip, deflate, br",
60
+ _ => "gzip, deflate, br, zstd",
61
+ }),
62
+ );
63
+ if !early_language {
64
+ headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static(language));
65
+ }
66
+ if matches!(
67
+ self,
68
+ Self::ZstdWithPriority | Self::Jxl | Self::EarlyLanguage
69
+ ) {
70
+ headers.insert("priority", HeaderValue::from_static("u=0, i"));
71
+ }
72
+ headers
73
+ }
74
+ }
@@ -0,0 +1,59 @@
1
+ use wreq::http2::{
2
+ HeadersDependency, HeadersPriority, Http2Options, PseudoId, PseudoOrder, SettingId,
3
+ SettingsOrder,
4
+ };
5
+
6
+ #[derive(Clone, Copy)]
7
+ pub(super) enum Preset {
8
+ StreamLimit,
9
+ StreamLimitNoPush,
10
+ NoPush,
11
+ }
12
+
13
+ impl Preset {
14
+ pub(super) fn build(self) -> Http2Options {
15
+ // Unset SETTINGS entries are omitted, not sent with a zero value.
16
+ let (max_concurrent_streams, enable_push) = match self {
17
+ Self::StreamLimit => (Some(1_000), None),
18
+ Self::StreamLimitNoPush => (Some(1_000), Some(false)),
19
+ Self::NoPush => (None, Some(false)),
20
+ };
21
+
22
+ let mut builder = Http2Options::builder()
23
+ .initial_window_size(6_291_456)
24
+ .initial_connection_window_size(15_728_640)
25
+ .max_header_list_size(262_144)
26
+ .header_table_size(65_536)
27
+ .max_concurrent_streams(max_concurrent_streams)
28
+ .headers_priority(HeadersPriority::new(HeadersDependency::Root, 255, true))
29
+ .headers_pseudo_order(
30
+ PseudoOrder::builder()
31
+ .extend([
32
+ PseudoId::Method,
33
+ PseudoId::Authority,
34
+ PseudoId::Scheme,
35
+ PseudoId::Path,
36
+ ])
37
+ .build(),
38
+ )
39
+ .settings_order(
40
+ SettingsOrder::builder()
41
+ .extend([
42
+ SettingId::HeaderTableSize,
43
+ SettingId::EnablePush,
44
+ SettingId::MaxConcurrentStreams,
45
+ SettingId::InitialWindowSize,
46
+ SettingId::MaxFrameSize,
47
+ SettingId::MaxHeaderListSize,
48
+ SettingId::EnableConnectProtocol,
49
+ SettingId::NoRfc7540Priorities,
50
+ ])
51
+ .build(),
52
+ );
53
+
54
+ if let Some(enable_push) = enable_push {
55
+ builder = builder.enable_push(enable_push);
56
+ }
57
+ builder.build()
58
+ }
59
+ }