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,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "socket"
5
+ require "stringio"
6
+ require "timeout"
7
+
8
+ class EmulationClientHelloTest < Minitest::Test
9
+ SUPPORTED_GROUPS = 10
10
+ SIGNATURE_ALGORITHMS = 13
11
+ KEY_SHARE = 51
12
+ TRUST_ANCHOR_IDS = 51_764
13
+ ENCRYPTED_CLIENT_HELLO = 65_037
14
+
15
+ def test_reusing_chrome_emulation_preserves_trust_anchors
16
+ [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile|
17
+ emulation = Wreq::Emulation.new(profile: profile)
18
+ client = Wreq::Client.new(emulation: emulation, no_proxy: true)
19
+ _, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
20
+ expected = extensions.fetch(TRUST_ANCHOR_IDS)
21
+ refute_empty expected, profile.to_s
22
+
23
+ request_client = Wreq::Client.new(no_proxy: true)
24
+ 2.times do
25
+ _, actual_extensions = capture_client_hello do |url|
26
+ request_client.get(url, emulation: emulation, timeout: 5)
27
+ end
28
+ assert_equal expected, actual_extensions.fetch(TRUST_ANCHOR_IDS), "#{profile}: reusing an object must retain its configuration"
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_edge158_sends_signature_grease_without_trust_anchors
34
+ client = Wreq::Client.new(emulation: Wreq::Emulation.new(profile: Wreq::Profile::Edge158), no_proxy: true)
35
+ _, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
36
+
37
+ _, grease, *signatures = extensions.fetch(SIGNATURE_ALGORITHMS).unpack("n*")
38
+ assert_equal 0x0a0a, grease & 0x0f0f
39
+ assert_equal grease >> 8, grease & 0xff
40
+ assert_equal [0x0904, 0x0905, 0x0906], signatures.first(3) # ML-DSA
41
+ refute extensions.key?(TRUST_ANCHOR_IDS)
42
+ end
43
+
44
+ def test_firefox_client_hello_matches_version
45
+ suites_153 = [
46
+ 0x1301, 0x1303, 0x1302,
47
+ 0xc02b, 0xc02f, 0xcca9, 0xcca8, 0xc02c, 0xc030, 0xc00a, 0xc013, 0xc014, 0x009c, 0x009d, 0x002f, 0x0035
48
+ ]
49
+ # Firefox 154 disabled TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA.
50
+ suites_154 = suites_153.reject { |suite| suite == 0xc00a }
51
+
52
+ [
53
+ [Wreq::Profile::Firefox153, suites_153, 15, [4588, 29, 23, 24, 25, 256, 257]],
54
+ [Wreq::Profile::Firefox154, suites_154, 15, [4588, 29, 23, 24, 25, 256, 257]],
55
+ [Wreq::Profile::Firefox155, suites_154, 16, [4588, 29, 23, 24, 25, 256, 257]],
56
+ [Wreq::Profile::Firefox156, suites_154, 16, [4588, 29, 23, 24, 25]]
57
+ ].each do |profile, expected_suites, padding_remainder, groups|
58
+ client = Wreq::Client.new(emulation: Wreq::Emulation.new(profile: profile), no_proxy: true)
59
+ suites, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
60
+ assert_equal [4588, 29, 23], key_share_groups(extensions.fetch(KEY_SHARE)), "#{profile}: key share groups"
61
+ assert_equal expected_suites, suites, "#{profile}: cipher suites"
62
+
63
+ assert_equal padding_remainder, ech_payload_size(extensions.fetch(ENCRYPTED_CLIENT_HELLO)) % 32, "#{profile}: ECH GREASE ciphertext"
64
+ assert_equal groups, extensions.fetch(SUPPORTED_GROUPS).unpack("n*").drop(1), "#{profile}: supported groups"
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ # Each listener forces a new connection. Stop after ClientHello so this test
71
+ # inspects the wire bytes without depending on certificates or an external service.
72
+ def capture_client_hello
73
+ server = TCPServer.new("127.0.0.1", 0)
74
+ thread = Thread.new do
75
+ socket = nil
76
+ Timeout.timeout(5) do
77
+ socket = server.accept
78
+ handshake = +"".b
79
+ loop do
80
+ header = read_tls_bytes(socket, 5)
81
+ raise "expected a TLS handshake record" unless header.getbyte(0) == 22
82
+ handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n"))
83
+ next if handshake.bytesize < 4
84
+ length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte }
85
+ break if handshake.bytesize >= length + 4
86
+ end
87
+ parse_client_hello(handshake)
88
+ end
89
+ ensure
90
+ socket&.close
91
+ end
92
+ thread.report_on_exception = false
93
+
94
+ assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" }
95
+ thread.value
96
+ ensure
97
+ server&.close
98
+ thread&.kill if thread&.alive?
99
+ thread&.join
100
+ end
101
+
102
+ def read_tls_bytes(io, length)
103
+ bytes = io.read(length)
104
+ raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length
105
+ bytes
106
+ end
107
+
108
+ def parse_client_hello(handshake)
109
+ io = StringIO.new(handshake)
110
+ raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1
111
+ read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random.
112
+ read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID.
113
+ suites = read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")).unpack("n*")
114
+ read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods.
115
+ extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
116
+ parsed = {}
117
+ until extensions.eof?
118
+ type, length = read_tls_bytes(extensions, 4).unpack("nn")
119
+ parsed[type] = read_tls_bytes(extensions, length)
120
+ end
121
+ [suites, parsed]
122
+ end
123
+
124
+ def ech_payload_size(extension)
125
+ io = StringIO.new(extension)
126
+ read_tls_bytes(io, 6) # Outer tag, HPKE suite and config ID.
127
+ read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Encapsulated key.
128
+ read_tls_bytes(io, 2).unpack1("n")
129
+ end
130
+
131
+ def key_share_groups(extension)
132
+ io = StringIO.new(extension)
133
+ entries = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
134
+ groups = []
135
+ until entries.eof?
136
+ group, length = read_tls_bytes(entries, 4).unpack("nn")
137
+ read_tls_bytes(entries, length) # Key exchange bytes.
138
+ groups << group
139
+ end
140
+ groups
141
+ end
142
+ end
@@ -1,119 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "test_helper"
4
- require "socket"
5
- require "stringio"
6
- require "timeout"
7
4
 
