wreq-rb 0.5.0-x86_64-darwin → 0.5.1-x86_64-darwin

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d47db7b4b15b3c9176b81df253a636efe037d29f3c9b9adaf6c55c367ad7af77
4
- data.tar.gz: e01eeba7ef41af14046475c7569b07899aae6f8313e0d16f034f29b0e98f9b1a
3
+ metadata.gz: 286233820d389ee72fba64eb3d77111b07385142fcb3f93d45d5547571132016
4
+ data.tar.gz: 4afcd090bcfe4935ca17f14808f361a35dfd750889520466d4ef6f110acad464
5
5
  SHA512:
6
- metadata.gz: dc359608c98eb1e28331d466a034069ea2840f55b1bda100455c31a23b68c7ec6029e3c85e9337f13ef90715925c8d4018f15f778cfc1519b04573d1117442bb
7
- data.tar.gz: a5f8c4644cf5610d7d5b0277f4189a58a2aeb7f6bb508f1583c2a4c46ca72a665ac9fc16e25d79bf00df763d3aec8057492c2d8bb20f0cbeaeac9fcc620b19d9
6
+ metadata.gz: 368810d49e204b6dedca44513c692016d07ab6005593cbe835cc33cb1ba6f2075f3d81c9d6843193e40e6d250f79f49f5179b18c70e0351baa09bea6e00660a8
7
+ data.tar.gz: be9643ce9e0c1f687da0516272f995e77be46be79af881238d3a76b35e206644eedaa30ba883bd4d9bf95d3759d3d72aa04d4c59a6adafd5c609942d4d4d4b30
data/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Yicheng Zhou
191
+ Copyright 2026 Illia Zub
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
data/README.md CHANGED
@@ -47,7 +47,7 @@ resp = Wreq.get("https://httpbin.org/bearer", bearer: "my-token")
47
47
  resp = Wreq.get("https://httpbin.org/basic-auth/user/pass", basic: ["user", "pass"])
48
48
 
49
49
  # Browser emulation (enabled by default)
50
- resp = Wreq.get("https://tls.peet.ws/api/all", emulation: "chrome_143")
50
+ resp = Wreq.get("https://tls.peet.ws/api/all", emulation: "chrome_148")
51
51
  ```
52
52
 
53
53
  ## Using a Client
@@ -116,7 +116,7 @@ All methods are available on both `Wreq` (module-level) and `Wreq::Client` (inst
116
116
 
117
117
  ### Cancelling Requests
118
118
 
119
- Call `cancel` on a client to abort all in-flight requests and close their underlying connections immediately:
119
+ Call `cancel` on a client to interrupt all in-flight requests immediately:
120
120
 
121
121
  ```ruby
122
122
  client = Wreq::Client.new
@@ -124,7 +124,7 @@ client = Wreq::Client.new
124
124
  # From another thread:
125
125
  t = Thread.new { client.get("https://slow.example.com/big-download") }
126
126
  sleep 1
127
- client.cancel # all in-flight requests return with "request interrupted" error
127
+ client.cancel # all in-flight requests raise Wreq::Error with "request interrupted"
128
128
  ```
129
129
 
130
130
  ### Per-Request Options
@@ -148,25 +148,25 @@ Pass an options hash as the second argument to any HTTP method:
148
148
 
149
149
  ## Browser Emulation
150
150
 
151
- wreq-rb emulates real browser TLS fingerprints, HTTP/2 settings, and headers by default. **The lastest supported Chrome is used when no emulation is specified.**
151
+ wreq-rb emulates real browser TLS fingerprints, HTTP/2 settings, and headers by default. **The latest supported Chrome is used when no emulation is specified.**
152
152
 
153
153
  ```ruby
154
154
  resp = Wreq.get("https://tls.peet.ws/api/all")
155
155
 
156
156
  # Explicit browser emulation
157
- client = Wreq::Client.new(emulation: "firefox_146")
157
+ client = Wreq::Client.new(emulation: "firefox_151")
158
158
  client = Wreq::Client.new(emulation: "safari_18.5")
