wreq-rb 0.4.0-aarch64-linux → 0.5.1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f120dd910385609c611944ca7d93171058bba1ea8ba4a16e95dd1d77a5f5e9e3
4
- data.tar.gz: 040bf96d8addb498772fce92f7267233f03d87aeabaf60723efd8f01dfb714f4
3
+ metadata.gz: 81136f1b3df3f8dd9186c9fe73cd5cfbdb633027724da6688447ab34cd98da63
4
+ data.tar.gz: 805228038bb0f9b54b93beec65f069221cc9ddd393c80a878b3db614433fb6fb
5
5
  SHA512:
6
- metadata.gz: 7fe68f42eeef23d296f15492036b2e13ae9f2c05c107f2a8d208da1e576bb35c79d0f048f41c81037505fb098816b5b1e4656d70621ca3349a588d1b75149784
7
- data.tar.gz: dd6d4cbf5c65c03f7835431414d0c933a6fa0ab356951e5f59c1b288abe5b6058c4f2f3ec05fb66a9ad008bf77d406a64a52428221921c39c0309bd31e9a1fed
6
+ metadata.gz: b1b57a77798fdb61ef986680b7c508ef073dc9ec6a9b5393e108e7ed5a5433bfa8f72159cc8e07c47b7719d0d054a9f829e5bc870ce205331a7624651152672d
7
+ data.tar.gz: 9af68ee94edd868ab579dbd40aebd3654b5d3fe363f07325eea8426a209a055bf2a0a1d3c70f23848e07effce78435b2cd898771b95765f4fd2a7b2a4c7af7e0
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
@@ -77,9 +77,23 @@ client = Wreq::Client.new(
77
77
  zstd: true, # enable zstd decompression
78
78
  emulation: "chrome_143", # browser emulation (enabled by default)
79
79
  emulation_os: "windows", # OS emulation: windows, macos (default), linux, android, ios
80
+ header_order: [ # wire order of headers (names only, case-sensitive)
81
+ "host", # listed headers appear first in the given order, remaining
82
+ "user-agent", # emulation headers follow.
83
+ "accept",
84
+ ],
80
85
  headers: { # default headers for all requests
81
86
  "Accept" => "application/json"
82
- }
87
+ },
88
+ referer: true, # auto-set Referer header on redirects (default: true)
89
+ pool_max_idle_per_host: 10, # max idle connections per host
90
+ pool_max_size: 100, # max total connections in the pool
91
+ tcp_nodelay: true, # disable Nagle algorithm (default: true)
92
+ tcp_keepalive: 15, # SO_KEEPALIVE interval in seconds (default: 15)
93
+ local_address: "1.2.3.4", # bind outgoing connections to this source IP
94
+ tls_sni: true, # send SNI in TLS handshake (default: true)
95
+ min_tls_version: "tls1.2", # minimum TLS version: tls1.0, tls1.1, tls1.2, tls1.3
96
+ max_tls_version: "tls1.3", # maximum TLS version
83
97
  )
84
98
 
85
99
  resp = client.get("https://api.example.com/data")