8
5
  class EmulationTest < Minitest::Test
9
- def test_reused_emulation_retains_trust_anchors_across_clients_and_requests
10
- [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile|
11
- emulation = Wreq::Emulation.new(profile: profile)
12
- client = Wreq::Client.new(emulation: emulation, no_proxy: true)
13
- expected = capture_trust_anchors { |url| client.get(url, timeout: 5) }
14
- refute_empty expected, profile.to_s
15
-
16
- request_client = Wreq::Client.new(no_proxy: true)
17
- 2.times do
18
- actual = capture_trust_anchors do |url|
19
- request_client.get(url, emulation: emulation, timeout: 5)
20
- end
21
- assert_equal expected, actual, "#{profile}: reusing an object must retain its configuration"
22
- end
23
- end
24
- end
25
-
26
- def test_all_emulation_device_constants_are_non_nil
27
- Wreq::Profile.constants.each do |name|
28
- const = Wreq::Profile.const_get(name)
29
- assert_instance_of Wreq::Profile, const,
30
- "#{name} should be Profile, got #{const.inspect}"
31
- end
32
- end
33
-
34
- def test_chrome151_profile_is_available
35
- profile = Wreq::Profile::Chrome151
36
-
37
- assert_equal "Chrome151", profile.to_s
38
- assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile)
39
- end
40
-
41
- def test_new_browser_profiles_are_available
42
- {
43
- Wreq::Profile::Chrome152 => "Chrome152",
44
- Wreq::Profile::Chrome153 => "Chrome153",
45
- Wreq::Profile::Chrome154 => "Chrome154",
46
- Wreq::Profile::Chrome155 => "Chrome155",
47
- Wreq::Profile::Chrome156 => "Chrome156",
48
- Wreq::Profile::Chrome157 => "Chrome157",
49
- Wreq::Profile::Firefox152 => "Firefox152"
50
- }.each do |profile, name|
51
- assert_equal name, profile.to_s
52
- assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile)
6
+ def test_expected_browser_profiles_are_registered
7
+ versions_by_browser = {
8
+ "Chrome" => 151..158,
9
+ "Edge" => [101, 122, 127, 131, *(134..158)],
10
+ "Firefox" => [109, 117, 128, 133, 135, 136, 139, *(142..160)],
11
+ "Opera" => 116..140
12
+ }
13
+ expected = versions_by_browser.flat_map do |browser, versions|
14
+ versions.map { |version| "#{browser}#{version}" }
53
15
  end