159
- client = Wreq::Client.new(emulation: "edge_142")
159
+ client = Wreq::Client.new(emulation: "edge_148")
160
160
 
161
161
  # Disable emulation entirely
162
162
  client = Wreq::Client.new(emulation: false)
163
163
 
164
164
  # Emulate a specific OS (default is macOS)
165
- client = Wreq::Client.new(emulation: "chrome_145", emulation_os: "windows")
166
- client = Wreq::Client.new(emulation: "chrome_145", emulation_os: "linux")
165
+ client = Wreq::Client.new(emulation: "chrome_148", emulation_os: "windows")
166
+ client = Wreq::Client.new(emulation: "chrome_148", emulation_os: "linux")
167
167
 
168
168
  # Emulation + custom user-agent (user_agent overrides emulation's UA)
169
- client = Wreq::Client.new(emulation: "chrome_143", user_agent: "MyBot/1.0")
169
+ client = Wreq::Client.new(emulation: "chrome_148", user_agent: "MyBot/1.0")
170
170
 
171
171
  # Per-request emulation override
172
172
  resp = client.get("https://example.com", emulation: "safari_26.2")
@@ -176,12 +176,12 @@ resp = client.get("https://example.com", emulation: "safari_26.2")
176
176
 
177
177
  | Browser | Example values |
178
178
  |---------|---------------|
179
- | Chrome | `chrome_100` .. `chrome_145` |
180
- | Firefox | `firefox_109` .. `firefox_147`, `firefox_private_135` |
181
- | Safari | `safari_15.3` .. `safari_26.2`, `safari_ios_26`, `safari_ipad_18` |
182
- | Edge | `edge_101` .. `edge_145` |
183
- | Opera | `opera_116` .. `opera_119` |
184
- | OkHttp | `okhttp_3_9` .. `okhttp_5` |
179
+ | Chrome | `chrome_100` .. `chrome_148` |
180
+ | Firefox | `firefox_109` .. `firefox_151`, `firefox_private_135` |
181
+ | Safari | `safari_15.3` .. `safari_26.4`, `safari_ios_26`, `safari_ipad_18` |
182
+ | Edge | `edge_101` .. `edge_148` |
183
+ | Opera | `opera_116` .. `opera_131` |
184
+ | OkHttp | `okhttp_3.9` .. `okhttp_5` |
185
185
 
186
186
  ## Response
187
187
 
@@ -210,3 +210,7 @@ bundle install
210
210
  bundle exec rake compile
211
211
  bundle exec rake test
