wreq 1.3.2.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 +470 -41
- data/Cargo.toml +11 -3
- data/crates/wreq-util/Cargo.toml +1 -0
- 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 +6 -39
- data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +11 -11
- data/crates/wreq-util/src/emulate/profile/okhttp.rs +2 -3
- data/crates/wreq-util/src/emulate/profile/opera/http2.rs +3 -3
- data/crates/wreq-util/src/emulate/profile.rs +5 -7
- 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_firefox.rs +26 -21
- data/crates/wreq-util/tests/support/mod.rs +1 -1
- 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/src/client.rs +8 -4
- data/src/lib.rs +2 -2
- data/test/option_validation_test.rb +13 -4
- data/wreq.gemspec +14 -2
- metadata +1 -2
- data/VERSION +0 -1
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/lib.rs
CHANGED
|
@@ -25,7 +25,7 @@ use crate::{
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const RUBY_MODULE_NAME: &str = "Wreq";
|
|
28
|
-
const VERSION: &str =
|
|
28
|
+
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
29
29
|
|
|
30
30
|
/// Send a HTTP request.
|
|
31
31
|
#[inline]
|
|
@@ -85,7 +85,7 @@ pub fn patch(ruby: &Ruby, args: &[Value]) -> Result<Response, magnus::Error> {
|
|
|
85
85
|
#[magnus::init]
|
|
86
86
|
fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
87
87
|
let gem_module = ruby.define_module(RUBY_MODULE_NAME)?;
|
|
88
|
-
gem_module.const_set("VERSION", VERSION
|
|
88
|
+
gem_module.const_set("VERSION", VERSION)?;
|
|
89
89
|
error::include(ruby, &gem_module)?;
|
|
90
90
|
gem_module.define_module_function("request", magnus::function!(request, -1))?;
|
|
91
91
|
gem_module.define_module_function("get", magnus::function!(get, -1))?;
|
|
@@ -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.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SearchApi
|
|
@@ -27,7 +27,6 @@ files:
|
|
|
27
27
|
- LICENSE
|
|
28
28
|
- README.md
|
|
29
29
|
- Rakefile
|
|
30
|
-
- VERSION
|
|
31
30
|
- build.rs
|
|
32
31
|
- crates/wreq-util/.github/FUNDING.yml
|
|
33
32
|
- crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.3.2.1
|