54
- end
16
+ expected.concat(%w[FirefoxPrivate135 FirefoxAndroid135 FirefoxPrivate136])
55
17
 
56
- def test_all_emulation_os_constants_are_non_nil
57
- Wreq::Platform.constants.each do |name|
58
- const = Wreq::Platform.const_get(name)
59
- assert_instance_of Wreq::Platform, const,
60
- "#{name} should be Platform, got #{const.inspect}"
61
- end
18
+ registered = Wreq::Profile.constants(false).map(&:to_s)
19
+ assert_empty expected - registered, "missing browser profiles"
62
20
  end
63
21
 
64
- private
65
-
66
- # Each listener forces a new connection. Stop after ClientHello so this test
67
- # inspects the extension bytes without depending on certificates or the network.
68
- def capture_trust_anchors
69
- server = TCPServer.new("127.0.0.1", 0)
70
- thread = Thread.new do
71
- socket = nil
72
- Timeout.timeout(5) do
73
- socket = server.accept
74
- handshake = +"".b
75
- loop do
76
- header = read_tls_bytes(socket, 5)
77
- raise "expected a TLS handshake record" unless header.getbyte(0) == 22
78
- handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n"))
79
- next if handshake.bytesize < 4
80
- length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte }
81
- break if handshake.bytesize >= length + 4
82
- end
83
- trust_anchors_from_client_hello(handshake)
84
- end
85
- ensure
86
- socket&.close
22
+ def test_registered_profiles_have_matching_names_and_build_emulation
23
+ Wreq::Profile.constants(false).each do |name|
24
+ profile = Wreq::Profile.const_get(name, false)
25
+ assert_instance_of Wreq::Profile, profile, name.to_s
26
+ assert_equal name.to_s, profile.to_s
27
+ assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile), name.to_s
87
28
  end
88
- thread.report_on_exception = false
89
-
90
- assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" }
91
- thread.value
92
- ensure
93
- server&.close
94
- thread&.kill if thread&.alive?
95
- thread&.join
96
- end
97
-
98
- def read_tls_bytes(io, length)
99
- bytes = io.read(length)
100
- raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length
101
- bytes
102
29
  end
103
30
 
104
- def trust_anchors_from_client_hello(handshake)
105
- io = StringIO.new(handshake)
106
- raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1
107
- read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random.
108
- read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID.
109
- read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Cipher suites.
110
- read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods.
111
- extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
112
- until extensions.eof?
113
- type, length = read_tls_bytes(extensions, 4).unpack("nn")
114
- data = read_tls_bytes(extensions, length)
115
- return data if type == 51764
31
+ def test_registered_platforms_are_platform_values
32
+ Wreq::Platform.constants(false).each do |name|
33
+ assert_instance_of Wreq::Platform, Wreq::Platform.const_get(name, false), name.to_s
116
34
  end
117
- raise "missing trust_anchors extension"
118
35
  end
119
36
  end
data/wreq.gemspec CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
44
44
  # Exclude non-Ruby files from RDoc to prevent parsing errors
45
45
  spec.rdoc_options = ["--exclude", "Cargo\\..*", "--exclude", "\\.rs$"]
46
46
 
47
- spec.requirements = ["Rust >= 1.98"]
47
+ spec.requirements = ["Rust >= 1.100"]
48
48
  # use a Ruby version which:
49
49
  # - supports Rubygems with the ability of compilation of Rust gem
50
50
  # - not end of life
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2.1
4
+ version: 1.3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SearchApi
@@ -29,6 +29,7 @@ files:
29
29
  - Rakefile
30
30
  - VERSION
31
31
  - build.rs
32
+ - crates/README.md
32
33
  - crates/wreq-util/.github/FUNDING.yml
33
34
  - crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md
34
35
  - crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md
@@ -49,19 +50,18 @@ files:
49
50
  - crates/wreq-util/src/emulate/compress.rs
50
51
  - crates/wreq-util/src/emulate/macros.rs
51
52
  - crates/wreq-util/src/emulate/profile.rs
