wreq 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +495 -57
- data/Cargo.toml +18 -6
- data/README.md +1 -1
- data/crates/wreq-util/CHANGELOG.md +1 -0
- data/crates/wreq-util/Cargo.toml +3 -1
- data/crates/wreq-util/README.md +4 -2
- data/crates/wreq-util/examples/emulate.rs +7 -3
- data/crates/wreq-util/examples/tower_delay.rs +4 -4
- data/crates/wreq-util/src/emulate/macros.rs +0 -1
- data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +3 -3
- data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +17 -39
- data/crates/wreq-util/src/emulate/profile/chrome.rs +71 -0
- data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +11 -11
- data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +9 -14
- data/crates/wreq-util/src/emulate/profile/okhttp.rs +9 -15
- data/crates/wreq-util/src/emulate/profile/opera/http2.rs +3 -3
- data/crates/wreq-util/src/emulate/profile/opera/tls.rs +11 -5
- data/crates/wreq-util/src/emulate/profile/safari/tls.rs +14 -15
- data/crates/wreq-util/src/emulate/profile.rs +7 -9
- data/crates/wreq-util/src/emulate.rs +3 -1
- data/crates/wreq-util/src/tower/delay/layer.rs +5 -5
- data/crates/wreq-util/src/tower/delay.rs +4 -4
- data/crates/wreq-util/tests/client.rs +7 -3
- data/crates/wreq-util/tests/emulate_chrome.rs +20 -0
- data/crates/wreq-util/tests/emulate_firefox.rs +26 -21
- data/crates/wreq-util/tests/emulate_safari.rs +1 -1
- data/crates/wreq-util/tests/support/mod.rs +16 -13
- data/lib/wreq.rb +9 -9
- data/lib/wreq_ruby/client.rb +39 -25
- data/lib/wreq_ruby/emulate.rb +7 -2
- data/lib/wreq_ruby/http.rb +9 -2
- data/src/client.rs +8 -4
- data/src/emulate.rs +2 -0
- data/test/emulation_test.rb +3 -1
- data/test/option_validation_test.rb +13 -4
- metadata +1 -1
data/lib/wreq_ruby/emulate.rb
CHANGED
|
@@ -67,6 +67,8 @@ module Wreq
|
|
|
67
67
|
Chrome153 = nil
|
|
68
68
|
Chrome154 = nil
|
|
69
69
|
Chrome155 = nil
|
|
70
|
+
Chrome156 = nil
|
|
71
|
+
Chrome157 = nil
|
|
70
72
|
|
|
71
73
|
Edge101 = nil
|
|
72
74
|
Edge122 = nil
|
|
@@ -265,9 +267,12 @@ module Wreq
|
|
|
265
267
|
# for HTTP/2 and automatic default headers. The actual implementation is
|
|
266
268
|
# provided by Rust.
|
|
267
269
|
#
|
|
270
|
+
# Profiles configure TLS over TCP, HTTP/2 and request headers. They do not
|
|
271
|
+
# configure HTTP/3 or QUIC fingerprints; HTTP/3 uses the backend defaults.
|
|
272
|
+
#
|
|
268
273
|
# Construction generates the native configuration once. For Chrome 152/153,
|
|
269
274
|
# the TLS trust_anchors extension's ID order is randomized at construction;
|
|
270
|
-
# Chrome 154
|
|
275
|
+
# Chrome 154 and later sort those IDs by their raw bytes instead. Reusing this object
|
|
271
276
|
# across clients or requests retains that order. Creating a new object generates
|
|
272
277
|
# a new configuration, including a fresh shuffle for Chrome 152/153.
|
|
273
278
|
# This does not freeze other per-handshake randomness or force a new handshake
|
|
@@ -299,7 +304,7 @@ module Wreq
|
|
|
299
304
|
# This stub is for documentation only.
|
|
300
305
|
unless singleton_methods(false).include?(:new)
|
|
301
306
|
# Generates a reusable native configuration. Chrome 152/153 Trust Anchor ID
|
|
302
|
-
# order is chosen here and retained when this object is reused; Chrome 154
|
|
307
|
+
# order is chosen here and retained when this object is reused; Chrome 154–156
|
|
303
308
|
# use raw-byte sorted order. See {Emulation} for connection semantics.
|
|
304
309
|
#
|
|
305
310
|
# @param profile [Wreq::Profile, nil] Fingerprint profile to emulate
|
data/lib/wreq_ruby/http.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Wreq
|
|
|
42
42
|
|
|
43
43
|
# Value-based equality. Returns true when both represent the same HTTP method.
|
|
44
44
|
# @param other [Object]
|
|
45
|
-
# @return [Boolean]
|
|
45
|
+
# @return [Boolean]
|
|
46
46
|
unless method_defined?(:==)
|
|
47
47
|
def ==(other)
|
|
48
48
|
end
|
|
@@ -77,7 +77,14 @@ module Wreq
|
|
|
77
77
|
HTTP_10 = nil # @return [Wreq::Version] HTTP/1.0
|
|
78
78
|
HTTP_11 = nil # @return [Wreq::Version] HTTP/1.1
|
|
79
79
|
HTTP_2 = nil # @return [Wreq::Version] HTTP/2
|
|
80
|
-
|
|
80
|
+
# Select HTTP/3 over QUIC with `version: Wreq::Version::HTTP_3` on a request.
|
|
81
|
+
# To use it by default, construct a client with `http3_only: true` instead.
|
|
82
|
+
# Requires an HTTPS URL and a reachable UDP endpoint. There is no automatic
|
|
83
|
+
# Alt-Svc discovery or fallback to HTTP/1.1 or HTTP/2.
|
|
84
|
+
# HTTP CONNECT proxies cannot carry these requests; use a direct connection,
|
|
85
|
+
# a SOCKS5 UDP relay or a `quic://` MASQUE proxy.
|
|
86
|
+
# @return [Wreq::Version] HTTP/3
|
|
87
|
+
HTTP_3 = nil
|
|
81
88
|
end
|
|
82
89
|
|
|
83
90
|
# Returns a string representation of the HTTP version.
|
data/src/client.rs
CHANGED
|
@@ -76,11 +76,11 @@ struct Builder {
|
|
|
76
76
|
tcp_reuse_address: Option<bool>,
|
|
77
77
|
|
|
78
78
|
// ========= Connection pool options =========
|
|
79
|
-
///
|
|
79
|
+
/// Idle connection reuse timeout, in seconds.
|
|
80
80
|
pool_idle_timeout: Option<u64>,
|
|
81
|
-
///
|
|
81
|
+
/// Maximum idle HTTP/1 connections retained per compatibility group.
|
|
82
82
|
pool_max_idle_per_host: Option<usize>,
|
|
83
|
-
///
|
|
83
|
+
/// Maximum compatibility groups retaining reusable connections; zero is unlimited.
|
|
84
84
|
pool_max_size: Option<usize>,
|
|
85
85
|
|
|
86
86
|
// ========= Protocol options =========
|
|
@@ -88,6 +88,8 @@ struct Builder {
|
|
|
88
88
|
http1_only: Option<bool>,
|
|
89
89
|
/// Whether to use the HTTP/2 protocol only.
|
|
90
90
|
http2_only: Option<bool>,
|
|
91
|
+
/// Whether to use HTTP/3 over QUIC without falling back to TCP.
|
|
92
|
+
http3_only: Option<bool>,
|
|
91
93
|
/// Whether to use HTTPS only.
|
|
92
94
|
https_only: Option<bool>,
|
|
93
95
|
|
|
@@ -147,6 +149,7 @@ impl Builder {
|
|
|
147
149
|
.reject_conflicts([
|
|
148
150
|
(stringify!(http1_only), builder.http1_only == Some(true)),
|
|
149
151
|
(stringify!(http2_only), builder.http2_only == Some(true)),
|
|
152
|
+
(stringify!(http3_only), builder.http3_only == Some(true)),
|
|
150
153
|
])
|
|
151
154
|
.reject_conflicts([
|
|
152
155
|
(stringify!(proxy), options.is_non_nil(stringify!(proxy))),
|
|
@@ -222,7 +225,7 @@ impl Client {
|
|
|
222
225
|
.map(|jar| jar.clone_store(ruby))
|
|
223
226
|
.transpose()?;
|
|
224
227
|
let result = gvl::nogvl(|| {
|
|
225
|
-
let mut builder = wreq::Client::
|
|
228
|
+
let mut builder = wreq::Client::builder_tokio();
|
|
226
229
|
|
|
227
230
|
// Emulation options.
|
|
228
231
|
apply_option!(set_if_some_inner, builder, params.emulation, emulation);
|
|
@@ -345,6 +348,7 @@ impl Client {
|
|
|
345
348
|
// Protocol options.
|
|
346
349
|
apply_option!(set_if_true, builder, params.http1_only, http1_only, false);
|
|
347
350
|
apply_option!(set_if_true, builder, params.http2_only, http2_only, false);
|
|
351
|
+
apply_option!(set_if_true, builder, params.http3_only, http3_only, false);
|
|
348
352
|
apply_option!(set_if_some, builder, params.https_only, https_only);
|
|
349
353
|
|
|
350
354
|
// TLS options.
|
data/src/emulate.rs
CHANGED
data/test/emulation_test.rb
CHANGED
|
@@ -7,7 +7,7 @@ require "timeout"
|
|
|
7
7
|
|
|
8
8
|
class EmulationTest < Minitest::Test
|
|
9
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].each do |profile|
|
|
10
|
+
[Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile|
|
|
11
11
|
emulation = Wreq::Emulation.new(profile: profile)
|
|
12
12
|
client = Wreq::Client.new(emulation: emulation, no_proxy: true)
|
|
13
13
|
expected = capture_trust_anchors { |url| client.get(url, timeout: 5) }
|
|
@@ -44,6 +44,8 @@ class EmulationTest < Minitest::Test
|
|
|
44
44
|
Wreq::Profile::Chrome153 => "Chrome153",
|
|
45
45
|
Wreq::Profile::Chrome154 => "Chrome154",
|
|
46
46
|
Wreq::Profile::Chrome155 => "Chrome155",
|
|
47
|
+
Wreq::Profile::Chrome156 => "Chrome156",
|
|
48
|
+
Wreq::Profile::Chrome157 => "Chrome157",
|
|
47
49
|
Wreq::Profile::Firefox152 => "Firefox152"
|
|
48
50
|
}.each do |profile, name|
|
|
49
51
|
assert_equal name, profile.to_s
|
|
@@ -227,12 +227,21 @@ class OptionValidationTest < Minitest::Test
|
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
def test_protocol_only_options_are_mutually_exclusive
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
[:http1_only, :http2_only, :http3_only].combination(2) do |first, second|
|
|
231
|
+
error = assert_raises(ArgumentError) do
|
|
232
|
+
Wreq::Client.new(**{first => true, second => true})
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
assert_includes error.message, ":#{first}"
|
|
236
|
+
assert_includes error.message, ":#{second}"
|
|
232
237
|
end
|
|
233
238
|
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
assert_instance_of Wreq::Client,
|
|
240
|
+
Wreq::Client.new(http3_only: true, http1_only: false, http2_only: nil)
|
|
241
|
+
assert_instance_of Wreq::Client,
|
|
242
|
+
Wreq::Client.new(http1_only: true, http3_only: false)
|
|
243
|
+
assert_instance_of Wreq::Client,
|
|
244
|
+
Wreq::Client.new(http2_only: true, http3_only: nil)
|
|
236
245
|
end
|
|
237
246
|
|
|
238
247
|
def test_validation_reports_the_first_failed_rule
|