wreq 1.3.2.2 → 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.
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
- /// Set an optional timeout for idle sockets being kept-alive. (in seconds)
79
+ /// Idle connection reuse timeout, in seconds.
80
80
  pool_idle_timeout: Option<u64>,
81
- /// Sets the maximum idle connection per host allowed in the pool.
81
+ /// Maximum idle HTTP/1 connections retained per compatibility group.
82
82
  pool_max_idle_per_host: Option<usize>,
83
- /// Sets the maximum number of connections in the pool.
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::builder();
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
@@ -95,7 +95,7 @@ define_ruby_enum!(
95
95
  Chrome155,
96
96
  Chrome156,
97
97
  Chrome157,
98
- Chrome158,
98
+
99
99
  Edge101,
100
100
  Edge122,
101
101
  Edge127,
@@ -115,6 +115,7 @@ define_ruby_enum!(
115
115
  Edge146,
116
116
  Edge147,
117
117
  Edge148,
118
+
118
119
  Firefox109,
119
120
  Firefox117,
120
121
  Firefox128,
@@ -136,6 +137,7 @@ define_ruby_enum!(
136
137
  Firefox150,
137
138
  Firefox151,
138
139
  Firefox152,
140
+
139
141
  SafariIos17_2,
140
142
  SafariIos17_4_1,
141
143
  SafariIos16_5,
@@ -165,6 +167,7 @@ define_ruby_enum!(
165
167
  SafariIos26_2,
166
168
  SafariIPad26,
167
169
  SafariIpad26_2,
170
+
168
171
  OkHttp3_9,
169
172
  OkHttp3_11,
170
173
  OkHttp3_13,
@@ -173,6 +176,7 @@ define_ruby_enum!(
173
176
  OkHttp4_10,
174
177
  OkHttp4_12,
175
178
  OkHttp5,
179
+
176
180
  Opera116,
177
181
  Opera117,
178
182
  Opera118,
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 = include_str!("../VERSION");
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.trim_end())?;
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))?;
@@ -46,7 +46,6 @@ class EmulationTest < Minitest::Test
46
46
  Wreq::Profile::Chrome155 => "Chrome155",
47
47
  Wreq::Profile::Chrome156 => "Chrome156",
48
48
  Wreq::Profile::Chrome157 => "Chrome157",
49
- Wreq::Profile::Chrome158 => "Chrome158",
50
49
  Wreq::Profile::Firefox152 => "Firefox152"
51
50
  }.each do |profile, name|
52
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
- error = assert_raises(ArgumentError) do
231
- Wreq::Client.new(http1_only: true, http2_only: true)
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
- assert_includes error.message, ":http1_only"
235
- assert_includes error.message, ":http2_only"
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
- # RubyGems accepts a fourth version segment, which Cargo does not.
10
- spec.version = File.read(File.join(__dir__, "VERSION")).strip
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"
@@ -44,7 +56,7 @@ Gem::Specification.new do |spec|
44
56
  # Exclude non-Ruby files from RDoc to prevent parsing errors
45
57
  spec.rdoc_options = ["--exclude", "Cargo\\..*", "--exclude", "\\.rs$"]
46
58
 
47
- spec.requirements = ["Rust >= 1.100"]
59
+ spec.requirements = ["Rust >= 1.98"]
48
60
  # use a Ruby version which:
49
61
  # - supports Rubygems with the ability of compilation of Rust gem
50
62
  # - 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.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SearchApi
@@ -27,9 +27,7 @@ files:
27
27
  - LICENSE
28
28
  - README.md
29
29
  - Rakefile
30
- - VERSION
31
30
  - build.rs
32
- - crates/README.md
33
31
  - crates/wreq-util/.github/FUNDING.yml
34
32
  - crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md
35
33
  - crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md
@@ -201,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
199
  - !ruby/object:Gem::Version
202
200
  version: '0'
203
201
  requirements:
204
- - Rust >= 1.100
202
+ - Rust >= 1.98
205
203
  rubygems_version: 3.6.9
206
204
  specification_version: 4
207
205
  summary: Ruby bindings for wreq, an HTTP client with TLS/HTTP2 browser fingerprinting
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.3.2.2
data/crates/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Local Rust dependencies
2
-
3
- - [`wreq-util`](wreq-util/) is a local copy of [0x676e67/wreq-util](https://github.com/0x676e67/wreq-util). The root [`Cargo.toml`](../Cargo.toml) resolves it from `crates/wreq-util` through `[patch.crates-io]`.
4
-
5
- When building or testing `wreq-util` on its own, use the Git dependency patches from the root manifest of the same branch. Cargo does not inherit those patches from the parent package.