52
- - crates/wreq-util/src/emulate/profile/chrome.rs
53
- - crates/wreq-util/src/emulate/profile/chrome/header.rs
54
- - crates/wreq-util/src/emulate/profile/chrome/http2.rs
55
- - crates/wreq-util/src/emulate/profile/chrome/tls.rs
53
+ - crates/wreq-util/src/emulate/profile/chromium.rs
54
+ - crates/wreq-util/src/emulate/profile/chromium/chrome.rs
55
+ - crates/wreq-util/src/emulate/profile/chromium/edge.rs
56
+ - crates/wreq-util/src/emulate/profile/chromium/header.rs
57
+ - crates/wreq-util/src/emulate/profile/chromium/http2.rs
58
+ - crates/wreq-util/src/emulate/profile/chromium/opera.rs
59
+ - crates/wreq-util/src/emulate/profile/chromium/tls.rs
56
60
  - crates/wreq-util/src/emulate/profile/firefox.rs
57
61
  - crates/wreq-util/src/emulate/profile/firefox/header.rs
58
62
  - crates/wreq-util/src/emulate/profile/firefox/http2.rs
59
63
  - crates/wreq-util/src/emulate/profile/firefox/tls.rs
60
64
  - crates/wreq-util/src/emulate/profile/okhttp.rs
61
- - crates/wreq-util/src/emulate/profile/opera.rs
62
- - crates/wreq-util/src/emulate/profile/opera/header.rs
63
- - crates/wreq-util/src/emulate/profile/opera/http2.rs
64
- - crates/wreq-util/src/emulate/profile/opera/tls.rs
65
65
  - crates/wreq-util/src/emulate/profile/safari.rs
66
66
  - crates/wreq-util/src/emulate/profile/safari/header.rs
67
67
  - crates/wreq-util/src/emulate/profile/safari/http2.rs
@@ -152,6 +152,7 @@ files:
152
152
  - test/client_cookie_test.rb
153
153
  - test/client_test.rb
154
154
  - test/cookie_test.rb
155
+ - test/emulation_client_hello_test.rb
155
156
  - test/emulation_test.rb
156
157
  - test/error_handling_test.rb
157
158
  - test/fork_test.rb
@@ -200,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
201
  - !ruby/object:Gem::Version
201
202
  version: '0'
202
203
  requirements:
203
- - Rust >= 1.98
204
+ - Rust >= 1.100
204
205
  rubygems_version: 3.6.9
205
206
  specification_version: 4
206
207
  summary: Ruby bindings for wreq, an HTTP client with TLS/HTTP2 browser fingerprinting