212
212
  ```
213
+
214
+ ## License
215
+
216
+ wreq-rb is released under the [Apache License, Version 2.0](LICENSE).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wreq
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
Binary file
Binary file
Binary file
@@ -1,60 +1,51 @@
1
- diff --git a/src/client/http.rs b/src/client/http.rs
2
- index 10be0c83..462c77d0 100644
3
- --- a/src/client/http.rs
4
- +++ b/src/client/http.rs
5
- @@ -33,6 +33,7 @@ use self::future::Pending;
6
- feature = "deflate",
7
- ))]
8
- use super::layer::decoder::{AcceptEncoding, DecompressionLayer};
9
- +use super::layer::transfer_size::{CountingBody, TransferSizeLayer, TransferSizeService};
10
- #[cfg(feature = "ws")]
11
- use super::ws::WebSocketRequestBuilder;
12
- use super::{
13
- @@ -104,7 +105,7 @@ type Decompression<T> = super::layer::decoder::Decompression<T>;
14
- feature = "brotli",
15
- feature = "deflate"
16
- ))]
17
- -type ResponseBody = TimeoutBody<tower_http::decompression::DecompressionBody<Incoming>>;
18
- +type ResponseBody = TimeoutBody<tower_http::decompression::DecompressionBody<CountingBody<Incoming>>>;
1
+ diff --git a/src/client.rs b/src/client.rs
2
+ index 4abe25d8..76e709a8 100644
3
+ --- a/src/client.rs
4
+ +++ b/src/client.rs
5
+ @@ -49,6 +49,7 @@ use self::{
6
+ redirect::{FollowRedirect, FollowRedirectLayer},
7
+ retry::RetryPolicy,
8
+ timeout::{Timeout, TimeoutLayer, TimeoutOptions, body::TimeoutBody},
9
+ + transfer_size::{CountingBody, TransferSizeLayer, TransferSizeService},
10
+ },
11
+ request::{Request, RequestBuilder},
12
+ response::Response,
13
+ @@ -115,25 +116,30 @@ type MaybeDecompressionBody<T> = tower_http::decompression::DecompressionBody<T>
14
+ type ClientService = Timeout<
15
+ ConfigService<
16
+ MaybeDecompression<
17
+ - Retry<RetryPolicy, FollowRedirect<HttpClient<Connector, Body>, FollowRedirectPolicy>>,
18
+ + TransferSizeService<
19
+ + Retry<
20
+ + RetryPolicy,
21
+ + FollowRedirect<HttpClient<Connector, Body>, FollowRedirectPolicy>,
22
+ + >,
23
+ + >,
24
+ >,
25
+ >,
26
+ >;
19
27
 
20
- /// Response body type with timeout only (no compression features).
21
- #[cfg(not(any(
22
- @@ -113,23 +114,25 @@ type ResponseBody = TimeoutBody<tower_http::decompression::DecompressionBody<Inc
23
- feature = "brotli",
24
- feature = "deflate"
25
- )))]
26
- -type ResponseBody = TimeoutBody<Incoming>;
27
- +type ResponseBody = TimeoutBody<CountingBody<Incoming>>;
28
+ type BoxedClientService = BoxCloneSyncService<
29
+ http::Request<Body>,
30
+ - http::Response<TimeoutBody<MaybeDecompressionBody<Incoming>>>,
31
+ + http::Response<TimeoutBody<MaybeDecompressionBody<CountingBody<Incoming>>>>,
32
+ BoxError,
33
+ >;
28
34
 
29
- /// The complete HTTP client service stack with all middleware layers.
30
- type ClientService = Timeout<
31
- ResponseBodyTimeout<
32
- ConfigService<
33
- Decompression<
34
- - Retry<
35
- - RetryPolicy,
36
- - FollowRedirect<
37
- - CookieService<
38
- - MapErr<
39
- - HttpClient<Connector, Body>,
40
- - fn(client::error::Error) -> BoxError,
41
- + TransferSizeService<
42
- + Retry<
43
- + RetryPolicy,
44
- + FollowRedirect<
45
- + CookieService<
46
- + MapErr<
47
- + HttpClient<Connector, Body>,
48
- + fn(client::error::Error) -> BoxError,
49
- + >,
50
- >,
51
- + FollowRedirectPolicy,
52
- >,
53
- - FollowRedirectPolicy,
54
- >,
55
- >,
56
- >,
57
- @@ -582,6 +585,10 @@ impl ClientBuilder {
35
+ type BoxedClientServiceLayer = BoxCloneSyncServiceLayer<
36
+ BoxCloneSyncService<
37
+ http::Request<Body>,
38
+ - http::Response<MaybeDecompressionBody<Incoming>>,
39
+ + http::Response<MaybeDecompressionBody<CountingBody<Incoming>>>,
40
+ BoxError,
41
+ >,
42
+ http::Request<Body>,
43
+ - http::Response<MaybeDecompressionBody<Incoming>>,
44
+ + http::Response<MaybeDecompressionBody<CountingBody<Incoming>>>,
45
+ BoxError,
46
+ >;
47
+
48
+ @@ -593,6 +599,10 @@ impl ClientBuilder {
58
49
  })
59
50
  .service(service);
60
51
 
@@ -65,18 +56,36 @@ index 10be0c83..462c77d0 100644
65
56
  #[cfg(any(
66
57
  feature = "gzip",
67
58
  feature = "zstd",
59
+ @@ -1585,7 +1595,7 @@ impl ClientBuilder {
60
+ L: Layer<
61
+ BoxCloneSyncService<
62
+ http::Request<Body>,
63
+ - http::Response<MaybeDecompressionBody<Incoming>>,
64
+ + http::Response<MaybeDecompressionBody<CountingBody<Incoming>>>,
65
+ BoxError,
66
+ >,
67
+ > + Clone
68
+ @@ -1594,7 +1604,7 @@ impl ClientBuilder {
69
+ + 'static,
70
+ L::Service: Service<
71
+ http::Request<Body>,
72
+ - Response = http::Response<MaybeDecompressionBody<Incoming>>,
73
+ + Response = http::Response<MaybeDecompressionBody<CountingBody<Incoming>>>,
74
+ Error = BoxError,
75
+ > + Clone
76
+ + Send
68
77
  diff --git a/src/client/layer.rs b/src/client/layer.rs
69
- index 05bb533f..cb0b0866 100644
78
+ index 5c03ef4d..fe37cff0 100644
70
79
  --- a/src/client/layer.rs
71
80
  +++ b/src/client/layer.rs
72
- @@ -13,3 +13,4 @@ pub mod decoder;
81
+ @@ -12,3 +12,4 @@ pub mod decoder;
73
82
  pub mod redirect;
74
83
  pub mod retry;
75
84
  pub mod timeout;
76
85
  +pub mod transfer_size;
77
86
  diff --git a/src/client/layer/transfer_size.rs b/src/client/layer/transfer_size.rs
78
87
  new file mode 100644
79
- index 00000000..7e8a4390
88
+ index 00000000..f155ec8d
80
89
  --- /dev/null
81
90
  +++ b/src/client/layer/transfer_size.rs
82
91
  @@ -0,0 +1,176 @@
@@ -91,8 +100,8 @@ index 00000000..7e8a4390
91
100
  +use std::{
92
101
  + pin::Pin,
93
102
  + sync::{
94
- + atomic::{AtomicU64, Ordering},
95
103
  + Arc,
104
+ + atomic::{AtomicU64, Ordering},
96
105
  + },
97
106
  + task::{Context, Poll},
98
107
  +};
@@ -257,18 +266,18 @@ index 00000000..7e8a4390
257
266
  + }
258
267
  +}
259
268
  diff --git a/src/client/response.rs b/src/client/response.rs
260
- index d98859b9..16ed35c3 100644
269
+ index 3d3532af..ed478804 100644
261
270
  --- a/src/client/response.rs
262
271
  +++ b/src/client/response.rs
263
- @@ -20,6 +20,7 @@ use serde::de::DeserializeOwned;
264
- use super::{
265
- conn::HttpInfo,
266
- core::{ext::ReasonPhrase, upgrade},
267
- + layer::transfer_size::TransferSizeHandle,
268
- };
272
+ @@ -18,6 +18,7 @@ use mime::Mime;
273
+ use serde::de::DeserializeOwned;
274
+ use wreq_proto::ext::ReasonPhrase;
275
+
276
+ +use super::layer::transfer_size::TransferSizeHandle;
269
277
  #[cfg(feature = "cookies")]
270
278
  use crate::cookie;
271
- @@ -91,6 +92,21 @@ impl Response {
279
+ use crate::{
280
+ @@ -97,6 +98,21 @@ impl Response {
272
281
  HttpBody::size_hint(self.res.body()).exact()
273
282
  }
274
283
 
@@ -4,11 +4,14 @@
4
4
  [![Crates.io License](https://img.shields.io/crates/l/wreq)](https://github.com/0x676e67/wreq/blob/main/LICENSE)
5
5
  [![Crates.io MSRV](https://img.shields.io/crates/msrv/wreq?logo=rust)](https://crates.io/crates/wreq)
6
6
  [![crates.io](https://img.shields.io/crates/v/wreq.svg?logo=rust)](https://crates.io/crates/wreq)
7
- [![docs.rs](https://img.shields.io/docsrs/wreq?logo=rust)](https://docs.rs/wreq)
7
+ [![Discord chat][discord-badge]][discord-url]
8
+
9
+ [discord-badge]: https://img.shields.io/discord/1486741856397164788.svg?logo=discord
10
+ [discord-url]: https://discord.gg/rfbvyFkgq3
8
11
 
9
12
  > 🚀 Help me work seamlessly with open source sharing by [sponsoring me on GitHub](https://github.com/0x676e67/0x676e67/blob/main/SPONSOR.md)
10
13
 
11
- An ergonomic and modular Rust HTTP client for advanced and low-level emulation, with customizable TLS, JA3/JA4, and HTTP/2 fingerprinting capabilities.
14
+ An ergonomic and modular Rust HTTP Client for high-fidelity protocol matching, featuring customizable TLS, JA3/JA4, and HTTP/2 signature capabilities.
12
15
 
13
16
  ## Features
14
17
 
@@ -21,8 +24,9 @@ An ergonomic and modular Rust HTTP client for advanced and low-level emulation,
21
24
  - Tower Middleware
22
25
  - WebSocket Upgrade
23
26
  - HTTPS via BoringSSL
24
- - HTTP/2 over TLS Emulation
27
+ - HTTP/2 over TLS Parity
25
28
  - Certificate Store (CAs & mTLS)
29
+ - Multiple Runtime (Tokio, Compio)
26
30
 
27
31
  ## Example
28
32
 
@@ -31,8 +35,8 @@ The following example uses the [Tokio](https://tokio.rs) runtime with optional f
31
35
  ```toml
