wreq 1.3.2.1-x86_64-linux → 1.3.5-x86_64-linux
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/crates/wreq-util/README.md +4 -2
- data/lib/wreq_ruby/3.3/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/3.4/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/4.0/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/client.rb +27 -13
- data/lib/wreq_ruby/emulate.rb +3 -0
- data/lib/wreq_ruby/http.rb +9 -2
- data/test/error_handling_test.rb +39 -0
- data/test/option_validation_test.rb +13 -4
- data/wreq.gemspec +14 -2
- metadata +1 -2
- data/VERSION +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 992057174e0eee0bf401620c8538e81eadb1bc8214b4040a74a42f0a56a9dc7b
|
|
4
|
+
data.tar.gz: ed97e8f7f0539b1cbd2915cf844758d3384c21a3e252a1fecd444af7394cc047
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8ead0e0cfd983150b492282fc71c8abedd5cc8e46237a1d6081a3c69064dab0c063536870af4f101d4a9aefc97f926345e3f34764df013c8735aff0ac538746
|
|
7
|
+
data.tar.gz: 7e8109279aeb66354c975c19306f4a9f346d217004ce85204113db867379023d2b5e8368684d16cce58b1ce9eaaeed9caf6e8926f20194219b491488a1421623
|
data/crates/wreq-util/README.md
CHANGED
|
@@ -20,12 +20,14 @@ See the [crate documentation](https://docs.rs/wreq-util/latest/wreq_util) for mo
|
|
|
20
20
|
|
|
21
21
|
## Example
|
|
22
22
|
|
|
23
|
+
This vendored copy uses the development wreq revision pinned in the [root Cargo.toml](../../Cargo.toml). Building it independently requires the same Git patches.
|
|
24
|
+
|
|
23
25
|
The following example uses the [Tokio](https://tokio.rs) runtime with optional features enabled by adding this to your `Cargo.toml`:
|
|
24
26
|
|
|
25
27
|
```toml
|
|
26
28
|
[dependencies]
|
|
27
29
|
tokio = { version = "1", features = ["full"] }
|
|
28
|
-
wreq = "
|
|
30
|
+
wreq = "0.16.1"
|
|
29
31
|
wreq-util = "3.0.0-rc"
|
|
30
32
|
```
|
|
31
33
|
|
|
@@ -38,7 +40,7 @@ use wreq_util::Emulation;
|
|
|
38
40
|
#[tokio::main]
|
|
39
41
|
async fn main() -> wreq::Result<()> {
|
|
40
42
|
// Build a client
|
|
41
|
-
let client = Client::
|
|
43
|
+
let client = Client::builder_tokio()
|
|
42
44
|
.emulation(Emulation::Chrome147)
|
|
43
45
|
.build()?;
|
|
44
46
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/wreq_ruby/client.rb
CHANGED
|
@@ -5,7 +5,7 @@ unless defined?(Wreq)
|
|
|
5
5
|
# HTTP client with extensive configuration options.
|
|
6
6
|
#
|
|
7
7
|
# This class wraps a native Rust implementation providing high-performance
|
|
8
|
-
# HTTP/1.1 and HTTP/
|
|
8
|
+
# HTTP/1.1, HTTP/2 and HTTP/3 client functionality with support for connection pooling,
|
|
9
9
|
# compression, redirects, proxies, and fine-grained timeout controls.
|
|
10
10
|
#
|
|
11
11
|
# The client is thread-safe and maintains an internal connection pool for
|
|
@@ -110,25 +110,37 @@ unless defined?(Wreq)
|
|
|
110
110
|
# allowing the reuse of local addresses in TIME_WAIT state. Useful for
|
|
111
111
|
# reducing port exhaustion in high-throughput scenarios.
|
|
112
112
|
#
|
|
113
|
-
# @param pool_idle_timeout [Integer, nil]
|
|
114
|
-
#
|
|
115
|
-
#
|
|
113
|
+
# @param pool_idle_timeout [Integer, nil] Idle connection reuse timeout in
|
|
114
|
+
# seconds. Defaults to 90 when omitted or nil. Does not expire a busy
|
|
115
|
+
# HTTP/2 or HTTP/3 connection.
|
|
116
116
|
#
|
|
117
|
-
# @param pool_max_idle_per_host [Integer, nil] Maximum
|
|
118
|
-
# connections
|
|
119
|
-
#
|
|
117
|
+
# @param pool_max_idle_per_host [Integer, nil] Maximum idle HTTP/1
|
|
118
|
+
# connections retained per compatibility group, which includes the host
|
|
119
|
+
# and connection configuration. Defaults to unlimited when omitted or
|
|
120
|
+
# nil; 0 disables connection reuse. Does not limit active connections.
|
|
120
121
|
#
|
|
121
|
-
# @param pool_max_size [Integer, nil]
|
|
122
|
-
#
|
|
123
|
-
#
|
|
122
|
+
# @param pool_max_size [Integer, nil] Maximum compatibility groups retaining
|
|
123
|
+
# idle HTTP/1 or shared HTTP/2 and HTTP/3 connections. Defaults to unlimited
|
|
124
|
+
# when omitted, nil or 0. A full pool evicts the least recently used idle
|
|
125
|
+
# group; it does not make requests wait or limit physical connections.
|
|
124
126
|
#
|
|
125
127
|
# @param http1_only [Boolean, nil] Force the client to use HTTP/1.1 only,
|
|
126
128
|
# even if HTTP/2 is available. Useful for compatibility with servers
|
|
127
|
-
# that have problematic HTTP/2 implementations.
|
|
129
|
+
# that have problematic HTTP/2 implementations. Cannot be combined with
|
|
130
|
+
# http2_only or http3_only. An explicit request version overrides this
|
|
131
|
+
# preference.
|
|
128
132
|
#
|
|
129
133
|
# @param http2_only [Boolean, nil] Force the client to use HTTP/2 only.
|
|
130
134
|
# Requests to servers that don't support HTTP/2 will fail. Cannot be
|
|
131
|
-
# combined with http1_only.
|
|
135
|
+
# combined with http1_only or http3_only. An explicit request version
|
|
136
|
+
# overrides this preference, including HTTP/3 over QUIC.
|
|
137
|
+
#
|
|
138
|
+
# @param http3_only [Boolean, nil] Use HTTP/3 over QUIC without falling back
|
|
139
|
+
# to TCP. Defaults to false when omitted or nil. Requires HTTPS and UDP
|
|
140
|
+
# connectivity. Cannot be combined with http1_only or http2_only. An
|
|
141
|
+
# explicit HTTP/1 or HTTP/2 request version overrides this preference.
|
|
142
|
+
# HTTP/HTTPS proxies, including environment proxies, cannot carry HTTP/3;
|
|
143
|
+
# use no_proxy: true, a SOCKS5 UDP proxy, or a QUIC MASQUE proxy instead.
|
|
132
144
|
#
|
|
133
145
|
# @param https_only [Boolean, nil] Reject plain HTTP connections and
|
|
134
146
|
# only allow HTTPS. Provides an additional layer of security by
|
|
@@ -149,7 +161,9 @@ unless defined?(Wreq)
|
|
|
149
161
|
# environment.
|
|
150
162
|
#
|
|
151
163
|
# @param proxy [String, nil] Proxy server URI to use for all requests.
|
|
152
|
-
# Supports HTTP, HTTPS, and
|
|
164
|
+
# Supports HTTP, HTTPS, SOCKS and QUIC proxies. HTTP/3 can use SOCKS5 UDP
|
|
165
|
+
# ASSOCIATE or a `quic://` MASQUE proxy, but not HTTP CONNECT proxies.
|
|
166
|
+
# Format: "protocol://host:port"
|
|
153
167
|
# Example: "http://proxy.example.com:8080"
|
|
154
168
|
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable.
|
|
155
169
|
# @param interface [String, nil] Bind sockets to a network interface on
|
data/lib/wreq_ruby/emulate.rb
CHANGED
|
@@ -267,6 +267,9 @@ module Wreq
|
|
|
267
267
|
# for HTTP/2 and automatic default headers. The actual implementation is
|
|
268
268
|
# provided by Rust.
|
|
269
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
|
+
#
|
|
270
273
|
# Construction generates the native configuration once. For Chrome 152/153,
|
|
271
274
|
# the TLS trust_anchors extension's ID order is randomized at construction;
|
|
272
275
|
# Chrome 154 and later sort those IDs by their raw bytes instead. Reusing this object
|
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/test/error_handling_test.rb
CHANGED
|
@@ -121,8 +121,47 @@ class ErrorHandlingTest < Minitest::Test
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
def test_proxy_tcp_connect_timeout_keeps_proxy_error
|
|
125
|
+
skip "Requires a stalled TCP handshake from a full loopback accept queue" unless RUBY_PLATFORM.include?("linux") || Gem.win_platform?
|
|
126
|
+
|
|
127
|
+
with_stalled_tcp_listener do |port|
|
|
128
|
+
%w[http socks5h].each do |scheme|
|
|
129
|
+
client = Wreq::Client.new(proxy: "#{scheme}://127.0.0.1:#{port}", connect_timeout: 1, timeout: 5)
|
|
130
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
131
|
+
|
|
132
|
+
error = assert_raises(Wreq::ProxyConnectionError, "#{scheme} proxy TCP deadline") do
|
|
133
|
+
client.get("https://127.0.0.1:443/")
|
|
134
|
+
end
|
|
135
|
+
assert_instance_of Wreq::ProxyConnectionError, error
|
|
136
|
+
assert_operator Process.clock_gettime(Process::CLOCK_MONOTONIC) - start, :>=, 0.9,
|
|
137
|
+
"#{scheme} proxy should time out, not fail immediately"
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
124
142
|
private
|
|
125
143
|
|
|
144
|
+
def with_stalled_tcp_listener
|
|
145
|
+
sockets = []
|
|
146
|
+
listener = Socket.new(:INET, :STREAM)
|
|
147
|
+
listener.bind(Socket.sockaddr_in(0, "127.0.0.1"))
|
|
148
|
+
listener.listen(0)
|
|
149
|
+
address = listener.local_address
|
|
150
|
+
|
|
151
|
+
# Leave the accept queue full and verify a subsequent dial stays pending.
|
|
152
|
+
pending = 8.times.any? do
|
|
153
|
+
socket = Socket.new(:INET, :STREAM)
|
|
154
|
+
sockets << socket
|
|
155
|
+
socket.connect_nonblock(address, exception: false) == :wait_writable &&
|
|
156
|
+
IO.select(nil, [socket], nil, 0.2).nil?
|
|
157
|
+
end
|
|
158
|
+
assert pending, "Expected a stalled TCP handshake on the loopback fixture"
|
|
159
|
+
yield address.ip_port
|
|
160
|
+
ensure
|
|
161
|
+
sockets.each(&:close)
|
|
162
|
+
listener&.close
|
|
163
|
+
end
|
|
164
|
+
|
|
126
165
|
def with_hanging_server
|
|
127
166
|
server = TCPServer.new("127.0.0.1", 0)
|
|
128
167
|
accepted = Queue.new
|
|
@@ -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
|
data/wreq.gemspec
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
3
5
|
Gem::Specification.new do |spec|
|
|
4
6
|
spec.name = "wreq"
|
|
5
7
|
# RubyGems integrates and expects `cargo`.
|
|
6
8
|
# Read more about
|
|
7
9
|
# [Gem::Ext::CargoBuilder](https://github.com/rubygems/rubygems/blob/v3.5.23/lib/rubygems/ext/cargo_builder.rb)
|
|
8
10
|
#
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
+
# wreq relies on "version" in `Cargo.toml` for the release process. You can read this gem spec with:
|
|
12
|
+
# `bundle exec ruby -e 'puts Gem::Specification.load("wreq.gemspec")'`
|
|
13
|
+
#
|
|
14
|
+
# keep in sync the key "wreq-ruby" with `Rakefile`.
|
|
15
|
+
#
|
|
16
|
+
# uses `cargo` to extract the version.
|
|
17
|
+
cargo_output = `cargo metadata --format-version 1`
|
|
18
|
+
cargo_output.force_encoding("UTF-8")
|
|
19
|
+
spec.version = JSON.parse(cargo_output.strip)
|
|
20
|
+
.fetch("packages")
|
|
21
|
+
.find { |p| p["name"] == "wreq-ruby" }
|
|
22
|
+
.fetch("version")
|
|
11
23
|
spec.authors = ["SearchApi"]
|
|
12
24
|
spec.email = ["support@searchapi.io"]
|
|
13
25
|
spec.summary = "Ruby bindings for wreq, an HTTP client with TLS/HTTP2 browser fingerprinting"
|
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.
|
|
4
|
+
version: 1.3.5
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- SearchApi
|
|
@@ -24,7 +24,6 @@ files:
|
|
|
24
24
|
- LICENSE
|
|
25
25
|
- README.md
|
|
26
26
|
- Rakefile
|
|
27
|
-
- VERSION
|
|
28
27
|
- crates/wreq-util/.github/FUNDING.yml
|
|
29
28
|
- crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md
|
|
30
29
|
- crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.3.2.1
|