wreq-rb 0.3.0-aarch64-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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c77754dc7226226da5575889e1e1a0e1296b1709b60655c83b22bd2a63bc32b5
4
+ data.tar.gz: e90578a12a1ebddf2b4a6be21668133cdfb240ac8bf36d72de740ff794b30c27
5
+ SHA512:
6
+ metadata.gz: d51f122f30d0e2dc5e0c52a615361aa4b9af233faff5d950be27a87031d7033448a73b66b6afe6d211e8fe4cb7b9bdaecde3baa476c1bbf7c0f19a2f7859dc06
7
+ data.tar.gz: e6fc1422a4917802675aa48707594e1ed766e79b4ada4f8917d6ff1500b0855243c2358f762b3b7ddec7cfd67ff289e1f46e1a3855c3516d056d51329de772bb
data/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # wreq-rb
2
+
3
+ Ruby bindings for the [wreq](https://github.com/0x676e67/wreq) Rust HTTP client — featuring TLS fingerprint emulation, HTTP/2 support, cookie handling, and proxy support.
4
+
5
+ ## Installation
6
+
7
+ Add to your Gemfile:
8
+
9
+ ```ruby
10
+ gem "wreq-rb"
11
+ ```
12
+
13
+ Then run:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ > **Build prerequisites:** You need Rust (1.85+), Clang, CMake, and Perl installed, since wreq compiles BoringSSL from source. See [wreq's build guide](https://github.com/0x676e67/wreq#building) for details.
20
+
21
+ ## Quick Start
22
+
23
+ ```ruby
24
+ require "wreq-rb"
25
+
26
+ # Simple GET request
27
+ resp = Wreq.get("https://httpbin.org/get")
28
+ puts resp.status # => 200
29
+ puts resp.text # => response body as string
30
+ puts resp.json # => parsed Ruby Hash
31
+
32
+ # POST with JSON body
33
+ resp = Wreq.post("https://httpbin.org/post", json: { name: "wreq", version: 1 })
34
+
35
+ # POST with form data
36
+ resp = Wreq.post("https://httpbin.org/post", form: { key: "value" })
37
+
38
+ # Custom headers
39
+ resp = Wreq.get("https://httpbin.org/headers",
40
+ headers: { "X-Custom" => "value", "Accept" => "application/json" })
41
+
42
+ # Query parameters
43
+ resp = Wreq.get("https://httpbin.org/get", query: { foo: "bar", page: "1" })
44
+
45
+ # Authentication
46
+ resp = Wreq.get("https://httpbin.org/bearer", bearer: "my-token")
47
+ resp = Wreq.get("https://httpbin.org/basic-auth/user/pass", basic: ["user", "pass"])
48
+
49
+ # Browser emulation (enabled by default)
50
+ resp = Wreq.get("https://tls.peet.ws/api/all", emulation: "chrome_143")
51
+ ```
52
+
53
+ ## Using a Client
54
+
55
+ For best performance, create a `Wreq::Client` and reuse it across requests (connections are pooled internally):
56
+
57
+ ```ruby
58
+ client = Wreq::Client.new(
59
+ user_agent: "MyApp/1.0",
60
+ timeout: 30, # total timeout in seconds
61
+ connect_timeout: 5, # connection timeout
62
+ read_timeout: 15, # read timeout
63
+ redirect: 10, # follow up to 10 redirects (false to disable)
64
+ cookie_store: true, # enable cookie jar
65
+ proxy: "http://proxy:8080", # proxy URL (supports http, https, socks5)
66
+ proxy_user: "user", # proxy auth
67
+ proxy_pass: "pass",
68
+ no_proxy: true, # disable all proxies (including env-vars)
69
+ https_only: false, # restrict to HTTPS
70
+ verify_host: true, # verify TLS hostname (default: true)
71
+ verify_cert: true, # verify TLS certificate (default: true)
72
+ http1_only: false, # force HTTP/1.1 only
73
+ http2_only: false, # force HTTP/2 only
74
+ gzip: true, # enable gzip decompression
75
+ brotli: true, # enable brotli decompression
76
+ deflate: true, # enable deflate decompression
77
+ zstd: true, # enable zstd decompression
78
+ emulation: "chrome_143", # browser emulation (enabled by default)
79
+ headers: { # default headers for all requests
80
+ "Accept" => "application/json"
81
+ }
82
+ )
83
+
84
+ resp = client.get("https://api.example.com/data")
85
+ resp = client.post("https://api.example.com/data", json: { key: "value" })
86
+ ```
87
+
88
+ ## HTTP Methods
89
+
90
+ All methods are available on both `Wreq` (module-level) and `Wreq::Client` (instance-level):
91
+
92
+ | Method | Usage |
93
+ |--------|-------|
94
+ | `get(url, **opts)` | GET request |
95
+ | `post(url, **opts)` | POST request |
96
+ | `put(url, **opts)` | PUT request |
97
+ | `patch(url, **opts)` | PATCH request |
98
+ | `delete(url, **opts)` | DELETE request |
99
+ | `head(url, **opts)` | HEAD request |
100
+ | `options(url, **opts)` | OPTIONS request |
101
+
102
+ ### Per-Request Options
103
+
104
+ Pass an options hash as the second argument to any HTTP method:
105
+
106
+ | Option | Type | Description |
107
+ |--------|------|-------------|
108
+ | `headers` | Hash | Request headers |
109
+ | `body` | String | Raw request body |
110
+ | `json` | Hash/Array | JSON-serialized body (sets Content-Type) |
111
+ | `form` | Hash | URL-encoded form body |
112
+ | `query` | Hash | URL query parameters |
113
+ | `timeout` | Float | Per-request timeout (seconds) |
114
+ | `auth` | String | Raw Authorization header |
115
+ | `bearer` | String | Bearer token |
116
+ | `basic` | Array | `[username, password]` for Basic auth |
117
+ | `proxy` | String | Per-request proxy URL |
118
+ | `emulation` | String/Boolean | Per-request emulation override |
119
+
120
+ ## Browser Emulation
121
+
122
+ wreq-rb emulates real browser TLS fingerprints, HTTP/2 settings, and headers by default. **Chrome 143 is used when no emulation is specified.**
123
+
124
+ ```ruby
125
+ # Default: Chrome 143 emulation (automatic)
126
+ resp = Wreq.get("https://tls.peet.ws/api/all")
127
+
128
+ # Explicit browser emulation
129
+ client = Wreq::Client.new(emulation: "firefox_146")
130
+ client = Wreq::Client.new(emulation: "safari_18_5")
131
+ client = Wreq::Client.new(emulation: "edge_142")
132
+
133
+ # Disable emulation entirely
134
+ client = Wreq::Client.new(emulation: false)
135
+
136
+ # Emulation + custom user-agent (user_agent overrides emulation's UA)
137
+ client = Wreq::Client.new(emulation: "chrome_143", user_agent: "MyBot/1.0")
138
+
139
+ # Per-request emulation override
140
+ resp = client.get("https://example.com", emulation: "safari_26_2")
141
+ ```
142
+
143
+ ### Supported Browsers
144
+
145
+ | Browser | Example values |
146
+ |---------|---------------|
147
+ | Chrome | `chrome_100` .. `chrome_143` |
148
+ | Firefox | `firefox_109`, `firefox_146`, `firefox_private_135` |
149
+ | Safari | `safari_15_3` .. `safari_26_2`, `safari_ios_26`, `safari_ipad_18` |
150
+ | Edge | `edge_101` .. `edge_142` |
151
+ | Opera | `opera_116` .. `opera_119` |
152
+ | OkHttp | `okhttp_3_9` .. `okhttp_5` |
153
+
154
+ ## Response
155
+
156
+ The `Wreq::Response` object provides:
157
+
158
+ | Method | Returns | Description |
159
+ |--------|---------|-------------|
160
+ | `status` / `code` | Integer | HTTP status code |
161
+ | `text` / `body` | String | Response body as string |
162
+ | `body_bytes` | Array | Raw bytes |
163
+ | `headers` | Hash | Response headers |
164
+ | `json` | Hash/Array | JSON-parsed body |
165
+ | `url` | String | Final URL (after redirects) |
166
+ | `version` | String | HTTP version |
167
+ | `content_length` | Integer/nil | Content length if known |
168
+ | `success?` | Boolean | Status 2xx? |
169
+ | `redirect?` | Boolean | Status 3xx? |
170
+ | `client_error?` | Boolean | Status 4xx? |
171
+ | `server_error?` | Boolean | Status 5xx? |
172
+
173
+ ## Building from Source
174
+
175
+ ```bash
176
+ bundle install
177
+ bundle exec rake compile
178
+ bundle exec rake test
179
+ ```
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wreq
4
+ VERSION = "0.3.0"
5
+ end
data/lib/wreq-rb.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ begin
6
+ # pre-compiled extension by rake-compiler is located inside lib/wreq_rb/<ruby_version>/
7
+ RUBY_VERSION =~ /(\d+\.\d+)/
8
+ require_relative "wreq_rb/#{Regexp.last_match(1)}/wreq_rb"
9
+ rescue LoadError => e
10
+ # fallback to the locally built extension
11
+ require_relative 'wreq_rb/wreq_rb'
12
+ end
13
+
14
+ require_relative "wreq-rb/version"
15
+
16
+ module Wreq
17
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,292 @@
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>>>;
19
+
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
+
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 {
58
+ })
59
+ .service(service);
60
+
61
+ + let service = ServiceBuilder::new()
62
+ + .layer(TransferSizeLayer::new())
63
+ + .service(service);
64
+ +
65
+ #[cfg(any(
66
+ feature = "gzip",
67
+ feature = "zstd",
68
+ diff --git a/src/client/layer.rs b/src/client/layer.rs
69
+ index 05bb533f..cb0b0866 100644
70
+ --- a/src/client/layer.rs
71
+ +++ b/src/client/layer.rs
72
+ @@ -13,3 +13,4 @@ pub mod decoder;
73
+ pub mod redirect;
74
+ pub mod retry;
75
+ pub mod timeout;
76
+ +pub mod transfer_size;
77
+ diff --git a/src/client/layer/transfer_size.rs b/src/client/layer/transfer_size.rs
78
+ new file mode 100644
79
+ index 00000000..7e8a4390
80
+ --- /dev/null
81
+ +++ b/src/client/layer/transfer_size.rs
82
+ @@ -0,0 +1,176 @@
83
+ +//! Middleware that records the network transfer size (pre-decompression bytes).
84
+ +//!
85
+ +//! This layer sits **below** the decompression layer so that it sees the raw
86
+ +//! compressed bytes flowing through the body. It wraps the response body in
87
+ +//! [`CountingBody`] which counts bytes as they flow through `poll_frame()`.
88
+ +//! The running total is accessible via a shared [`TransferSizeHandle`] stored
89
+ +//! in the response extensions.
90
+ +
91
+ +use std::{
92
+ + pin::Pin,
93
+ + sync::{
94
+ + atomic::{AtomicU64, Ordering},
95
+ + Arc,
96
+ + },
97
+ + task::{Context, Poll},
98
+ +};
99
+ +
100
+ +use bytes::Bytes;
101
+ +use http::{Request, Response};
102
+ +use http_body::{Body, Frame};
103
+ +use tower::{Layer, Service};
104
+ +
105
+ +/// A shared handle to the running byte count of the response body on the wire.
106
+ +///
107
+ +/// Call [`TransferSizeHandle::get()`] **after** the body has been fully
108
+ +/// consumed to obtain the total transferred bytes.
109
+ +#[derive(Debug, Clone)]
110
+ +pub struct TransferSizeHandle(Arc<AtomicU64>);
111
+ +
112
+ +impl TransferSizeHandle {
113
+ + /// Returns the number of bytes that have flowed through the body so far.
114
+ + #[inline]
115
+ + pub fn get(&self) -> u64 {
116
+ + self.0.load(Ordering::Relaxed)
117
+ + }
118
+ +}
119
+ +
120
+ +// ===== CountingBody =====
121
+ +
122
+ +pin_project_lite::pin_project! {
123
+ + /// A body wrapper that counts raw bytes flowing through `poll_frame()`.
124
+ + pub struct CountingBody<B> {
125
+ + #[pin]
126
+ + inner: B,
127
+ + counter: Arc<AtomicU64>,
128
+ + }
129
+ +}
130
+ +
131
+ +impl<B> Body for CountingBody<B>
132
+ +where
133
+ + B: Body<Data = Bytes>,
134
+ + B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
135
+ +{
136
+ + type Data = Bytes;
137
+ + type Error = B::Error;
138
+ +
139
+ + fn poll_frame(
140
+ + self: Pin<&mut Self>,
141
+ + cx: &mut Context<'_>,
142
+ + ) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
143
+ + let this = self.project();
144
+ + match this.inner.poll_frame(cx) {
145
+ + Poll::Ready(Some(Ok(frame))) => {
146
+ + if let Some(data) = frame.data_ref() {
147
+ + this.counter
148
+ + .fetch_add(data.len() as u64, Ordering::Relaxed);
149
+ + }
150
+ + Poll::Ready(Some(Ok(frame)))
151
+ + }
152
+ + other => other,
153
+ + }
154
+ + }
155
+ +
156
+ + #[inline]
157
+ + fn is_end_stream(&self) -> bool {
158
+ + self.inner.is_end_stream()
159
+ + }
160
+ +
161
+ + #[inline]
162
+ + fn size_hint(&self) -> http_body::SizeHint {
163
+ + self.inner.size_hint()
164
+ + }
165
+ +}
166
+ +
167
+ +// ===== TransferSizeLayer / TransferSizeService =====
168
+ +
169
+ +/// A [`Layer`] that wraps responses with transfer-size tracking.
170
+ +#[derive(Debug, Clone, Copy, Default)]
171
+ +pub struct TransferSizeLayer;
172
+ +
173
+ +impl TransferSizeLayer {
174
+ + /// Create a new [`TransferSizeLayer`].
175
+ + #[inline]
176
+ + pub const fn new() -> Self {
177
+ + Self
178
+ + }
179
+ +}
180
+ +
181
+ +impl<S> Layer<S> for TransferSizeLayer {
182
+ + type Service = TransferSizeService<S>;
183
+ +
184
+ + #[inline]
185
+ + fn layer(&self, inner: S) -> Self::Service {
186
+ + TransferSizeService { inner }
187
+ + }
188
+ +}
189
+ +
190
+ +/// The [`Service`] created by [`TransferSizeLayer`].
191
+ +#[derive(Debug, Clone)]
192
+ +pub struct TransferSizeService<S> {
193
+ + inner: S,
194
+ +}
195
+ +
196
+ +impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for TransferSizeService<S>
197
+ +where
198
+ + S: Service<Request<ReqBody>, Response = Response<ResBody>>,
199
+ + ResBody: Body<Data = Bytes>,
200
+ + ResBody::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
201
+ +{
202
+ + type Response = Response<CountingBody<ResBody>>;
203
+ + type Error = S::Error;
204
+ + type Future = TransferSizeFuture<S::Future>;
205
+ +
206
+ + #[inline]
207
+ + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
208
+ + self.inner.poll_ready(cx)
209
+ + }
210
+ +
211
+ + #[inline]
212
+ + fn call(&mut self, req: Request<ReqBody>) -> Self::Future {
213
+ + TransferSizeFuture {
214
+ + inner: self.inner.call(req),
215
+ + }
216
+ + }
217
+ +}
218
+ +
219
+ +// ===== TransferSizeFuture =====
220
+ +
221
+ +pin_project_lite::pin_project! {
222
+ + /// Future returned by [`TransferSizeService`].
223
+ + pub struct TransferSizeFuture<F> {
224
+ + #[pin]
225
+ + inner: F,
226
+ + }
227
+ +}
228
+ +
229
+ +impl<F, ResBody, E> std::future::Future for TransferSizeFuture<F>
230
+ +where
231
+ + F: std::future::Future<Output = Result<Response<ResBody>, E>>,
232
+ + ResBody: Body<Data = Bytes>,
233
+ + ResBody::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
234
+ +{
235
+ + type Output = Result<Response<CountingBody<ResBody>>, E>;
236
+ +
237
+ + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
238
+ + let this = self.project();
239
+ + match this.inner.poll(cx) {
240
+ + Poll::Ready(Ok(response)) => {
241
+ + let counter = Arc::new(AtomicU64::new(0));
242
+ + let handle = TransferSizeHandle(counter.clone());
243
+ +
244
+ + let (mut parts, body) = response.into_parts();
245
+ + parts.extensions.insert(handle);
246
+ +
247
+ + let counting_body = CountingBody {
248
+ + inner: body,
249
+ + counter,
250
+ + };
251
+ +
252
+ + Poll::Ready(Ok(Response::from_parts(parts, counting_body)))
253
+ + }
254
+ + Poll::Ready(Err(e)) => Poll::Ready(Err(e)),
255
+ + Poll::Pending => Poll::Pending,
256
+ + }
257
+ + }
258
+ +}
259
+ diff --git a/src/client/response.rs b/src/client/response.rs
260
+ index d98859b9..16ed35c3 100644
261
+ --- a/src/client/response.rs
262
+ +++ 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
+ };
269
+ #[cfg(feature = "cookies")]
270
+ use crate::cookie;
271
+ @@ -91,6 +92,21 @@ impl Response {
272
+ HttpBody::size_hint(self.res.body()).exact()
273
+ }
274
+
275
+ + /// Get a handle to the transfer size counter for this response.
276
+ + ///
277
+ + /// The handle tracks the number of raw (pre-decompression) bytes received
278
+ + /// from the network as the body is consumed. Call
279
+ + /// [`TransferSizeHandle::get()`] **after** the body has been fully read
280
+ + /// (e.g. after [`bytes()`](Self::bytes) or [`text()`](Self::text)) to
281
+ + /// obtain the total network transfer size.
282
+ + ///
283
+ + /// Returns `None` only if the response was constructed outside the normal
284
+ + /// client pipeline (e.g. via `From<http::Response>`).
285
+ + #[inline]
286
+ + pub fn transfer_size_handle(&self) -> Option<&TransferSizeHandle> {
287
+ + self.res.extensions().get::<TransferSizeHandle>()
288
+ + }
289
+ +
290
+ /// Retrieve the cookies contained in the [`Response`].
291
+ ///
292
+ /// Note that invalid 'Set-Cookie' headers will be ignored.
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2016 Sean McArthur
190
+ Copyright 2026 0x676e67 <gngppz@gmail.com>
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,122 @@
1
+ # wreq
2
+
3
+ [![CI](https://github.com/0x676e67/wreq/actions/workflows/ci.yml/badge.svg)](https://github.com/0x676e67/wreq/actions/workflows/ci.yml)
4
+ [![Crates.io License](https://img.shields.io/crates/l/wreq)](https://github.com/0x676e67/wreq/blob/main/LICENSE)
5
+ [![Crates.io MSRV](https://img.shields.io/crates/msrv/wreq?logo=rust)](https://crates.io/crates/wreq)
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)
8
+
9
+ > 🚀 Help me work seamlessly with open source sharing by [sponsoring me on GitHub](https://github.com/0x676e67/0x676e67/blob/main/SPONSOR.md)
10
+
11
+ An ergonomic and modular Rust HTTP client for advanced and low-level emulation, with customizable TLS, JA3/JA4, and HTTP/2 fingerprinting capabilities.
12
+
13
+ ## Features
14
+
15
+ - Plain bodies, JSON, urlencoded, multipart
16
+ - HTTP Trailer
17
+ - Cookie Store
18
+ - Redirect Policy
19
+ - Original Header
20
+ - Rotating Proxies
21
+ - Tower Middleware
22
+ - WebSocket Upgrade
23
+ - HTTPS via BoringSSL
24
+ - HTTP/2 over TLS Emulation
25
+ - Certificate Store (CAs & mTLS)
26
+
27
+ ## Example
28
+
29
+ The following example uses the [Tokio](https://tokio.rs) runtime with optional features enabled by adding this to your `Cargo.toml`:
30
+
31
+ ```toml
32
+ [dependencies]
33
+ tokio = { version = "1", features = ["full"] }
34
+ wreq = "6.0.0-rc.28"
35
+ wreq-util = "3.0.0-rc.10"
36
+ ```
37
+
38
+ And then the code:
39
+
40
+ ```rust
41
+ use wreq::Client;
42
+ use wreq_util::Emulation;
43
+
44
+ #[tokio::main]
45
+ async fn main() -> wreq::Result<()> {
46
+ // Build a client
47
+ let client = Client::builder()
48
+ .emulation(Emulation::Safari26)
49
+ .build()?;
50
+
51
+ // Use the API you're already familiar with
52
+ let resp = client.get("https://tls.peet.ws/api/all").send().await?;
53
+ println!("{}", resp.text().await?);
54
+ Ok(())
55
+ }
56
+ ```
57
+
58
+ ## Behavior
59
+
60
+ - **HTTP/1 over TLS**
61
+
62
+ In the Rust ecosystem, most HTTP clients rely on the [http](https://github.com/hyperium/http) library, which performs well but does not preserve header case. This causes some **WAFs** to reject **HTTP/1** requests with lowercase headers (see [discussion](https://github.com/seanmonstar/reqwest/discussions/2227)). **wreq** addresses this by fully supporting **HTTP/1** header case sensitivity.
63
+
64
+ - **HTTP/2 over TLS**
65
+
66
+ Due to the complexity of **TLS** encryption and the widespread adoption of **HTTP/2**, browser fingerprints such as **JA3**, **JA4**, and **Akamai** cannot be reliably emulated using simple fingerprint strings. Instead of parsing and emulating these string-based fingerprints, **wreq** provides fine-grained control over **TLS** and **HTTP/2** extensions and settings for precise browser behavior emulation.
67
+
68
+ - **Device Emulation**
69
+
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.
71
+
72
+ ## Building
73
+
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
+ ```
80
+
81
+ Install the dependencies required to build [BoringSSL](https://github.com/google/boringssl/blob/master/BUILDING.md#build-prerequisites)
82
+
83
+ ```bash
84
+ sudo apt-get install build-essential cmake perl pkg-config libclang-dev musl-tools git -y
85
+ cargo build --release
86
+ ```
87
+
88
+ This GitHub Actions [workflow](.github/compilation-guide/build.yml) can be used to compile the project on **Linux**, **Windows**, and **macOS**.
89
+
90
+ ## Services
91
+
92
+ Help sustain the ongoing development of this open-source project by reaching out for [commercial support](mailto:gngppz@gmail.com). Receive private guidance, expert reviews, or direct access to the maintainer, with personalized technical assistance tailored to your needs.
93
+
94
+ ## License
95
+
96
+ Licensed under either of Apache License, Version 2.0 ([LICENSE](./LICENSE) or http://www.apache.org/licenses/LICENSE-2.0).
97
+
98
+ ## Contribution
99
+
100
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the [Apache-2.0](./LICENSE) license, shall be licensed as above, without any additional terms or conditions.
101
+
102
+ ## Sponsors
103
+
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>
105
+
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:
107
+
108
+ **Akamai** • **DataDome** • **Kasada** • **Incapsula**
109
+
110
+ No browser automation. Just simple API calls that return the exact cookies and headers these systems require.
111
+
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)**
113
+
114
+ ---
115
+
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>
117
+
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!
119
+
120
+ ## Accolades
121
+
122
+ A hard fork of [reqwest](https://github.com/seanmonstar/reqwest).
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wreq-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: aarch64-linux
6
+ authors:
7
+ - Yicheng Zhou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-02-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: An ergonomic Ruby HTTP client powered by Rust's wreq library, featuring
14
+ TLS fingerprint emulation (JA3/JA4), HTTP/2 support, cookie handling, proxy support,
15
+ and redirect policies.
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - lib/wreq-rb.rb
23
+ - lib/wreq-rb/version.rb
24
+ - lib/wreq_rb/2.7/wreq_rb.so
25
+ - lib/wreq_rb/3.3/wreq_rb.so
26
+ - lib/wreq_rb/3.4/wreq_rb.so
27
+ - patches/0001-add-transfer-size-tracking.patch
28
+ - vendor/wreq/LICENSE
29
+ - vendor/wreq/README.md
30
+ homepage: https://github.com/zyc9012/wreq-rb
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '2.7'
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: 3.5.dev
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.5.23
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Ruby HTTP client featuring TLS fingerprint emulation, HTTP/2 support, cookie
56
+ handling, and proxy support.
57
+ test_files: []