32
36
  [dependencies]
33
37
  tokio = { version = "1", features = ["full"] }
34
- wreq = "6.0.0-rc.28"
35
- wreq-util = "3.0.0-rc.10"
38
+ wreq = "6.0.0-rc"
39
+ wreq-util = "3.0.0-rc"
36
40
  ```
37
41
 
38
42
  And then the code:
@@ -67,18 +71,13 @@ Due to the complexity of **TLS** encryption and the widespread adoption of **HTT
67
71
 
68
72
  - **Device Emulation**
69
73
 
70
- Most browser device models share identical **TLS** and **HTTP/2** configurations, differing only in the **User-Agent** string. Common browser device emulation templates are maintained in [wreq-util](https://github.com/0x676e67/wreq-util), a companion utility crate.
74
+ **TLS** and **HTTP/2** fingerprints are often identical across various browser models because these underlying protocols evolve slower than browser release cycles. **100+ browser device emulation profiles** are maintained in [wreq-util](https://github.com/0x676e67/wreq-util).
71
75
 
72
76
  ## Building
73
77
 
74
- Compiling alongside **openssl-sys** can cause symbol conflicts with **boring-sys** that lead to [link failures](https://github.com/cloudflare/boring/issues/197), and on **Linux** and **Android** this can be avoided by enabling the **prefix-symbols** feature.
75
-
76
- ```toml
77
- [dependencies]
78
- wreq = { version = "6.0.0-rc.27", features = ["prefix-symbols"] }
79
- ```
78
+ Compiling alongside **openssl-sys** can cause symbol conflicts with **boringssl** that lead to [link failures](https://github.com/cloudflare/boring/issues/197), and on **Linux** and **Android** this can be avoided by enabling the **`prefix-symbols`** feature.
80
79
 
81
- Install the dependencies required to build [BoringSSL](https://github.com/google/boringssl/blob/master/BUILDING.md#build-prerequisites)
80
+ Install [BoringSSL build dependencies](https://github.com/google/boringssl/blob/master/BUILDING.md#build-prerequisites) and build with:
82
81
 
83
82
  ```bash
