wreq 1.2.3-x64-mingw-ucrt
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 +7 -0
- data/Cargo.lock +1687 -0
- data/Cargo.toml +54 -0
- data/Gemfile +18 -0
- data/LICENSE +201 -0
- data/README.md +153 -0
- data/Rakefile +90 -0
- data/build.rs +16 -0
- data/docs/windows-gnu-tokio-crash.md +70 -0
- data/examples/body.rb +42 -0
- data/examples/client.rb +33 -0
- data/examples/cookie.rb +24 -0
- data/examples/emulate_request.rb +37 -0
- data/examples/headers.rb +27 -0
- data/examples/proxy.rb +113 -0
- data/examples/send_stream.rb +85 -0
- data/examples/stream.rb +14 -0
- data/examples/thread_interrupt.rb +83 -0
- data/extconf.rb +7 -0
- data/lib/wreq.rb +303 -0
- data/lib/wreq_ruby/3.3/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/3.4/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/4.0/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/body.rb +36 -0
- data/lib/wreq_ruby/client.rb +526 -0
- data/lib/wreq_ruby/cookie.rb +156 -0
- data/lib/wreq_ruby/emulate.rb +232 -0
- data/lib/wreq_ruby/error.rb +157 -0
- data/lib/wreq_ruby/header.rb +205 -0
- data/lib/wreq_ruby/http.rb +160 -0
- data/lib/wreq_ruby/response.rb +209 -0
- data/script/build_platform_gem.rb +34 -0
- data/script/build_windows_gnu.ps1 +257 -0
- data/src/arch.rs +33 -0
- data/src/client/body/form.rs +2 -0
- data/src/client/body/json.rs +16 -0
- data/src/client/body/stream.rs +146 -0
- data/src/client/body.rs +57 -0
- data/src/client/param.rs +19 -0
- data/src/client/query.rs +2 -0
- data/src/client/req.rs +274 -0
- data/src/client/resp.rs +248 -0
- data/src/client.rs +413 -0
- data/src/cookie.rs +312 -0
- data/src/emulate.rs +376 -0
- data/src/error.rs +163 -0
- data/src/extractor.rs +117 -0
- data/src/gvl.rs +154 -0
- data/src/header.rs +245 -0
- data/src/http.rs +142 -0
- data/src/lib.rs +98 -0
- data/src/macros.rs +123 -0
- data/src/rt.rs +46 -0
- data/test/client_cookie_test.rb +46 -0
- data/test/client_test.rb +136 -0
- data/test/cookie_test.rb +182 -0
- data/test/emulation_test.rb +21 -0
- data/test/error_handling_test.rb +92 -0
- data/test/header_test.rb +290 -0
- data/test/inspect_test.rb +125 -0
- data/test/module_methods_test.rb +75 -0
- data/test/orig_header_test.rb +115 -0
- data/test/request_parameters_test.rb +175 -0
- data/test/request_test.rb +244 -0
- data/test/response_test.rb +69 -0
- data/test/stream_test.rb +397 -0
- data/test/test_helper.rb +52 -0
- data/wreq.gemspec +68 -0
- metadata +123 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
unless defined?(Wreq)
|
|
4
|
+
module Wreq
|
|
5
|
+
# HTTP client with extensive configuration options.
|
|
6
|
+
#
|
|
7
|
+
# This class wraps a native Rust implementation providing high-performance
|
|
8
|
+
# HTTP/1.1 and HTTP/2 client functionality with support for connection pooling,
|
|
9
|
+
# compression, redirects, proxies, and fine-grained timeout controls.
|
|
10
|
+
#
|
|
11
|
+
# The client is thread-safe and maintains an internal connection pool for
|
|
12
|
+
# efficient request reuse.
|
|
13
|
+
#
|
|
14
|
+
# @example Basic usage
|
|
15
|
+
# client = Wreq::Client.new
|
|
16
|
+
# # Use client for HTTP requests
|
|
17
|
+
#
|
|
18
|
+
# @example With common options
|
|
19
|
+
# client = Wreq::Client.new(
|
|
20
|
+
# user_agent: "MyApp/1.0",
|
|
21
|
+
# timeout: 30,
|
|
22
|
+
# gzip: true,
|
|
23
|
+
# brotli: true
|
|
24
|
+
# )
|
|
25
|
+
#
|
|
26
|
+
# @see https://github.com/your-repo/wreq-ruby Full documentation
|
|
27
|
+
class Client
|
|
28
|
+
# Create a new HTTP client instance.
|
|
29
|
+
#
|
|
30
|
+
# All options are optional. Time-related numeric values are expressed in seconds.
|
|
31
|
+
#
|
|
32
|
+
# @param emulation [Wreq::Emulation, nil] Device and OS emulation settings.
|
|
33
|
+
# If specified, the client will modify request headers and behaviors
|
|
34
|
+
#
|
|
35
|
+
# @param user_agent [String, nil] Custom User-Agent header value.
|
|
36
|
+
# If not specified, a default user agent will be used.
|
|
37
|
+
#
|
|
38
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Default headers to include
|
|
39
|
+
# in every request. Header names are case-insensitive. These headers
|
|
40
|
+
# can be overridden on a per-request basis.
|
|
41
|
+
# @param orig_headers [Array<String>, nil] Original header names used to
|
|
42
|
+
# preserve raw header order and HTTP/1 case-sensitive header handling.
|
|
43
|
+
#
|
|
44
|
+
# @param referer [Boolean, nil] Whether to automatically send Referer
|
|
45
|
+
# headers when following redirects. When true, the previous URL will
|
|
46
|
+
# be sent as the Referer header.
|
|
47
|
+
#
|
|
48
|
+
# @param allow_redirects [Boolean, nil] Enable automatic following of
|
|
49
|
+
# HTTP redirects (3xx status codes). When false, redirect responses
|
|
50
|
+
# will be returned directly to the caller.
|
|
51
|
+
#
|
|
52
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to
|
|
53
|
+
# follow before returning an error. Only applies when allow_redirects
|
|
54
|
+
# is true. Default is typically 10 if not specified.
|
|
55
|
+
#
|
|
56
|
+
# @param cookie_store [Boolean, nil] Enable an in-memory cookie jar
|
|
57
|
+
# that automatically handles Set-Cookie headers and sends appropriate
|
|
58
|
+
# Cookie headers on subsequent requests.
|
|
59
|
+
#
|
|
60
|
+
# @param cookie_provider [Wreq::Jar, nil] Custom cookie jar provider
|
|
61
|
+
# used to store and retrieve cookies for all requests made by this
|
|
62
|
+
# client. Typically used together with `cookie_store: true`.
|
|
63
|
+
#
|
|
64
|
+
# @param timeout [Integer, nil] Overall timeout for the entire request
|
|
65
|
+
# in seconds, including connection establishment, request transmission,
|
|
66
|
+
# and response reading. If not set, requests may wait indefinitely.
|
|
67
|
+
#
|
|
68
|
+
# @param connect_timeout [Integer, nil] Maximum time in seconds to wait
|
|
69
|
+
# when establishing a connection to the remote server. This is separate
|
|
70
|
+
# from the overall timeout.
|
|
71
|
+
#
|
|
72
|
+
# @param read_timeout [Integer, nil] Maximum time in seconds to wait
|
|
73
|
+
# between reading chunks of data from the server. Applies to each
|
|
74
|
+
# read operation, not the entire response.
|
|
75
|
+
#
|
|
76
|
+
# @param tcp_keepalive [Integer, nil] Time in seconds that a connection
|
|
77
|
+
# must be idle before TCP keepalive probes are sent. Helps detect
|
|
78
|
+
# broken connections.
|
|
79
|
+
#
|
|
80
|
+
# @param tcp_keepalive_interval [Integer, nil] Time in seconds between
|
|
81
|
+
# individual TCP keepalive probes. Only relevant if tcp_keepalive is set.
|
|
82
|
+
#
|
|
83
|
+
# @param tcp_keepalive_retries [Integer, nil] Number of failed keepalive
|
|
84
|
+
# probes before the connection is considered dead and closed.
|
|
85
|
+
#
|
|
86
|
+
# @param tcp_user_timeout [Integer, nil] Maximum time in seconds that
|
|
87
|
+
# transmitted data may remain unacknowledged before the connection is
|
|
88
|
+
# forcibly closed. Linux-specific option (Android, Fuchsia, Linux only).
|
|
89
|
+
#
|
|
90
|
+
# @param tcp_nodelay [Boolean, nil] Enable TCP_NODELAY socket option,
|
|
91
|
+
# which disables Nagle's algorithm. When true, small packets are sent
|
|
92
|
+
# immediately rather than being buffered. Useful for reducing latency
|
|
93
|
+
# in interactive protocols.
|
|
94
|
+
#
|
|
95
|
+
# @param tcp_reuse_address [Boolean, nil] Enable SO_REUSEADDR socket option,
|
|
96
|
+
# allowing the reuse of local addresses in TIME_WAIT state. Useful for
|
|
97
|
+
# reducing port exhaustion in high-throughput scenarios.
|
|
98
|
+
#
|
|
99
|
+
# @param pool_idle_timeout [Integer, nil] Time in seconds before idle
|
|
100
|
+
# connections in the pool are evicted and closed. Helps free up
|
|
101
|
+
# resources for long-running applications.
|
|
102
|
+
#
|
|
103
|
+
# @param pool_max_idle_per_host [Integer, nil] Maximum number of idle
|
|
104
|
+
# connections to maintain per host in the connection pool. Connections
|
|
105
|
+
# beyond this limit will be closed immediately after use.
|
|
106
|
+
#
|
|
107
|
+
# @param pool_max_size [Integer, nil] Total maximum size of the connection
|
|
108
|
+
# pool across all hosts. Once reached, new requests may need to wait
|
|
109
|
+
# for existing connections to become available.
|
|
110
|
+
#
|
|
111
|
+
# @param http1_only [Boolean, nil] Force the client to use HTTP/1.1 only,
|
|
112
|
+
# even if HTTP/2 is available. Useful for compatibility with servers
|
|
113
|
+
# that have problematic HTTP/2 implementations.
|
|
114
|
+
#
|
|
115
|
+
# @param http2_only [Boolean, nil] Force the client to use HTTP/2 only.
|
|
116
|
+
# Requests to servers that don't support HTTP/2 will fail. Cannot be
|
|
117
|
+
# combined with http1_only.
|
|
118
|
+
#
|
|
119
|
+
# @param https_only [Boolean, nil] Reject plain HTTP connections and
|
|
120
|
+
# only allow HTTPS. Provides an additional layer of security by
|
|
121
|
+
# preventing accidental cleartext connections.
|
|
122
|
+
#
|
|
123
|
+
# @param verify [Boolean, nil] Enable or disable TLS certificate
|
|
124
|
+
# verification. When false, the client will accept any certificate,
|
|
125
|
+
# including self-signed or expired ones. Should only be disabled
|
|
126
|
+
# for testing purposes.
|
|
127
|
+
#
|
|
128
|
+
# @param no_proxy [Boolean, nil] Disable use of any configured proxy
|
|
129
|
+
# for this client, even if proxy settings are detected from the
|
|
130
|
+
# environment.
|
|
131
|
+
#
|
|
132
|
+
# @param proxy [String, nil] Proxy server URI to use for all requests.
|
|
133
|
+
# Supports HTTP, HTTPS, and SOCKS5 proxies. Format: "protocol://host:port"
|
|
134
|
+
# Example: "http://proxy.example.com:8080"
|
|
135
|
+
# @param local_address [String, nil] Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable.
|
|
136
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
137
|
+
#
|
|
138
|
+
# @param gzip [Boolean, nil] Accept and automatically decompress gzip
|
|
139
|
+
# content encoding. When true, adds "Accept-Encoding: gzip" header.
|
|
140
|
+
#
|
|
141
|
+
# @param brotli [Boolean, nil] Accept and automatically decompress Brotli
|
|
142
|
+
# content encoding. When true, adds "Accept-Encoding: br" header.
|
|
143
|
+
# Provides better compression than gzip.
|
|
144
|
+
#
|
|
145
|
+
# @param deflate [Boolean, nil] Accept and automatically decompress deflate
|
|
146
|
+
# content encoding. When true, adds "Accept-Encoding: deflate" header.
|
|
147
|
+
#
|
|
148
|
+
# @param zstd [Boolean, nil] Accept and automatically decompress Zstandard
|
|
149
|
+
# content encoding. When true, adds "Accept-Encoding: zstd" header.
|
|
150
|
+
# Modern compression algorithm with excellent performance.
|
|
151
|
+
#
|
|
152
|
+
# @return [Wreq::Client] A configured HTTP client instance ready to make requests.
|
|
153
|
+
#
|
|
154
|
+
# @raise [ArgumentError] if incompatible options are specified together
|
|
155
|
+
# (e.g., http1_only and http2_only both true).
|
|
156
|
+
# @raise [RuntimeError] if the underlying client cannot be initialized
|
|
157
|
+
# due to system resource constraints or invalid configuration.
|
|
158
|
+
#
|
|
159
|
+
# @example Minimal client
|
|
160
|
+
# client = Wreq::Client.new
|
|
161
|
+
#
|
|
162
|
+
# @example Client with custom headers
|
|
163
|
+
# client = Wreq::Client.new(
|
|
164
|
+
# user_agent: "MyApp/2.0 (https://example.com)",
|
|
165
|
+
# headers: {
|
|
166
|
+
# "Accept" => "application/json",
|
|
167
|
+
# "X-API-Key" => "secret-key-here"
|
|
168
|
+
# }
|
|
169
|
+
# )
|
|
170
|
+
#
|
|
171
|
+
# @example Client with timeouts
|
|
172
|
+
# client = Wreq::Client.new(
|
|
173
|
+
# timeout: 30, # 30 seconds total
|
|
174
|
+
# connect_timeout: 5, # 5 seconds to connect
|
|
175
|
+
# read_timeout: 10 # 10 seconds between reads
|
|
176
|
+
# )
|
|
177
|
+
#
|
|
178
|
+
# @example Client with redirect handling
|
|
179
|
+
# client = Wreq::Client.new(
|
|
180
|
+
# allow_redirects: true,
|
|
181
|
+
# max_redirects: 5,
|
|
182
|
+
# referer: true,
|
|
183
|
+
# history: true
|
|
184
|
+
# )
|
|
185
|
+
#
|
|
186
|
+
# @example Client with compression
|
|
187
|
+
# client = Wreq::Client.new(
|
|
188
|
+
# gzip: true,
|
|
189
|
+
# brotli: true,
|
|
190
|
+
# zstd: true
|
|
191
|
+
# )
|
|
192
|
+
#
|
|
193
|
+
# @example Client with proxy
|
|
194
|
+
# client = Wreq::Client.new(
|
|
195
|
+
# proxy: "http://proxy.corp.com:8080"
|
|
196
|
+
# )
|
|
197
|
+
#
|
|
198
|
+
# @example Client with SOCKS5 proxy
|
|
199
|
+
# client = Wreq::Client.new(
|
|
200
|
+
# proxy: "socks5://localhost:1080"
|
|
201
|
+
# )
|
|
202
|
+
#
|
|
203
|
+
# @example HTTPS-only client with strict verification
|
|
204
|
+
# client = Wreq::Client.new(
|
|
205
|
+
# https_only: true,
|
|
206
|
+
# verify: true
|
|
207
|
+
# )
|
|
208
|
+
#
|
|
209
|
+
# @example HTTP/2 optimized client
|
|
210
|
+
# client = Wreq::Client.new(
|
|
211
|
+
# http2_only: true,
|
|
212
|
+
# tcp_nodelay: true
|
|
213
|
+
# )
|
|
214
|
+
#
|
|
215
|
+
# @example Connection pool tuning
|
|
216
|
+
# client = Wreq::Client.new(
|
|
217
|
+
# pool_max_idle_per_host: 32,
|
|
218
|
+
# pool_idle_timeout: 90,
|
|
219
|
+
# pool_max_size: 128
|
|
220
|
+
# )
|
|
221
|
+
#
|
|
222
|
+
# @example TCP keepalive configuration
|
|
223
|
+
# client = Wreq::Client.new(
|
|
224
|
+
# tcp_keepalive: 60,
|
|
225
|
+
# tcp_keepalive_interval: 10,
|
|
226
|
+
# tcp_keepalive_retries: 3
|
|
227
|
+
# )
|
|
228
|
+
#
|
|
229
|
+
# @example Development/testing client (insecure)
|
|
230
|
+
# client = Wreq::Client.new(
|
|
231
|
+
# verify: false, # WARNING: Do not use in production!
|
|
232
|
+
# timeout: 5
|
|
233
|
+
# )
|
|
234
|
+
def self.new(**options)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Send an HTTP request.
|
|
238
|
+
#
|
|
239
|
+
# @param method [Wreq::Method] HTTP method to use
|
|
240
|
+
# @param url [String] Target URL
|
|
241
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
242
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
243
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
244
|
+
# @param query [Hash, nil] URL query parameters
|
|
245
|
+
# @param auth [String, nil] Authorization header value
|
|
246
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
247
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
248
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
249
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
250
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
251
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
252
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
253
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
254
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
255
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
256
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
257
|
+
# @param proxy [String, nil] Proxy server URI
|
|
258
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
259
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
260
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
261
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
262
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
263
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
264
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
265
|
+
# @return [Wreq::Response] HTTP response
|
|
266
|
+
def request(method, url, **options)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# Send an HTTP GET request.
|
|
270
|
+
#
|
|
271
|
+
# @param url [String] Target URL
|
|
272
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
273
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
274
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
275
|
+
# @param query [Hash, nil] URL query parameters
|
|
276
|
+
# @param auth [String, nil] Authorization header value
|
|
277
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
278
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
279
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
280
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
281
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
282
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
283
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
284
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
285
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
286
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
287
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
288
|
+
# @param proxy [String, nil] Proxy server URI
|
|
289
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
290
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
291
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
292
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
293
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
294
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
295
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
296
|
+
# @return [Wreq::Response] HTTP response
|
|
297
|
+
def get(url, **options)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# Send an HTTP HEAD request.
|
|
301
|
+
#
|
|
302
|
+
# @param url [String] Target URL
|
|
303
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
304
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
305
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
306
|
+
# @param query [Hash, nil] URL query parameters
|
|
307
|
+
# @param auth [String, nil] Authorization header value
|
|
308
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
309
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
310
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
311
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
312
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
313
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
314
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
315
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
316
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
317
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
318
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
319
|
+
# @param proxy [String, nil] Proxy server URI
|
|
320
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
321
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
322
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
323
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
324
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
325
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
326
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
327
|
+
# @return [Wreq::Response] HTTP response
|
|
328
|
+
def head(url, **options)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Send an HTTP POST request.
|
|
332
|
+
#
|
|
333
|
+
# @param url [String] Target URL
|
|
334
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
335
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
336
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
337
|
+
# @param query [Hash, nil] URL query parameters
|
|
338
|
+
# @param auth [String, nil] Authorization header value
|
|
339
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
340
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
341
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
342
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
343
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
344
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
345
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
346
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
347
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
348
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
349
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
350
|
+
# @param proxy [String, nil] Proxy server URI
|
|
351
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
352
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
353
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
354
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
355
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
356
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
357
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
358
|
+
# @return [Wreq::Response] HTTP response
|
|
359
|
+
def post(url, **options)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# Send an HTTP PUT request.
|
|
363
|
+
#
|
|
364
|
+
# @param url [String] Target URL
|
|
365
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
366
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
367
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
368
|
+
# @param query [Hash, nil] URL query parameters
|
|
369
|
+
# @param auth [String, nil] Authorization header value
|
|
370
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
371
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
372
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
373
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
374
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
375
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
376
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
377
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
378
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
379
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
380
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
381
|
+
# @param proxy [String, nil] Proxy server URI
|
|
382
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
383
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
384
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
385
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
386
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
387
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
388
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
389
|
+
# @return [Wreq::Response] HTTP response
|
|
390
|
+
def put(url, **options)
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# Send an HTTP DELETE request.
|
|
394
|
+
#
|
|
395
|
+
# @param url [String] Target URL
|
|
396
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
397
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
398
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
399
|
+
# @param query [Hash, nil] URL query parameters
|
|
400
|
+
# @param auth [String, nil] Authorization header value
|
|
401
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
402
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
403
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
404
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
405
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
406
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
407
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
408
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
409
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
410
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
411
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
412
|
+
# @param proxy [String, nil] Proxy server URI
|
|
413
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
414
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
415
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
416
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
417
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
418
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
419
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
420
|
+
# @return [Wreq::Response] HTTP response
|
|
421
|
+
def delete(url, **options)
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
# Send an HTTP OPTIONS request.
|
|
425
|
+
#
|
|
426
|
+
# @param url [String] Target URL
|
|
427
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
428
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
429
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
430
|
+
# @param query [Hash, nil] URL query parameters
|
|
431
|
+
# @param auth [String, nil] Authorization header value
|
|
432
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
433
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
434
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
435
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
436
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
437
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
438
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
439
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
440
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
441
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
442
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
443
|
+
# @param proxy [String, nil] Proxy server URI
|
|
444
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
445
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
446
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
447
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
448
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
449
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
450
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
451
|
+
# @return [Wreq::Response] HTTP response
|
|
452
|
+
def options(url, **options)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
# Send an HTTP TRACE request.
|
|
456
|
+
#
|
|
457
|
+
# @param url [String] Target URL
|
|
458
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
459
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
460
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
461
|
+
# @param query [Hash, nil] URL query parameters
|
|
462
|
+
# @param auth [String, nil] Authorization header value
|
|
463
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
464
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
465
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
466
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
467
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
468
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
469
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
470
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
471
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
472
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
473
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
474
|
+
# @param proxy [String, nil] Proxy server URI
|
|
475
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
476
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
477
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
478
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
479
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
480
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
481
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
482
|
+
# @return [Wreq::Response] HTTP response
|
|
483
|
+
def trace(url, **options)
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
# Send an HTTP PATCH request.
|
|
487
|
+
#
|
|
488
|
+
# @param url [String] Target URL
|
|
489
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
490
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
491
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
492
|
+
# @param query [Hash, nil] URL query parameters
|
|
493
|
+
# @param auth [String, nil] Authorization header value
|
|
494
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
495
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
496
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
497
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
498
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
499
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
500
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
501
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
502
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
503
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
504
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
505
|
+
# @param proxy [String, nil] Proxy server URI
|
|
506
|
+
# @param local_address [String, nil] Bind the request's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.
|
|
507
|
+
# @param interface [String, nil] Bind the socket to a specific network interface via `SO_BINDTODEVICE` (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).
|
|
508
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
509
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
510
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
511
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
512
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
513
|
+
# @return [Wreq::Response] HTTP response
|
|
514
|
+
def patch(url, **options)
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
module Wreq
|
|
521
|
+
class Client
|
|
522
|
+
def inspect
|
|
523
|
+
"#<Wreq::Client>"
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
end
|