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
data/lib/wreq.rb
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
5
|
+
require_relative "wreq_ruby/#{$1}/wreq_ruby"
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require_relative "wreq_ruby/wreq_ruby"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Load type hint definitions
|
|
11
|
+
require_relative "wreq_ruby/http"
|
|
12
|
+
require_relative "wreq_ruby/client"
|
|
13
|
+
require_relative "wreq_ruby/response"
|
|
14
|
+
require_relative "wreq_ruby/body"
|
|
15
|
+
require_relative "wreq_ruby/header"
|
|
16
|
+
require_relative "wreq_ruby/error"
|
|
17
|
+
require_relative "wreq_ruby/cookie"
|
|
18
|
+
|
|
19
|
+
unless defined?(Wreq)
|
|
20
|
+
module Wreq
|
|
21
|
+
VERSION = nil
|
|
22
|
+
|
|
23
|
+
# Send an HTTP request.
|
|
24
|
+
#
|
|
25
|
+
# @param method [Wreq::Method] HTTP method to use
|
|
26
|
+
# @param url [String] Target URL
|
|
27
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
28
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
29
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
30
|
+
# @param query [Hash, nil] URL query parameters
|
|
31
|
+
# @param auth [String, nil] Authorization header value
|
|
32
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
33
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
34
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
35
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
36
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
37
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
38
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
39
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
40
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
41
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
42
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
43
|
+
# @param proxy [String, nil] Proxy server URI
|
|
44
|
+
# @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 or the connection may fail.
|
|
45
|
+
# @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).
|
|
46
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
47
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
48
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
49
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
50
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
51
|
+
# @return [Wreq::Response] HTTP response
|
|
52
|
+
def self.request(method, url, **options)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Send an HTTP GET request.
|
|
56
|
+
#
|
|
57
|
+
# @param url [String] Target URL
|
|
58
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
59
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
60
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
61
|
+
# @param query [Hash, nil] URL query parameters
|
|
62
|
+
# @param auth [String, nil] Authorization header value
|
|
63
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
64
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
65
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
66
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
67
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
68
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
69
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
70
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
71
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
72
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
73
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
74
|
+
# @param proxy [String, nil] Proxy server URI
|
|
75
|
+
# @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 or the connection may fail.
|
|
76
|
+
# @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).
|
|
77
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
78
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
79
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
80
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
81
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
82
|
+
# @return [Wreq::Response] HTTP response
|
|
83
|
+
def self.get(url, **options)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Send an HTTP HEAD request.
|
|
87
|
+
#
|
|
88
|
+
# @param url [String] Target URL
|
|
89
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
90
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
91
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
92
|
+
# @param query [Hash, nil] URL query parameters
|
|
93
|
+
# @param auth [String, nil] Authorization header value
|
|
94
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
95
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
96
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
97
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
98
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
99
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
100
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
101
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
102
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
103
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
104
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
105
|
+
# @param proxy [String, nil] Proxy server URI
|
|
106
|
+
# @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 or the connection may fail.
|
|
107
|
+
# @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).
|
|
108
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
109
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
110
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
111
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
112
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
113
|
+
# @return [Wreq::Response] HTTP response
|
|
114
|
+
def self.head(url, **options)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Send an HTTP POST request.
|
|
118
|
+
#
|
|
119
|
+
# @param url [String] Target URL
|
|
120
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
121
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
122
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
123
|
+
# @param query [Hash, nil] URL query parameters
|
|
124
|
+
# @param auth [String, nil] Authorization header value
|
|
125
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
126
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
127
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
128
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
129
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
130
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
131
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
132
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
133
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
134
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
135
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
136
|
+
# @param proxy [String, nil] Proxy server URI
|
|
137
|
+
# @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 or the connection may fail.
|
|
138
|
+
# @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).
|
|
139
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
140
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
141
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
142
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
143
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
144
|
+
# @return [Wreq::Response] HTTP response
|
|
145
|
+
def self.post(url, **options)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Send an HTTP PUT request.
|
|
149
|
+
#
|
|
150
|
+
# @param url [String] Target URL
|
|
151
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
152
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
153
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
154
|
+
# @param query [Hash, nil] URL query parameters
|
|
155
|
+
# @param auth [String, nil] Authorization header value
|
|
156
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
157
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
158
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
159
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
160
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
161
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
162
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
163
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
164
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
165
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
166
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
167
|
+
# @param proxy [String, nil] Proxy server URI
|
|
168
|
+
# @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 or the connection may fail.
|
|
169
|
+
# @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).
|
|
170
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
171
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
172
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
173
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
174
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
175
|
+
# @return [Wreq::Response] HTTP response
|
|
176
|
+
def self.put(url, **options)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Send an HTTP DELETE request.
|
|
180
|
+
#
|
|
181
|
+
# @param url [String] Target URL
|
|
182
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
183
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
184
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
185
|
+
# @param query [Hash, nil] URL query parameters
|
|
186
|
+
# @param auth [String, nil] Authorization header value
|
|
187
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
188
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
189
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
190
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
191
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
192
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
193
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
194
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
195
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
196
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
197
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
198
|
+
# @param proxy [String, nil] Proxy server URI
|
|
199
|
+
# @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 or the connection may fail.
|
|
200
|
+
# @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).
|
|
201
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
202
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
203
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
204
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
205
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
206
|
+
# @return [Wreq::Response] HTTP response
|
|
207
|
+
def self.delete(url, **options)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Send an HTTP OPTIONS request.
|
|
211
|
+
#
|
|
212
|
+
# @param url [String] Target URL
|
|
213
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
214
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
215
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
216
|
+
# @param query [Hash, nil] URL query parameters
|
|
217
|
+
# @param auth [String, nil] Authorization header value
|
|
218
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
219
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
220
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
221
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
222
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
223
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
224
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
225
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
226
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
227
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
228
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
229
|
+
# @param proxy [String, nil] Proxy server URI
|
|
230
|
+
# @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 or the connection may fail.
|
|
231
|
+
# @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).
|
|
232
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
233
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
234
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
235
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
236
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
237
|
+
# @return [Wreq::Response] HTTP response
|
|
238
|
+
def self.options(url, **options)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Send an HTTP TRACE request.
|
|
242
|
+
#
|
|
243
|
+
# @param url [String] Target URL
|
|
244
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
245
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
246
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
247
|
+
# @param query [Hash, nil] URL query parameters
|
|
248
|
+
# @param auth [String, nil] Authorization header value
|
|
249
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
250
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
251
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
252
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
253
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
254
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
255
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
256
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
257
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
258
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
259
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
260
|
+
# @param proxy [String, nil] Proxy server URI
|
|
261
|
+
# @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 or the connection may fail.
|
|
262
|
+
# @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).
|
|
263
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
264
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
265
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
266
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
267
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
268
|
+
# @return [Wreq::Response] HTTP response
|
|
269
|
+
def self.trace(url, **options)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Send an HTTP PATCH request.
|
|
273
|
+
#
|
|
274
|
+
# @param url [String] Target URL
|
|
275
|
+
# @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
|
|
276
|
+
# @param orig_headers [Array<String>, nil] Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling
|
|
277
|
+
# @param default_headers [Hash{String=>String}, nil] Default headers to merge
|
|
278
|
+
# @param query [Hash, nil] URL query parameters
|
|
279
|
+
# @param auth [String, nil] Authorization header value
|
|
280
|
+
# @param bearer_auth [String, nil] Bearer token for Authorization header
|
|
281
|
+
# @param basic_auth [Array<String>, nil] Username and password for basic auth
|
|
282
|
+
# @param cookies [Hash{String=>String}, String, nil] Cookies to send
|
|
283
|
+
# @param allow_redirects [Boolean, nil] Whether to follow redirects
|
|
284
|
+
# @param max_redirects [Integer, nil] Maximum number of redirects to follow
|
|
285
|
+
# @param gzip [Boolean, nil] Enable gzip compression
|
|
286
|
+
# @param brotli [Boolean, nil] Enable Brotli compression
|
|
287
|
+
# @param deflate [Boolean, nil] Enable deflate compression
|
|
288
|
+
# @param zstd [Boolean, nil] Enable Zstandard compression
|
|
289
|
+
# @param timeout [Integer, nil] Total request timeout (seconds)
|
|
290
|
+
# @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
|
|
291
|
+
# @param proxy [String, nil] Proxy server URI
|
|
292
|
+
# @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 or the connection may fail.
|
|
293
|
+
# @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).
|
|
294
|
+
# @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
|
|
295
|
+
# @param version [Wreq::Version, nil] HTTP version to use
|
|
296
|
+
# @param form [Hash{String=>String}, nil] Form data (application/x-www-form-urlencoded)
|
|
297
|
+
# @param json [Object, nil] JSON body (will be serialized)
|
|
298
|
+
# @param body [String, IO, nil] Raw request body (string or stream)
|
|
299
|
+
# @return [Wreq::Response] HTTP response
|
|
300
|
+
def self.patch(url, **options)
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
unless defined?(Wreq)
|
|
4
|
+
module Wreq
|
|
5
|
+
# BodySender: for streaming request bodies, allowing thread-safe chunked data push.
|
|
6
|
+
# Backed by a Rust channel, avoids buffering the entire payload in memory.
|
|
7
|
+
#
|
|
8
|
+
# Supports multi-threaded chunk push: you can safely call `push` from multiple threads.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# sender = Wreq::BodySender.new(8)
|
|
12
|
+
# Thread.new do
|
|
13
|
+
# File.open('big.bin', 'rb') { |f| while (chunk = f.read(65536)); sender.push(chunk); end }
|
|
14
|
+
# sender.close
|
|
15
|
+
# end
|
|
16
|
+
# resp = client.post(url, body: sender)
|
|
17
|
+
#
|
|
18
|
+
# Note:
|
|
19
|
+
# - Sender is for request upload only, not for response reading.
|
|
20
|
+
# - Each BodySender instance can only be used once (single-use):
|
|
21
|
+
# after being consumed by a request, further push or reuse is not allowed.
|
|
22
|
+
class BodySender
|
|
23
|
+
# @param capacity [Integer] channel buffer size, default 8
|
|
24
|
+
def self.new(capacity = 8)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param data [String] binary chunk
|
|
28
|
+
def push(data)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Close the sender, signaling end of data.
|
|
32
|
+
def close
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|