84
83
  sudo apt-get install build-essential cmake perl pkg-config libclang-dev musl-tools git -y
@@ -101,21 +100,27 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
101
100
 
102
101
  ## Sponsors
103
102
 
104
- <a href="https://hypersolutions.co/?utm_source=github&utm_medium=readme&utm_campaign=wreq" target="_blank"><img src="https://raw.githubusercontent.com/0x676e67/wreq/main/.github/assets/hypersolutions.jpg" height="47" width="149"></a>
103
+ <a href="https://captcha.fun/?utm_source=github&utm_medium=readme&utm_campaign=wreq" target="_blank"><img src="https://www.captcha.fun/banner.jpg" height="47" width="149"></a>
105
104
 
106
- TLS fingerprinting alone isn't enough for modern bot protection. **[Hyper Solutions](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=wreq)** provides the missing piece - API endpoints that generate valid antibot tokens for:
105
+ **Solve reCAPTCHA in less than 2 seconds**
107
106
 
108
- **Akamai** **DataDome** **Kasada** **Incapsula**
107
+ **[Captcha.fun](https://captcha.fun/?utm_source=github&utm_medium=readme&utm_campaign=wreq)** delivers fast, reliable CAPTCHA solving built for automation at scale.
109
108
 
110
- No browser automation. Just simple API calls that return the exact cookies and headers these systems require.
109
+ With simple API integration, consistent performance, and competitive pricing, it's an easy way to keep your workflows moving without delays—use code **`WREQ`** for **10% bonus credits**.
111
110
 
112
- 🚀 **[Get Your API Key](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=wreq)** | 📖 **[Docs](https://docs.justhyped.dev)** | 💬 **[Discord](https://discord.gg/akamai)**
111
+ **[Dashboard](https://dash.captcha.fun/)** | **[Docs](http://docs.captcha.fun/)** | **[Discord](https://discord.gg/captchafun)**
113
112
 
114
113
  ---
115
114
 
116
- <a href="https://dashboard.capsolver.com/passport/register?inviteCode=y7CtB_a-3X6d" target="_blank"><img src="https://raw.githubusercontent.com/0x676e67/wreq/main/.github/assets/capsolver.jpg" height="47" width="149"></a>
115
+ <a href="https://hypersolutions.co/?utm_source=github&utm_medium=readme&utm_campaign=wreq" target="_blank"><img src="https://raw.githubusercontent.com/0x676e67/wreq/main/.github/assets/hypersolutions.jpg" height="47" width="149"></a>
116
+
117
+ TLS fingerprinting alone isn't enough for modern bot protection. **[Hyper Solutions](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=wreq)** provides the missing piece - API endpoints that generate valid antibot tokens for:
118
+
119
+ **Akamai** • **DataDome** • **Kasada** • **Incapsula**
120
+
121
+ No browser automation. Just simple API calls that return the exact cookies and headers these systems require.
117
122
 
118
- [CapSolver](https://www.capsolver.com/?utm_source=github&utm_medium=banner_repo&utm_campaign=wreq) leverages AI-powered Auto Web Unblock to bypass Captchas effortlessly, providing fast, reliable, and cost-effective data access with seamless integration into Colly, Puppeteer, and Playwright—use code **`RQUEST`** for a 6% bonus!
123
+ **[Dashboard](https://hypersolutions.co?utm_source=github&utm_medium=readme&utm_campaign=wreq)** | **[Docs](https://docs.justhyped.dev)** | **[Discord](https://discord.gg/akamai)**
119
124
 
120
125
  ## Accolades
121
126
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Yicheng Zhou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-03-17 00:00:00.000000000 Z
12
+ date: 2026-06-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: An ergonomic Ruby HTTP client powered by Rust's wreq library, featuring
15
15
  TLS fingerprint emulation (JA3/JA4), HTTP/2 support, cookie handling, proxy support,
@@ -20,6 +20,7 @@ executables:
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - LICENSE
23
24
  - README.md
24
25
  - exe/wreq
25
26
  - lib/wreq-rb.rb
@@ -28,12 +29,11 @@ files:
28
29
  - lib/wreq_rb/3.3/wreq_rb.bundle
29
30
  - lib/wreq_rb/3.4/wreq_rb.bundle
30
31
  - patches/0001-add-transfer-size-tracking.patch
31
- - patches/0002-add-cancel-connections.patch
32
32
  - vendor/wreq/LICENSE
33
33
  - vendor/wreq/README.md
34
34
  homepage: https://github.com/serpapi/wreq-rb
35
35
  licenses:
36
- - MIT
36
+ - Apache-2.0
37
37
  metadata: {}
38
38
  post_install_message:
39
39
  rdoc_options: []
@@ -1,181 +0,0 @@
1
- diff --git a/src/client/http.rs b/src/client/http.rs
2
- index 462c77d0..6231e700 100644
3
- --- a/src/client/http.rs
4
- +++ b/src/client/http.rs
5
- @@ -171,6 +171,7 @@ type ClientRef = Either<ClientService, BoxedClientService>;
6
- #[derive(Clone)]
7
- pub struct Client {
8
- inner: Arc<ClientRef>,
9
- + cancel_connections: Arc<dyn Fn() + Send + Sync>,
10
- }
11
-
12
- /// A [`ClientBuilder`] can be used to create a [`Client`] with custom configuration.
13
- @@ -439,6 +440,14 @@ impl Client {
14
- let fut = Oneshot::new(self.inner.as_ref().clone(), req);
15
- Pending::request(uri, fut)
16
- }
17
- +
18
- + /// Cancel all background connection tasks immediately.
19
- + ///
20
- + /// This force-drops every tracked H1/H2 connection task, causing the
21
- + /// underlying TCP socket to close abruptly.
22
- + pub fn cancel_connections(&self) {
23
- + (self.cancel_connections)()
24
- + }
25
- }
26
-
27
- impl tower::Service<Request> for Client {
28
- @@ -495,7 +504,7 @@ impl ClientBuilder {
29
- }
30
-
31
- // Create base client service
32
- - let service = {
33
- + let (service, cancel_connections) = {
34
- let (tls_options, http1_options, http2_options) = config.transport_options.into();
35
-
36
- let resolver = {
37
- @@ -555,7 +564,7 @@ impl ClientBuilder {
38
- .build(config.connector_layers)?;
39
-
40
- // Build client
41
- - HttpClient::builder(TokioExecutor::new())
42
- + let http_client = HttpClient::builder(TokioExecutor::new())
43
- .http1_options(http1_options)
44
- .http2_options(http2_options)
45
- .http2_only(matches!(config.http_version_pref, HttpVersionPref::Http2))
46
- @@ -564,8 +573,10 @@ impl ClientBuilder {
47
- .pool_idle_timeout(config.pool_idle_timeout)
48
- .pool_max_idle_per_host(config.pool_max_idle_per_host)
49
- .pool_max_size(config.pool_max_size)
50
- - .build(connector)
51
- - .map_err(Into::into as _)
52
- + .build(connector);
53
- + // Capture abort fn before tower layers consume the client
54
- + let cancel_connections = http_client.cancel_connections_fn();
55
- + (http_client.map_err(Into::into as _), cancel_connections)
56
- };
57
-
58
- // Configured client service with layers
59
- @@ -633,6 +644,7 @@ impl ClientBuilder {
60
-
61
- Ok(Client {
62
- inner: Arc::new(client),
63
- + cancel_connections,
64
- })
65
- }
66
-
67
- diff --git a/src/client/http/client.rs b/src/client/http/client.rs
68
- index a29c52dd..7f6ce68f 100644
69
- --- a/src/client/http/client.rs
70
- +++ b/src/client/http/client.rs
71
- @@ -10,7 +10,7 @@ use std::{
72
- future::Future,
73
- num::NonZeroU32,
74
- pin::Pin,
75
- - sync::Arc,
76
- + sync::{Arc, Mutex},
77
- task::{self, Poll},
78
- time::Duration,
79
- };
80
- @@ -119,6 +119,7 @@ pub struct HttpClient<C, B> {
81
- h1_builder: conn::http1::Builder,
82
- h2_builder: conn::http2::Builder<Exec>,
83
- pool: pool::Pool<PoolClient<B>, ConnectIdentity>,
84
- + conn_abort_handles: Arc<Mutex<Vec<tokio::task::AbortHandle>>>,
85
- }
86
-
87
- #[derive(Clone, Copy)]
88
- @@ -452,8 +453,8 @@ where
89
- + Send
90
- + Unpin
91
- + 'static {
92
- - let executor = self.exec.clone();
93
- let pool = self.pool.clone();
94
- + let conn_abort_handles = self.conn_abort_handles.clone();
95
-
96
- let h1_builder = self.h1_builder.clone();
97
- let h2_builder = self.h2_builder.clone();
98
- @@ -513,10 +514,17 @@ where
99
- trace!(
100
- "http2 handshake complete, spawning background dispatcher task"
101
- );
102
- - executor.execute(
103
- - conn.map_err(|_e| debug!("client connection error: {}", _e))
104
- - .map(|_| ()),
105
- - );
106
- + let h2_conn_future = conn
107
- + .map_err(|_e| debug!("client connection error: {}", _e))
108
- + .map(|_| ());
109
- + let abort_handle = tokio::spawn(h2_conn_future).abort_handle();
110
- + {
111
- + let mut handles = conn_abort_handles.lock().unwrap_or_else(|e| e.into_inner());
112
- + if handles.len() >= 64 {
113
- + handles.retain(|h| !h.is_finished());
114
- + }
115
- + handles.push(abort_handle);
116
- + }
117
-
118
- // Wait for 'conn' to ready up before we
119
- // declare this tx as usable
120
- @@ -544,8 +552,7 @@ where
121
- // Spawn the connection task in the background using the executor.
122
- // The task manages the HTTP/1.1 connection, including upgrades (e.g., WebSocket).
123
- // Errors are sent via err_tx to ensure they can be checked if the sender (tx) fails.
124
- - executor.execute(
125
- - conn.with_upgrades()
126
- + let h1_conn_future = conn.with_upgrades()
127
- .map_err(|e| {
128
- // Log the connection error at debug level for diagnostic purposes.
129
- debug!("client connection error: {:?}", e);
130
- @@ -555,8 +562,15 @@ where
131
- // (e.g., if the receiver is dropped, which is handled later).
132
- let _ = err_tx.send(e);
133
- })
134
- - .map(|_| ()),
135
- - );
136
- + .map(|_| ());
137
- + let abort_handle = tokio::spawn(h1_conn_future).abort_handle();
138
- + {
139
- + let mut handles = conn_abort_handles.lock().unwrap_or_else(|e| e.into_inner());
140
- + if handles.len() >= 64 {
141
- + handles.retain(|h| !h.is_finished());
142
- + }
143
- + handles.push(abort_handle);
144
- + }
145
-
146
- // Log that the client is waiting for the connection to be ready.
147
- // Readiness indicates the sender (tx) can accept a request without blocking. More actions
148
- @@ -682,10 +696,25 @@ impl<C: Clone, B> Clone for HttpClient<C, B> {
149
- h2_builder: self.h2_builder.clone(),
150
- connector: self.connector.clone(),
151
- pool: self.pool.clone(),
152
- + conn_abort_handles: self.conn_abort_handles.clone(),
153
- }
154
- }
155
- }
156
-
157
- +impl<C, B> HttpClient<C, B> {
158
- + /// Returns a closure that cancels all tracked connection tasks when called.
159
- + /// Each call drains the handle list and aborts every stored task.
160
- + pub fn cancel_connections_fn(&self) -> Arc<dyn Fn() + Send + Sync + 'static> {
161
- + let handles = self.conn_abort_handles.clone();
162
- + Arc::new(move || {
163
- + let mut guard = handles.lock().unwrap_or_else(|e| e.into_inner());
164
- + for handle in guard.drain(..) {
165
- + handle.abort();
166
- + }
167
- + })
168
- + }
169
- +}
170
- +
171
- /// A pooled HTTP connection that can send requests
172
- struct PoolClient<B> {
173
- conn_info: Connected,
174
- @@ -998,6 +1027,7 @@ impl Builder {
175
- h2_builder: self.h2_builder,
176
- connector,
177
- pool: pool::Pool::new(self.pool_config, exec, timer),
178
- + conn_abort_handles: Arc::new(Mutex::new(Vec::new())),
179
- }
180
- }
181
- }