wreq 1.2.5-aarch64-linux → 1.2.7-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 +4 -4
- data/.cargo/config.toml +4 -0
- data/Rakefile +6 -0
- data/crates/wreq-util/README.md +1 -1
- data/docs/windows-gnu-tokio-crash.md +49 -3
- data/extconf.rb +4 -0
- data/lib/wreq.rb +70 -45
- 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 +29 -11
- data/lib/wreq_ruby/client.rb +88 -55
- data/lib/wreq_ruby/cookie.rb +79 -19
- data/lib/wreq_ruby/emulate.rb +74 -6
- data/lib/wreq_ruby/error.rb +5 -7
- data/lib/wreq_ruby/http.rb +74 -0
- data/lib/wreq_ruby/response.rb +3 -0
- data/script/rust_env.rb +85 -0
- data/test/body_sender_test.rb +246 -0
- data/test/cookie_test.rb +211 -10
- data/test/json_precision_test.rb +209 -0
- data/test/option_validation_test.rb +311 -0
- data/test/value_semantics_test.rb +238 -0
- data/wreq.gemspec +1 -1
- metadata +9 -4
- data/script/build_windows_gnu.ps1 +0 -264
data/lib/wreq_ruby/client.rb
CHANGED
|
@@ -11,6 +11,12 @@ unless defined?(Wreq)
|
|
|
11
11
|
# The client is thread-safe and maintains an internal connection pool for
|
|
12
12
|
# efficient request reuse.
|
|
13
13
|
#
|
|
14
|
+
# Client and request options are limited to the keys listed below. Unknown,
|
|
15
|
+
# ambiguous, ineffective, and unavailable platform options raise
|
|
16
|
+
# ArgumentError. Known values retain the error class from their Ruby or
|
|
17
|
+
# native conversion, such as TypeError or Wreq::BuilderError. Request
|
|
18
|
+
# validation finishes before network I/O.
|
|
19
|
+
#
|
|
14
20
|
# @example Basic usage
|
|
15
21
|
# client = Wreq::Client.new
|
|
16
22
|
# # Use client for HTTP requests
|
|
@@ -50,8 +56,7 @@ unless defined?(Wreq)
|
|
|
50
56
|
# will be returned directly to the caller.
|
|
51
57
|
#
|
|
52
58
|
# @param max_redirects [Integer, nil] Maximum number of redirects to
|
|
53
|
-
# follow before returning an error.
|
|
54
|
-
# is true. Default is typically 10 if not specified.
|
|
59
|
+
# follow before returning an error. Requires `allow_redirects: true`.
|
|
55
60
|
#
|
|
56
61
|
# @param cookie_store [Boolean, nil] Enable an in-memory cookie jar
|
|
57
62
|
# that automatically handles Set-Cookie headers and sends appropriate
|
|
@@ -85,7 +90,7 @@ unless defined?(Wreq)
|
|
|
85
90
|
#
|
|
86
91
|
# @param tcp_user_timeout [Integer, nil] Maximum time in seconds that
|
|
87
92
|
# transmitted data may remain unacknowledged before the connection is
|
|
88
|
-
# forcibly closed.
|
|
93
|
+
# forcibly closed. Available on Android, Fuchsia, and Linux only.
|
|
89
94
|
#
|
|
90
95
|
# @param tcp_nodelay [Boolean, nil] Enable TCP_NODELAY socket option,
|
|
91
96
|
# which disables Nagle's algorithm. When true, small packets are sent
|
|
@@ -133,7 +138,9 @@ unless defined?(Wreq)
|
|
|
133
138
|
# Supports HTTP, HTTPS, and SOCKS5 proxies. Format: "protocol://host:port"
|
|
134
139
|
# Example: "http://proxy.example.com:8080"
|
|
135
140
|
# @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
|
|
141
|
+
# @param interface [String, nil] Bind sockets to a network interface on
|
|
142
|
+
# platforms supported by the native client. Unsupported platforms raise
|
|
143
|
+
# ArgumentError.
|
|
137
144
|
#
|
|
138
145
|
# @param gzip [Boolean, nil] Accept and automatically decompress gzip
|
|
139
146
|
# content encoding. When true, adds "Accept-Encoding: gzip" header.
|
|
@@ -151,10 +158,13 @@ unless defined?(Wreq)
|
|
|
151
158
|
#
|
|
152
159
|
# @return [Wreq::Client] A configured HTTP client instance ready to make requests.
|
|
153
160
|
#
|
|
154
|
-
# @raise [ArgumentError] if
|
|
155
|
-
#
|
|
156
|
-
# @raise [
|
|
157
|
-
#
|
|
161
|
+
# @raise [ArgumentError] if an option is unknown, conflicting,
|
|
162
|
+
# ineffective, or unavailable on the current platform.
|
|
163
|
+
# @raise [TypeError] if the option argument is not a Hash.
|
|
164
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
165
|
+
# value cannot be converted or validated.
|
|
166
|
+
# @raise [Wreq::BuilderError, Wreq::TlsError] if the native client cannot
|
|
167
|
+
# be initialized.
|
|
158
168
|
#
|
|
159
169
|
# @example Minimal client
|
|
160
170
|
# client = Wreq::Client.new
|
|
@@ -179,8 +189,7 @@ unless defined?(Wreq)
|
|
|
179
189
|
# client = Wreq::Client.new(
|
|
180
190
|
# allow_redirects: true,
|
|
181
191
|
# max_redirects: 5,
|
|
182
|
-
# referer: true
|
|
183
|
-
# history: true
|
|
192
|
+
# referer: true
|
|
184
193
|
# )
|
|
185
194
|
#
|
|
186
195
|
# @example Client with compression
|
|
@@ -236,18 +245,22 @@ unless defined?(Wreq)
|
|
|
236
245
|
|
|
237
246
|
# Send an HTTP request.
|
|
238
247
|
#
|
|
248
|
+
# Only the options listed here are accepted. Body options (`body`, `form`,
|
|
249
|
+
# `json`) and authentication options (`auth`, `bearer_auth`, `basic_auth`)
|
|
250
|
+
# are mutually exclusive. `max_redirects` requires `allow_redirects: true`.
|
|
251
|
+
#
|
|
239
252
|
# @param method [Wreq::Method] HTTP method to use
|
|
240
253
|
# @param url [String] Target URL
|
|
241
254
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
242
255
|
# @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 [Boolean, nil] Whether to apply default
|
|
256
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
244
257
|
# @param query [Hash, nil] URL query parameters
|
|
245
258
|
# @param auth [String, nil] Authorization header value
|
|
246
259
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
247
260
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
248
261
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
249
262
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
250
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
263
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
251
264
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
252
265
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
253
266
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -256,13 +269,17 @@ unless defined?(Wreq)
|
|
|
256
269
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
257
270
|
# @param proxy [String, nil] Proxy server URI
|
|
258
271
|
# @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
|
|
272
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
260
273
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
261
274
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
262
275
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
263
|
-
# @param json [Object, nil] JSON body
|
|
264
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
276
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
277
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
265
278
|
# @return [Wreq::Response] HTTP response
|
|
279
|
+
# @raise [ArgumentError] if options are unknown, conflicting, ineffective,
|
|
280
|
+
# or unavailable on the current platform
|
|
281
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
282
|
+
# value cannot be converted, validated, or built
|
|
266
283
|
def request(method, url, **options)
|
|
267
284
|
end
|
|
268
285
|
|
|
@@ -271,14 +288,14 @@ unless defined?(Wreq)
|
|
|
271
288
|
# @param url [String] Target URL
|
|
272
289
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
273
290
|
# @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 [Boolean, nil] Whether to apply default
|
|
291
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
275
292
|
# @param query [Hash, nil] URL query parameters
|
|
276
293
|
# @param auth [String, nil] Authorization header value
|
|
277
294
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
278
295
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
279
296
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
280
297
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
281
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
298
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
282
299
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
283
300
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
284
301
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -287,13 +304,15 @@ unless defined?(Wreq)
|
|
|
287
304
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
288
305
|
# @param proxy [String, nil] Proxy server URI
|
|
289
306
|
# @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
|
|
307
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
291
308
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
292
309
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
293
310
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
294
|
-
# @param json [Object, nil] JSON body
|
|
295
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
311
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
312
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
296
313
|
# @return [Wreq::Response] HTTP response
|
|
314
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
315
|
+
# value cannot be converted, validated, or built
|
|
297
316
|
def get(url, **options)
|
|
298
317
|
end
|
|
299
318
|
|
|
@@ -302,14 +321,14 @@ unless defined?(Wreq)
|
|
|
302
321
|
# @param url [String] Target URL
|
|
303
322
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
304
323
|
# @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 [Boolean, nil] Whether to apply default
|
|
324
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
306
325
|
# @param query [Hash, nil] URL query parameters
|
|
307
326
|
# @param auth [String, nil] Authorization header value
|
|
308
327
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
309
328
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
310
329
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
311
330
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
312
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
331
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
313
332
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
314
333
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
315
334
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -318,13 +337,15 @@ unless defined?(Wreq)
|
|
|
318
337
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
319
338
|
# @param proxy [String, nil] Proxy server URI
|
|
320
339
|
# @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
|
|
340
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
322
341
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
323
342
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
324
343
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
325
|
-
# @param json [Object, nil] JSON body
|
|
326
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
344
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
345
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
327
346
|
# @return [Wreq::Response] HTTP response
|
|
347
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
348
|
+
# value cannot be converted, validated, or built
|
|
328
349
|
def head(url, **options)
|
|
329
350
|
end
|
|
330
351
|
|
|
@@ -333,14 +354,14 @@ unless defined?(Wreq)
|
|
|
333
354
|
# @param url [String] Target URL
|
|
334
355
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
335
356
|
# @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 [Boolean, nil] Whether to apply default
|
|
357
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
337
358
|
# @param query [Hash, nil] URL query parameters
|
|
338
359
|
# @param auth [String, nil] Authorization header value
|
|
339
360
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
340
361
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
341
362
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
342
363
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
343
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
364
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
344
365
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
345
366
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
346
367
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -349,13 +370,15 @@ unless defined?(Wreq)
|
|
|
349
370
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
350
371
|
# @param proxy [String, nil] Proxy server URI
|
|
351
372
|
# @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
|
|
373
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
353
374
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
354
375
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
355
376
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
356
|
-
# @param json [Object, nil] JSON body
|
|
357
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
377
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
378
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
358
379
|
# @return [Wreq::Response] HTTP response
|
|
380
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
381
|
+
# value cannot be converted, validated, or built
|
|
359
382
|
def post(url, **options)
|
|
360
383
|
end
|
|
361
384
|
|
|
@@ -364,14 +387,14 @@ unless defined?(Wreq)
|
|
|
364
387
|
# @param url [String] Target URL
|
|
365
388
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
366
389
|
# @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 [Boolean, nil] Whether to apply default
|
|
390
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
368
391
|
# @param query [Hash, nil] URL query parameters
|
|
369
392
|
# @param auth [String, nil] Authorization header value
|
|
370
393
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
371
394
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
372
395
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
373
396
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
374
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
397
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
375
398
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
376
399
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
377
400
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -380,13 +403,15 @@ unless defined?(Wreq)
|
|
|
380
403
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
381
404
|
# @param proxy [String, nil] Proxy server URI
|
|
382
405
|
# @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
|
|
406
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
384
407
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
385
408
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
386
409
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
387
|
-
# @param json [Object, nil] JSON body
|
|
388
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
410
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
411
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
389
412
|
# @return [Wreq::Response] HTTP response
|
|
413
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
414
|
+
# value cannot be converted, validated, or built
|
|
390
415
|
def put(url, **options)
|
|
391
416
|
end
|
|
392
417
|
|
|
@@ -395,14 +420,14 @@ unless defined?(Wreq)
|
|
|
395
420
|
# @param url [String] Target URL
|
|
396
421
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
397
422
|
# @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 [Boolean, nil] Whether to apply default
|
|
423
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
399
424
|
# @param query [Hash, nil] URL query parameters
|
|
400
425
|
# @param auth [String, nil] Authorization header value
|
|
401
426
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
402
427
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
403
428
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
404
429
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
405
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
430
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
406
431
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
407
432
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
408
433
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -411,13 +436,15 @@ unless defined?(Wreq)
|
|
|
411
436
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
412
437
|
# @param proxy [String, nil] Proxy server URI
|
|
413
438
|
# @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
|
|
439
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
415
440
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
416
441
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
417
442
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
418
|
-
# @param json [Object, nil] JSON body
|
|
419
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
443
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
444
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
420
445
|
# @return [Wreq::Response] HTTP response
|
|
446
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
447
|
+
# value cannot be converted, validated, or built
|
|
421
448
|
def delete(url, **options)
|
|
422
449
|
end
|
|
423
450
|
|
|
@@ -426,14 +453,14 @@ unless defined?(Wreq)
|
|
|
426
453
|
# @param url [String] Target URL
|
|
427
454
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
428
455
|
# @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 [Boolean, nil] Whether to apply default
|
|
456
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
430
457
|
# @param query [Hash, nil] URL query parameters
|
|
431
458
|
# @param auth [String, nil] Authorization header value
|
|
432
459
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
433
460
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
434
461
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
435
462
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
436
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
463
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
437
464
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
438
465
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
439
466
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -442,13 +469,15 @@ unless defined?(Wreq)
|
|
|
442
469
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
443
470
|
# @param proxy [String, nil] Proxy server URI
|
|
444
471
|
# @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
|
|
472
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
446
473
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
447
474
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
448
475
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
449
|
-
# @param json [Object, nil] JSON body
|
|
450
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
476
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
477
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
451
478
|
# @return [Wreq::Response] HTTP response
|
|
479
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
480
|
+
# value cannot be converted, validated, or built
|
|
452
481
|
def options(url, **options)
|
|
453
482
|
end
|
|
454
483
|
|
|
@@ -457,14 +486,14 @@ unless defined?(Wreq)
|
|
|
457
486
|
# @param url [String] Target URL
|
|
458
487
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
459
488
|
# @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 [Boolean, nil] Whether to apply default
|
|
489
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
461
490
|
# @param query [Hash, nil] URL query parameters
|
|
462
491
|
# @param auth [String, nil] Authorization header value
|
|
463
492
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
464
493
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
465
494
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
466
495
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
467
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
496
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
468
497
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
469
498
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
470
499
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -473,13 +502,15 @@ unless defined?(Wreq)
|
|
|
473
502
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
474
503
|
# @param proxy [String, nil] Proxy server URI
|
|
475
504
|
# @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
|
|
505
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
477
506
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
478
507
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
479
508
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
480
|
-
# @param json [Object, nil] JSON body
|
|
481
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
509
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
510
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
482
511
|
# @return [Wreq::Response] HTTP response
|
|
512
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
513
|
+
# value cannot be converted, validated, or built
|
|
483
514
|
def trace(url, **options)
|
|
484
515
|
end
|
|
485
516
|
|
|
@@ -488,14 +519,14 @@ unless defined?(Wreq)
|
|
|
488
519
|
# @param url [String] Target URL
|
|
489
520
|
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
490
521
|
# @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 [Boolean, nil] Whether to apply default
|
|
522
|
+
# @param default_headers [Boolean, nil] Whether to apply native default headers
|
|
492
523
|
# @param query [Hash, nil] URL query parameters
|
|
493
524
|
# @param auth [String, nil] Authorization header value
|
|
494
525
|
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
495
526
|
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
496
527
|
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
497
528
|
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
498
|
-
# @param max_redirects [Integer, nil] Maximum
|
|
529
|
+
# @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
|
|
499
530
|
# @param gzip [Boolean, nil] Enable gzip compression
|
|
500
531
|
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
501
532
|
# @param deflate [Boolean, nil] Enable deflate compression
|
|
@@ -504,13 +535,15 @@ unless defined?(Wreq)
|
|
|
504
535
|
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
505
536
|
# @param proxy [String, nil] Proxy server URI
|
|
506
537
|
# @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
|
|
538
|
+
# @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
|
|
508
539
|
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
509
540
|
# @param version [Wreq::Version, nil] HTTP version to use
|
|
510
541
|
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
511
|
-
# @param json [Object, nil] JSON body
|
|
512
|
-
# @param body [String, Wreq::BodySender, nil]
|
|
542
|
+
# @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
|
|
543
|
+
# @param body [String, Wreq::BodySender, nil] Raw or streaming request body
|
|
513
544
|
# @return [Wreq::Response] HTTP response
|
|
545
|
+
# @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
|
|
546
|
+
# value cannot be converted, validated, or built
|
|
514
547
|
def patch(url, **options)
|
|
515
548
|
end
|
|
516
549
|
end
|
data/lib/wreq_ruby/cookie.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
unless defined?(Wreq)
|
|
2
2
|
module Wreq
|
|
3
|
-
#
|
|
3
|
+
# SameSite values for HTTP cookies.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
5
|
+
# The constant names match the native Rust variants.
|
|
6
|
+
# standard:disable Naming/ConstantName
|
|
6
7
|
class SameSite
|
|
7
8
|
# Strict same-site policy.
|
|
8
9
|
Strict = nil
|
|
@@ -10,36 +11,67 @@ unless defined?(Wreq)
|
|
|
10
11
|
Lax = nil
|
|
11
12
|
# None same-site policy.
|
|
12
13
|
None = nil
|
|
14
|
+
|
|
15
|
+
# Returns the SameSite attribute name (e.g. "Strict", "Lax", "None").
|
|
16
|
+
# @return [String]
|
|
17
|
+
def to_s
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns the SameSite attribute as a lowercase symbol (e.g. :strict, :lax, :none).
|
|
21
|
+
# @return [Symbol]
|
|
22
|
+
def to_sym
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Value-based equality.
|
|
26
|
+
# @param other [Object]
|
|
27
|
+
# @return [Boolean]
|
|
28
|
+
def ==(other)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Strict equality for Hash key and Set member semantics.
|
|
32
|
+
# @param other [Object]
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
def eql?(other)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Hash value consistent with {#eql?} for use as Hash keys.
|
|
38
|
+
# @return [Integer]
|
|
39
|
+
def hash
|
|
40
|
+
end
|
|
13
41
|
end
|
|
42
|
+
# standard:enable Naming/ConstantName
|
|
14
43
|
|
|
15
|
-
# A single HTTP cookie.
|
|
44
|
+
# A single HTTP cookie backed by an immutable native value.
|
|
16
45
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
# Constructor accepts `name`, `value`, plus optional keyword arguments for
|
|
20
|
-
# other attributes.
|
|
46
|
+
# Cookie instances can be shared safely between threads. Pass optional
|
|
47
|
+
# attributes as keywords to {.new}.
|
|
21
48
|
class Cookie
|
|
22
|
-
#
|
|
49
|
+
# Creates a Cookie instance.
|
|
23
50
|
#
|
|
24
|
-
#
|
|
51
|
+
# The native extension defines `.new` directly instead of `#initialize`.
|
|
25
52
|
#
|
|
26
53
|
# @param name [String] Cookie name
|
|
27
54
|
# @param value [String] Cookie value
|
|
28
55
|
# @param options [Hash] Optional keyword arguments
|
|
29
56
|
# @option options [String] :domain Domain attribute
|
|
30
57
|
# @option options [String] :path Path attribute
|
|
31
|
-
# @option options [Integer] :max_age Max-Age in seconds
|
|
32
|
-
#
|
|
58
|
+
# @option options [Integer] :max_age Signed Max-Age in seconds.
|
|
59
|
+
# Zero or negative values expire the cookie immediately.
|
|
60
|
+
# @option options [Time, Numeric] :expires A Time or finite Unix timestamp in seconds
|
|
33
61
|
# @option options [Boolean] :http_only HttpOnly flag
|
|
34
62
|
# @option options [Boolean] :secure Secure flag
|
|
35
63
|
# @option options [Wreq::SameSite] :same_site SameSite attribute
|
|
36
64
|
# @return [Wreq::Cookie]
|
|
65
|
+
# @raise [ArgumentError] if an option is unknown or duplicated, or if :expires is not finite
|
|
66
|
+
# @raise [RangeError] if :max_age or :expires is outside the supported range
|
|
67
|
+
# @raise [TypeError] if an option has the wrong type
|
|
37
68
|
# @example
|
|
38
69
|
# c = Wreq::Cookie.new(
|
|
39
70
|
# "sid", "abc",
|
|
40
71
|
# domain: "example.com",
|
|
41
72
|
# path: "/",
|
|
42
73
|
# max_age: 3600,
|
|
74
|
+
# expires: Time.utc(2030, 1, 1),
|
|
43
75
|
# http_only: true,
|
|
44
76
|
# secure: true,
|
|
45
77
|
# same_site: Wreq::SameSite::Lax
|
|
@@ -85,6 +117,11 @@ unless defined?(Wreq)
|
|
|
85
117
|
def same_site_strict?
|
|
86
118
|
end
|
|
87
119
|
|
|
120
|
+
# Returns the SameSite setting, or nil if it was omitted.
|
|
121
|
+
# @return [Wreq::SameSite, nil]
|
|
122
|
+
def same_site
|
|
123
|
+
end
|
|
124
|
+
|
|
88
125
|
# @return [String, nil] Path attribute
|
|
89
126
|
def path
|
|
90
127
|
end
|
|
@@ -93,31 +130,50 @@ unless defined?(Wreq)
|
|
|
93
130
|
def domain
|
|
94
131
|
end
|
|
95
132
|
|
|
96
|
-
#
|
|
133
|
+
# Returns the signed Max-Age lifetime in seconds.
|
|
134
|
+
#
|
|
135
|
+
# Zero and negative values expire the cookie immediately.
|
|
136
|
+
# @return [Integer, nil]
|
|
97
137
|
def max_age
|
|
98
138
|
end
|
|
99
139
|
|
|
100
|
-
#
|
|
140
|
+
# Returns the expiration time in UTC.
|
|
141
|
+
# @return [Time, nil]
|
|
142
|
+
def expires_at
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Returns the expiration as a Unix timestamp with fractional seconds.
|
|
146
|
+
# The Float return value may lose precision for large timestamps.
|
|
147
|
+
# @deprecated Use {#expires_at}, which returns Time.
|
|
148
|
+
# @return [Float, nil]
|
|
101
149
|
def expires
|
|
102
150
|
end
|
|
151
|
+
|
|
152
|
+
# Returns the cookie formatted as a Set-Cookie value.
|
|
153
|
+
# @return [String]
|
|
154
|
+
def to_s
|
|
155
|
+
end
|
|
103
156
|
end
|
|
104
157
|
|
|
105
|
-
#
|
|
158
|
+
# Stores cookies for reuse across requests.
|
|
159
|
+
#
|
|
160
|
+
# Pass a Jar to Wreq::Client as `cookie_provider` to share its cookies.
|
|
106
161
|
class Jar
|
|
107
|
-
#
|
|
162
|
+
# Creates an empty cookie jar.
|
|
108
163
|
# @return [Wreq::Jar]
|
|
109
164
|
def self.new
|
|
110
165
|
end
|
|
111
166
|
|
|
112
|
-
#
|
|
167
|
+
# Returns all stored cookies.
|
|
113
168
|
# @return [Array<Wreq::Cookie>]
|
|
114
169
|
def get_all
|
|
115
170
|
end
|
|
116
171
|
|
|
117
|
-
#
|
|
118
|
-
# @param cookie [String, Wreq::Cookie]
|
|
119
|
-
# @param url [String]
|
|
172
|
+
# Adds a Cookie object or Set-Cookie string for the given URL.
|
|
173
|
+
# @param cookie [String, Wreq::Cookie] Cookie to store
|
|
174
|
+
# @param url [String] URL that scopes the cookie
|
|
120
175
|
# @return [void]
|
|
176
|
+
# @raise [TypeError] if cookie is neither a String nor Wreq::Cookie
|
|
121
177
|
def add(cookie, url)
|
|
122
178
|
end
|
|
123
179
|
|
|
@@ -138,6 +194,8 @@ end
|
|
|
138
194
|
|
|
139
195
|
module Wreq
|
|
140
196
|
class Cookie
|
|
197
|
+
# Returns a short representation for debugging.
|
|
198
|
+
# @return [String]
|
|
141
199
|
def inspect
|
|
142
200
|
parts = ["#<Wreq::Cookie", name]
|
|
143
201
|
parts << "domain=#{domain}" if domain
|
|
@@ -149,6 +207,8 @@ module Wreq
|
|
|
149
207
|
end
|
|
150
208
|
|
|
151
209
|
class Jar
|
|
210
|
+
# Returns a short representation with the number of stored cookies.
|
|
211
|
+
# @return [String]
|
|
152
212
|
def inspect
|
|
153
213
|
"#<Wreq::Jar [#{get_all.length} cookies]>"
|
|
154
214
|
end
|