@@ -1,116 +0,0 @@
1
- use super::*;
2
-
3
- pub fn header_initializer(
4
- sec_ch_ua: &'static str,
5
- ua: &'static str,
6
- emulation_os: Platform,
7
- ) -> HeaderMap {
8
- let mut headers = HeaderMap::new();
9
- header_chrome_sec_ch_ua!(
10
- headers,
11
- sec_ch_ua,
12
- emulation_os.platform(),
13
- emulation_os.is_mobile()
14
- );
15
- headers.insert(
16
- HeaderName::from_static("upgrade-insecure-requests"),
17
- HeaderValue::from_static("1"),
18
- );
19
- header_chrome_ua!(headers, ua);
20
- header_chrome_accept!(headers);
21
- header_chrome_sec_fetch!(headers);
22
- header_chrome_accept_encoding!(headers);
23
- headers
24
- }
25
-
26
- pub fn header_initializer_with_zstd(
27
- sec_ch_ua: &'static str,
28
- ua: &'static str,
29
- emulation_os: Platform,
30
- ) -> HeaderMap {
31
- let mut headers = HeaderMap::new();
32
- header_chrome_sec_ch_ua!(
33
- headers,
34
- sec_ch_ua,
35
- emulation_os.platform(),
36
- emulation_os.is_mobile()
37
- );
38
- headers.insert(
39
- HeaderName::from_static("upgrade-insecure-requests"),
40
- HeaderValue::from_static("1"),
41
- );
42
- header_chrome_ua!(headers, ua);
43
- header_chrome_accept!(headers);
44
- header_chrome_sec_fetch!(headers);
45
- header_chrome_accept_encoding!(zstd, headers);
46
- headers
47
- }
48
-
49
- pub fn header_initializer_with_zstd_priority(
50
- sec_ch_ua: &'static str,
51
- ua: &'static str,
52
- emulation_os: Platform,
53
- ) -> HeaderMap {
54
- let mut headers = HeaderMap::new();
55
- header_chrome_sec_ch_ua!(
56
- headers,
57
- sec_ch_ua,
58
- emulation_os.platform(),
59
- emulation_os.is_mobile()
60
- );
61
- headers.insert(
62
- HeaderName::from_static("upgrade-insecure-requests"),
63
- HeaderValue::from_static("1"),
64
- );
65
- header_chrome_ua!(headers, ua);
66
- header_chrome_accept!(headers);
67
- header_chrome_sec_fetch!(headers);
68
- header_chrome_accept_encoding!(zstd, headers);
69
- headers.insert(
70
- HeaderName::from_static("priority"),
71
- HeaderValue::from_static("u=0, i"),
72
- );
73
- headers
74
- }
75
-
76
- pub fn header_initializer_chrome155(
77
- sec_ch_ua: &'static str,
78
- ua: &'static str,
79
- emulation_os: Platform,
80
- ) -> HeaderMap {
81
- let mut headers = header_initializer_with_zstd_priority(sec_ch_ua, ua, emulation_os);
82
- // Chrome 155 enables JPEG XL in Blink; the iOS profile keeps its WebKit headers.
83
- // https://chromium.googlesource.com/chromium/src/+/cfaadc5a132d78e1828635aa8405a499f3e14864/content/common/content_constants_internal.h
84
- if !matches!(emulation_os, Platform::IOS) {
85
- headers.insert(ACCEPT, HeaderValue::from_static("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"));
86
- }
87
- headers
88
- }
89
-
90
- pub fn header_initializer_chrome152(
91
- sec_ch_ua: &'static str,
92
- ua: &'static str,
93
- emulation_os: Platform,
94
- ) -> HeaderMap {
95
- let mut headers = HeaderMap::new();
96
- header_chrome_sec_ch_ua!(
97
- headers,
98
- sec_ch_ua,
99
- emulation_os.platform(),
100
- emulation_os.is_mobile()
101
- );
102
- headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
103
- headers.insert(
104
- HeaderName::from_static("upgrade-insecure-requests"),
105
- HeaderValue::from_static("1"),
106
- );
107
- header_chrome_ua!(headers, ua);
108
- header_chrome_accept!(headers);
109
- header_chrome_sec_fetch!(headers);
110
- header_chrome_accept_encoding!(zstd_only, headers);
111
- headers.insert(
112
- HeaderName::from_static("priority"),
113
- HeaderValue::from_static("u=0, i"),
114
- );
115
- headers
116
- }
@@ -1,65 +0,0 @@
1
- macro_rules! headers_stream_dependency {
2
- () => {
3
- StreamDependency::new(StreamId::zero(), 255, true)
4
- };
5
- }
6
-
7
- macro_rules! pseudo_order {
8
- () => {
9
- PseudoOrder::builder()
10
- .extend([
11
- PseudoId::Method,
12
- PseudoId::Authority,
13
- PseudoId::Scheme,
14
- PseudoId::Path,
15
- ])
16
- .build()
17
- };
18
- }
19
-
20
- macro_rules! settings_order {
21
- () => {
22
- SettingsOrder::builder()
23
- .extend([
24
- SettingId::HeaderTableSize,
25
- SettingId::EnablePush,
26
- SettingId::MaxConcurrentStreams,
27
- SettingId::InitialWindowSize,
28
- SettingId::MaxFrameSize,
29
- SettingId::MaxHeaderListSize,
30
- SettingId::EnableConnectProtocol,
31
- SettingId::NoRfc7540Priorities,
32
- ])
33
- .build()
34
- };
35
- }
36
-
37
- macro_rules! http2_options {
38
- (@base $builder:expr) => {
39
- $builder
40
- .initial_window_size(6291456)
41
- .initial_connection_window_size(15728640)
42
- .max_header_list_size(262144)
43
- .header_table_size(65536)
44
- .headers_stream_dependency(headers_stream_dependency!())
45
- .headers_pseudo_order(pseudo_order!())
46
- .settings_order(settings_order!())
47
- };
48
-
49
- (1) => {
50
- http2_options!(@base Http2Options::builder())
51
- .max_concurrent_streams(1000)
52
- .build()
53
- };
54
- (2) => {
55
- http2_options!(@base Http2Options::builder())
56
- .max_concurrent_streams(1000)
57
- .enable_push(false)
58
- .build()
59
- };
60
- (3) => {
61
- http2_options!(@base Http2Options::builder())
62
- .enable_push(false)
63
- .build()
64
- };
65
- }