@@ -100,6 +114,19 @@ All methods are available on both `Wreq` (module-level) and `Wreq::Client` (inst
100
114
  | `head(url, **opts)` | HEAD request |
101
115
  | `options(url, **opts)` | OPTIONS request |
102
116
 
117
+ ### Cancelling Requests
118
+
119
+ Call `cancel` on a client to interrupt all in-flight requests immediately:
120
+
121
+ ```ruby
122
+ client = Wreq::Client.new
123
+
124
+ # From another thread:
125
+ t = Thread.new { client.get("https://slow.example.com/big-download") }
126
+ sleep 1
127
+ client.cancel # all in-flight requests raise Wreq::Error with "request interrupted"
128
+ ```
129
+
103
130
  ### Per-Request Options
104
131
 
105
132
  Pass an options hash as the second argument to any HTTP method:
@@ -121,40 +148,40 @@ Pass an options hash as the second argument to any HTTP method:
121
148
 
122
149
  ## Browser Emulation
123
150
 
124
- 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.**
125
152
 
126
153
  ```ruby
127
154
  resp = Wreq.get("https://tls.peet.ws/api/all")
128
155
 
129
156
  # Explicit browser emulation
130
- client = Wreq::Client.new(emulation: "firefox_146")
131
- client = Wreq::Client.new(emulation: "safari_18_5")
132
- client = Wreq::Client.new(emulation: "edge_142")
157
+ client = Wreq::Client.new(emulation: "firefox_151")
158
+ client = Wreq::Client.new(emulation: "safari_18.5")
159
+ client = Wreq::Client.new(emulation: "edge_148")
133
160
 
134
161
  # Disable emulation entirely
135
162
  client = Wreq::Client.new(emulation: false)
136
163
 
137
164
  # Emulate a specific OS (default is macOS)
138
- client = Wreq::Client.new(emulation: "chrome_145", emulation_os: "windows")
139
- 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")
140
167
 
141
168
  # Emulation + custom user-agent (user_agent overrides emulation's UA)
142
- 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")
143
170
 
144
171
  # Per-request emulation override
145
- resp = client.get("https://example.com", emulation: "safari_26_2")
172
+ resp = client.get("https://example.com", emulation: "safari_26.2")
146
173
  ```
147
174
 
148
175
  ### Supported Browsers
149
176
 
150
177
  | Browser | Example values |
151
178
  |---------|---------------|
152
- | Chrome | `chrome_100` .. `chrome_145` |
153
- | Firefox | `firefox_109` .. `firefox_147`, `firefox_private_135` |
154
- | Safari | `safari_15.3` .. `safari_26.2`, `safari_ios_26`, `safari_ipad_18` |
155
- | Edge | `edge_101` .. `edge_145` |
156
- | Opera | `opera_116` .. `opera_119` |
157
- | 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` |
158
185
 
159
186
  ## Response
160
187
 
@@ -183,3 +210,7 @@ bundle install
183
210
  bundle exec rake compile
184
211
  bundle exec rake test
185
212
  ```
213
+
214
+ ## License
215
+
216
+ wreq-rb is released under the [Apache License, Version 2.0](LICENSE).
data/exe/wreq ADDED
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "optparse"
5
+ require "json"
6
+ require "wreq-rb"
7
+
8
+ cfg = {
9
+ method: nil,
10
+ headers: {},
11
+ include: false,
12
+ silent: false,
13
+ redirect: 10,
14
+ verify_cert: true,
15
+ verify_host: true,
16
+ pretty: false,
17
+ }
18
+ req = {}
19
+
20
+ parser = OptionParser.new do |o|
21
+ o.banner = "Usage: wreq [METHOD] URL [options]"
22
+
23
+ o.separator ""
24
+ o.separator "Request:"
25
+
26
+ o.on("-X", "--request METHOD", "HTTP method (default: GET)") { |m| cfg[:method] = m.upcase }
27
+
28
+ o.on("-H", "--header LINE", 'Request header, e.g. "Accept: application/json" (repeatable)') do |h|
29
+ name, _, value = h.partition(":")
30
+ cfg[:headers][name.strip] = value.strip
31
+ end
32
+
33
+ o.on("-d", "--data DATA",
34
+ "Request body. Prefix with @ to read from file, e.g. @body.json") do |d|
35
+ cfg[:method] ||= "POST"
36
+ if d.start_with?("@")
37
+ path = d[1..]
38
+ abort "wreq: cannot read '#{path}': file not found" unless File.exist?(path)
39
+ req[:body] = File.binread(path)
40
+ else
41
+ req[:body] = d
42
+ end
43
+ end
44
+
45
+ o.on("--json DATA",
46
+ "JSON body (sets Content-Type: application/json). Prefix with @ for file.") do |d|
47
+ cfg[:method] ||= "POST"
48
+ raw = d.start_with?("@") ? File.read(d[1..]) : d
49
+ begin
50
+ req[:json] = JSON.parse(raw)
51
+ rescue JSON::ParserError => e
52
+ abort "wreq: invalid JSON: #{e.message}"
53
+ end
54
+ end
55
+
56
+ o.on("--form PAIR", "Form field as key=value (repeatable)") do |f|
57
+ cfg[:method] ||= "POST"
58
+ key, _, val = f.partition("=")
59
+ (req[:form] ||= {})[key] = val
60
+ end
61
+
62
+ o.on("-q", "--query PAIR", "Query parameter as key=value (repeatable)") do |q|
63
+ key, _, val = q.partition("=")
64
+ (req[:query] ||= {})[key] = val
65
+ end
66
+
67
+ o.separator ""
68
+ o.separator "Auth:"
69
+
70
+ o.on("-u", "--user USER[:PASS]", "Basic auth credentials") do |u|
71
+ user, _, pass = u.partition(":")
72
+ req[:basic] = [user, pass]
73
+ end
74
+
75
+ o.on("--bearer TOKEN", "Bearer token auth") { |t| req[:bearer] = t }
76
+
77
+ o.separator ""
78
+ o.separator "Output:"
79
+
80
+ o.on("-i", "--include", "Include response headers in stdout before the body") do
81
+ cfg[:include] = true
82
+ end
83
+
84
+ o.on("-s", "--silent", "Suppress body output") { cfg[:silent] = true }
85
+
86
+ o.on("-o", "--output FILE", "Write body to FILE") { |f| cfg[:output] = f }
87
+
88
+ o.on("--pretty", "Pretty-print JSON response bodies") { cfg[:pretty] = true }
89
+
90
+ o.separator ""
91
+ o.separator "Connection:"
92
+
93
+ o.on("-L", "--location", "Follow redirects (default: on, max 10)") { cfg[:redirect] = 10 }
94
+ o.on("--no-location", "Do not follow redirects") { cfg[:redirect] = false }
95
+ o.on("--max-redirects N", Integer, "Max redirects (default: 10)") { |n| cfg[:redirect] = n }
96
+
97
+ o.on("-k", "--insecure", "Skip TLS certificate verification") do
98
+ cfg[:verify_cert] = false
99
+ cfg[:verify_host] = false
100
+ end
101
+
102
+ o.on("-x", "--proxy URL", "Proxy URL (e.g. http://host:port)") { |p| cfg[:proxy] = p }
103
+
104
+ o.on("--local-address IP", "Bind outgoing connections to this source IP address") do |ip|
105
+ cfg[:local_address] = ip
106
+ end
107
+
108
+ o.on("--timeout SECS", Float, "Total timeout in seconds") { |t| cfg[:timeout] = t }
109
+ o.on("--connect-timeout SECS", Float, "Connection timeout in seconds") { |t| cfg[:connect_timeout] = t }
110
+
111
+ o.on("--http1", "Force HTTP/1.1") { cfg[:http1_only] = true }
112
+ o.on("--http2", "Force HTTP/2") { cfg[:http2_only] = true }
113
+
114
+ o.separator ""
115
+ o.separator "Emulation:"
116
+
117
+ o.on("--emulation PROFILE",
118
+ "Browser emulation profile (e.g. chrome_145, firefox_147, safari_26.2)") do |e|
119
+ cfg[:emulation] = e
120
+ end
121
+
122
+ o.on("--emulation-os OS",
123
+ "Emulation OS override: windows, macos, linux, android, ios") do |os|
124
+ cfg[:emulation_os] = os
125
+ end
126
+
127
+ o.on("--no-emulation", "Disable browser emulation entirely") { cfg[:emulation] = false }
128
+
129
+ o.on("-A", "--user-agent UA", "Override User-Agent header") { |ua| cfg[:user_agent] = ua }
130
+
131
+ o.on("--cookie-store", "Enable persistent cookie jar for this request") { cfg[:cookie_store] = true }
132
+
133
+ o.separator ""
134
+
135
+ o.on("-V", "--version", "Print version and exit") { puts "wreq #{Wreq::VERSION}"; exit 0 }
136
+ o.on_tail("-h", "--help", "Show this help") { puts o; exit 0 }
137
+ end
138
+
139
+ args = ARGV.dup
140
+
141
+ # Allow bare method as first positional arg: `wreq POST https://...`
142
+ if args.first =~ /\A[A-Z]+\z/
143
+ cfg[:method] = args.shift
144
+ end
145
+
146
+ begin
147
+ parser.parse!(args)
148
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
149
+ abort "wreq: #{e.message}\nRun 'wreq --help' for usage."
150
+ end
151
+
152
+ url = args.shift
153
+ unless url
154
+ $stderr.puts parser
155
+ exit 1
156
+ end
157
+
158
+ cfg[:method] ||= "GET"
159
+
160
+ # Build Wreq::Client options (connection/emulation settings only)
161
+ CLIENT_KEYS = %i[emulation emulation_os user_agent proxy local_address timeout connect_timeout
162
+ http1_only http2_only cookie_store https_only].freeze
163
+ client_opts = cfg.slice(*CLIENT_KEYS).reject { |_, v| v.nil? }
164
+ client_opts[:redirect] = cfg[:redirect]
165
+ client_opts[:verify_cert] = cfg[:verify_cert]
166
+ client_opts[:verify_host] = cfg[:verify_host]
167
+
168
+ client = Wreq::Client.new(**client_opts)
169
+
170
+ # Per-request headers
171
+ req[:headers] = cfg[:headers] unless cfg[:headers].empty?
172
+
173
+ # Execute request
174
+ begin
175
+ response = client.public_send(cfg[:method].downcase, url, **req)
176
+ rescue NoMethodError
177
+ abort "wreq: unsupported HTTP method '#{cfg[:method]}'"
178
+ rescue => e
179
+ abort "wreq: #{e.message}"
180
+ end
181
+
182
+ # -i: print response status + headers to stdout before body
183
+ if cfg[:include]
184
+ puts "#{response.version} #{response.status}"
185
+ response.headers.each do |k, values|
186
+ Array(values).each { |v| puts "#{k}: #{v}" }
187
+ end
188
+ puts ""
189
+ end
190
+
191
+ # Output body
192
+ unless cfg[:silent] || cfg[:method] == "HEAD"
193
+ if cfg[:output]
194
+ bytes = response.body_bytes.pack("C*")
195
+ File.binwrite(cfg[:output], bytes)
196
+ warn "Saved #{bytes.bytesize} bytes to #{cfg[:output]}"
197
+ else
198
+ body = response.body
199
+ if cfg[:pretty] && !body.nil? && !body.empty?
200
+ body = begin
201
+ JSON.pretty_generate(JSON.parse(body))
202
+ rescue JSON::ParserError
203
+ body
204
+ end
205
+ end
206
+ print body unless body.nil?
207
+ $stdout.puts if body && !body.empty? && !body.end_with?("\n")
208
+ end
209
+ end
210
+
211
+ exit response.success? ? 0 : 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wreq
4
- VERSION = "0.4.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,25 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Yicheng Zhou
8
8
  - Illia Zub
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
- date: 2026-03-02 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,
16
16
  and redirect policies.
17
17
  email:
18
- executables: []
18
+ executables:
19
+ - wreq
19
20
  extensions: []
20
21
  extra_rdoc_files: []
21
22
  files:
23
+ - LICENSE
22
24
  - README.md
25
+ - exe/wreq
23
26
  - lib/wreq-rb.rb
24
27
  - lib/wreq-rb/version.rb
25
28
  - lib/wreq_rb/2.7/wreq_rb.so
@@ -30,7 +33,7 @@ files:
30
33
  - vendor/wreq/README.md
31
34
  homepage: https://github.com/serpapi/wreq-rb
32
35
  licenses:
33
- - MIT
36
+ - Apache-2.0
34
37
  metadata: {}
35
38
  post_install_message:
36
39
  rdoc_options: []