wreq 1.2.4 → 1.2.6

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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +22 -19
  3. data/Cargo.toml +15 -2
  4. data/crates/wreq-util/.github/FUNDING.yml +15 -0
  5. data/crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  6. data/crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md +10 -0
  7. data/crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/crates/wreq-util/.github/dependabot.yml +22 -0
  9. data/crates/wreq-util/.github/workflows/ci.yml +82 -0
  10. data/crates/wreq-util/.github/workflows/release-plz.yml +52 -0
  11. data/crates/wreq-util/.gitignore +24 -0
  12. data/crates/wreq-util/CHANGELOG.md +74 -0
  13. data/crates/wreq-util/Cargo.toml +94 -0
  14. data/crates/wreq-util/LICENSE +201 -0
  15. data/crates/wreq-util/README.md +62 -0
  16. data/crates/wreq-util/examples/emulate.rs +39 -0
  17. data/crates/wreq-util/examples/tower_delay.rs +191 -0
  18. data/crates/wreq-util/release-plz.toml +2 -0
  19. data/crates/wreq-util/rustfmt.toml +5 -0
  20. data/crates/wreq-util/src/emulate/compress.rs +85 -0
  21. data/crates/wreq-util/src/emulate/macros.rs +372 -0
  22. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +74 -0
  23. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +65 -0
  24. data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +153 -0
  25. data/crates/wreq-util/src/emulate/profile/chrome.rs +2028 -0
  26. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +37 -0
  27. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +113 -0
  28. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +253 -0
  29. data/crates/wreq-util/src/emulate/profile/firefox.rs +518 -0
  30. data/crates/wreq-util/src/emulate/profile/okhttp.rs +241 -0
  31. data/crates/wreq-util/src/emulate/profile/opera/header.rs +29 -0
  32. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +50 -0
  33. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +97 -0
  34. data/crates/wreq-util/src/emulate/profile/opera.rs +299 -0
  35. data/crates/wreq-util/src/emulate/profile/safari/header.rs +59 -0
  36. data/crates/wreq-util/src/emulate/profile/safari/http2.rs +116 -0
  37. data/crates/wreq-util/src/emulate/profile/safari/tls.rs +177 -0
  38. data/crates/wreq-util/src/emulate/profile/safari.rs +222 -0
  39. data/crates/wreq-util/src/emulate/profile.rs +47 -0
  40. data/crates/wreq-util/src/emulate.rs +369 -0
  41. data/crates/wreq-util/src/lib.rs +14 -0
  42. data/crates/wreq-util/src/rand.rs +24 -0
  43. data/crates/wreq-util/src/tower/delay/future.rs +43 -0
  44. data/crates/wreq-util/src/tower/delay/layer.rs +201 -0
  45. data/crates/wreq-util/src/tower/delay/service.rs +190 -0
  46. data/crates/wreq-util/src/tower/delay.rs +98 -0
  47. data/crates/wreq-util/src/tower.rs +7 -0
  48. data/crates/wreq-util/tests/client.rs +153 -0
  49. data/crates/wreq-util/tests/emulate_chrome.rs +270 -0
  50. data/crates/wreq-util/tests/emulate_firefox.rs +92 -0
  51. data/crates/wreq-util/tests/emulate_okhttp.rs +46 -0
  52. data/crates/wreq-util/tests/emulate_opera.rs +113 -0
  53. data/crates/wreq-util/tests/emulate_safari.rs +151 -0
  54. data/crates/wreq-util/tests/support/mod.rs +55 -0
  55. data/crates/wreq-util/tests/support/server.rs +232 -0
  56. data/examples/emulate_request.rb +1 -1
  57. data/lib/wreq.rb +72 -45
  58. data/lib/wreq_ruby/body.rb +30 -9
  59. data/lib/wreq_ruby/client.rb +88 -55
  60. data/lib/wreq_ruby/cookie.rb +81 -21
  61. data/lib/wreq_ruby/emulate.rb +77 -7
  62. data/lib/wreq_ruby/error.rb +5 -7
  63. data/lib/wreq_ruby/header.rb +205 -114
  64. data/lib/wreq_ruby/http.rb +74 -0
  65. data/lib/wreq_ruby/response.rb +31 -3
  66. data/script/build_windows_gnu.ps1 +6 -0
  67. data/src/arch.rs +22 -0
  68. data/src/client/body/form.rs +2 -0
  69. data/src/client/body/json.rs +47 -14
  70. data/src/client/body/stream.rs +147 -43
  71. data/src/client/body.rs +11 -15
  72. data/src/client/param.rs +7 -7
  73. data/src/client/req.rs +87 -47
  74. data/src/client/resp.rs +23 -24
  75. data/src/client.rs +310 -230
  76. data/src/cookie.rs +280 -87
  77. data/src/emulate.rs +86 -50
  78. data/src/error.rs +198 -45
  79. data/src/extractor.rs +16 -76
  80. data/src/header.rs +318 -130
  81. data/src/http.rs +62 -33
  82. data/src/lib.rs +26 -20
  83. data/src/macros.rs +71 -46
  84. data/src/options.rs +284 -0
  85. data/src/rt.rs +22 -11
  86. data/src/serde/de/array_deserializer.rs +48 -0
  87. data/src/serde/de/array_enumerator.rs +59 -0
  88. data/src/serde/de/deserializer.rs +307 -0
  89. data/src/serde/de/enum_deserializer.rs +47 -0
  90. data/src/serde/de/hash_deserializer.rs +89 -0
  91. data/src/serde/de/number_deserializer.rs +51 -0
  92. data/src/serde/de/variant_deserializer.rs +101 -0
  93. data/src/serde/de.rs +33 -0
  94. data/src/serde/error.rs +146 -0
  95. data/src/serde/ser/enums.rs +14 -0
  96. data/src/serde/ser/map_serializer.rs +56 -0
  97. data/src/serde/ser/seq_serializer.rs +71 -0
  98. data/src/serde/ser/serializer.rs +194 -0
  99. data/src/serde/ser/struct_serializer.rs +106 -0
  100. data/src/serde/ser/struct_variant_serializer.rs +44 -0
  101. data/src/serde/ser/tuple_variant_serializer.rs +41 -0
  102. data/src/serde/ser.rs +18 -0
  103. data/src/serde/tests.rs +237 -0
  104. data/src/serde.rs +202 -0
  105. data/test/body_sender_test.rb +246 -0
  106. data/test/cookie_test.rb +211 -10
  107. data/test/header_test.rb +228 -192
  108. data/test/json_precision_test.rb +209 -0
  109. data/test/option_validation_test.rb +311 -0
  110. data/test/stream_test.rb +36 -0
  111. data/test/value_semantics_test.rb +238 -0
  112. metadata +77 -1
@@ -0,0 +1,55 @@
1
+ #![allow(dead_code)]
2
+ pub mod server;
3
+
4
+ use std::{sync::LazyLock, time::Duration};
5
+
6
+ use tokio::sync::Semaphore;
7
+ use wreq::Client;
8
+
9
+ // TODO: remove once done converting to new support server?
10
+ #[allow(unused)]
11
+ pub static DEFAULT_USER_AGENT: &str =
12
+ concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
13
+
14
+ pub static TEST_SEMAPHORE: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(1));
15
+
16
+ pub static CLIENT: LazyLock<Client> = LazyLock::new(|| {
17
+ Client::builder()
18
+ .connect_timeout(Duration::from_secs(60))
19
+ .build()
20
+ .unwrap()
21
+ });
22
+
23
+ #[allow(unused_macros)]
24
+ macro_rules! test_emulation {
25
+ ($test_name:ident, $emulation:expr, $ja4:expr, $akamai_hash:expr) => {
26
+ #[tokio::test]
27
+ async fn $test_name() {
28
+ let _permit = crate::support::TEST_SEMAPHORE.acquire().await.unwrap();
29
+
30
+ let resp = crate::support::CLIENT
31
+ .get("https://tls.browserleaks.com/")
32
+ .emulation($emulation)
33
+ .send()
34
+ .await
35
+ .unwrap();
36
+
37
+ assert_eq!(resp.status(), wreq::StatusCode::OK);
38
+ let content = resp.text().await.unwrap();
39
+
40
+ let conditional = $ja4.iter().any(|&ja4| content.contains(ja4));
41
+ if !conditional {
42
+ println!("{}", content);
43
+ }
44
+ assert!(conditional);
45
+
46
+ let conditional = content.contains($akamai_hash);
47
+ if !conditional {
48
+ println!("{}", content);
49
+ }
50
+ assert!(conditional);
51
+
52
+ tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
53
+ }
54
+ };
55
+ }
@@ -0,0 +1,232 @@
1
+ #![cfg(not(target_arch = "wasm32"))]
2
+ use std::{
3
+ convert::Infallible, future::Future, net, sync::mpsc as std_mpsc, thread, time::Duration,
4
+ };
5
+
6
+ use tokio::{io::AsyncReadExt, net::TcpStream, runtime, sync::oneshot};
7
+
8
+ pub struct Server {
9
+ addr: net::SocketAddr,
10
+ panic_rx: std_mpsc::Receiver<()>,
11
+ events_rx: std_mpsc::Receiver<Event>,
12
+ shutdown_tx: Option<oneshot::Sender<()>>,
13
+ }
14
+
15
+ #[non_exhaustive]
16
+ pub enum Event {
17
+ ConnectionClosed,
18
+ }
19
+
20
+ impl Server {
21
+ pub fn addr(&self) -> net::SocketAddr {
22
+ self.addr
23
+ }
24
+
25
+ #[allow(unused)]
26
+ pub fn events(&mut self) -> Vec<Event> {
27
+ let mut events = Vec::new();
28
+ while let Ok(event) = self.events_rx.try_recv() {
29
+ events.push(event);
30
+ }
31
+ events
32
+ }
33
+ }
34
+
35
+ impl Drop for Server {
36
+ fn drop(&mut self) {
37
+ if let Some(tx) = self.shutdown_tx.take() {
38
+ let _ = tx.send(());
39
+ }
40
+
41
+ if !::std::thread::panicking() {
42
+ self.panic_rx
43
+ .recv_timeout(Duration::from_secs(3))
44
+ .expect("test server should not panic");
45
+ }
46
+ }
47
+ }
48
+
49
+ pub fn http<F, Fut>(func: F) -> Server
50
+ where
51
+ F: Fn(http::Request<hyper::body::Incoming>) -> Fut + Clone + Send + 'static,
52
+ Fut: Future<Output = http::Response<wreq::Body>> + Send + 'static,
53
+ {
54
+ http_with_config(func, |_builder| {})
55
+ }
56
+
57
+ type Builder = hyper_util::server::conn::auto::Builder<hyper_util::rt::TokioExecutor>;
58
+
59
+ pub fn http_with_config<F1, Fut, F2, Bu>(func: F1, apply_config: F2) -> Server
60
+ where
61
+ F1: Fn(http::Request<hyper::body::Incoming>) -> Fut + Clone + Send + 'static,
62
+ Fut: Future<Output = http::Response<wreq::Body>> + Send + 'static,
63
+ F2: FnOnce(&mut Builder) -> Bu + Send + 'static,
64
+ {
65
+ // Spawn new runtime in thread to prevent reactor execution context conflict
66
+ let test_name = thread::current().name().unwrap_or("<unknown>").to_string();
67
+ thread::spawn(move || {
68
+ let rt = runtime::Builder::new_current_thread()
69
+ .enable_all()
70
+ .build()
71
+ .expect("new rt");
72
+ let listener = rt.block_on(async move {
73
+ tokio::net::TcpListener::bind(&std::net::SocketAddr::from(([127, 0, 0, 1], 0)))
74
+ .await
75
+ .unwrap()
76
+ });
77
+ let addr = listener.local_addr().unwrap();
78
+
79
+ let (shutdown_tx, mut shutdown_rx) = oneshot::channel();
80
+ let (panic_tx, panic_rx) = std_mpsc::channel();
81
+ let (events_tx, events_rx) = std_mpsc::channel();
82
+ let tname = format!(
83
+ "test({})-support-server",
84
+ test_name,
85
+ );
86
+ thread::Builder::new()
87
+ .name(tname)
88
+ .spawn(move || {
89
+ rt.block_on(async move {
90
+ let mut builder =
91
+ hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new());
92
+ apply_config(&mut builder);
93
+
94
+ loop {
95
+ tokio::select! {
96
+ _ = &mut shutdown_rx => {
97
+ break;
98
+ }
99
+ accepted = listener.accept() => {
100
+ let (io, _) = accepted.expect("accepted");
101
+ let func = func.clone();
102
+ let svc = hyper::service::service_fn(move |req| {
103
+ let fut = func(req);
104
+ async move { Ok::<_, Infallible>(fut.await) }
105
+ });
106
+ let builder = builder.clone();
107
+ let events_tx = events_tx.clone();
108
+ tokio::spawn(async move {
109
+ let _ = builder.serve_connection_with_upgrades(hyper_util::rt::TokioIo::new(io), svc).await;
110
+ let _ = events_tx.send(Event::ConnectionClosed);
111
+ });
112
+ }
113
+ }
114
+ }
115
+ let _ = panic_tx.send(());
116
+ });
117
+ })
118
+ .expect("thread spawn");
119
+ Server {
120
+ addr,
121
+ panic_rx,
122
+ events_rx,
123
+ shutdown_tx: Some(shutdown_tx),
124
+ }
125
+ })
126
+ .join()
127
+ .unwrap()
128
+ }
129
+
130
+ #[allow(unused)]
131
+ pub fn low_level_with_response<F>(do_response: F) -> Server
132
+ where
133
+ for<'c> F: Fn(&'c [u8], &'c mut TcpStream) -> Box<dyn Future<Output = ()> + Send + 'c>
134
+ + Clone
135
+ + Send
136
+ + 'static,
137
+ {
138
+ // Spawn new runtime in thread to prevent reactor execution context conflict
139
+ let test_name = thread::current().name().unwrap_or("<unknown>").to_string();
140
+ thread::spawn(move || {
141
+ let rt = runtime::Builder::new_current_thread()
142
+ .enable_all()
143
+ .build()
144
+ .expect("new rt");
145
+ let listener = rt.block_on(async move {
146
+ tokio::net::TcpListener::bind(&std::net::SocketAddr::from(([127, 0, 0, 1], 0)))
147
+ .await
148
+ .unwrap()
149
+ });
150
+ let addr = listener.local_addr().unwrap();
151
+
152
+ let (shutdown_tx, mut shutdown_rx) = oneshot::channel();
153
+ let (panic_tx, panic_rx) = std_mpsc::channel();
154
+ let (events_tx, events_rx) = std_mpsc::channel();
155
+ let tname = format!("test({})-support-server", test_name,);
156
+ thread::Builder::new()
157
+ .name(tname)
158
+ .spawn(move || {
159
+ rt.block_on(async move {
160
+ loop {
161
+ tokio::select! {
162
+ _ = &mut shutdown_rx => {
163
+ break;
164
+ }
165
+ accepted = listener.accept() => {
166
+ let (io, _) = accepted.expect("accepted");
167
+ let do_response = do_response.clone();
168
+ let events_tx = events_tx.clone();
169
+ tokio::spawn(async move {
170
+ low_level_server_client(io, do_response).await;
171
+ let _ = events_tx.send(Event::ConnectionClosed);
172
+ });
173
+ }
174
+ }
175
+ }
176
+ let _ = panic_tx.send(());
177
+ });
178
+ })
179
+ .expect("thread spawn");
180
+ Server {
181
+ addr,
182
+ panic_rx,
183
+ events_rx,
184
+ shutdown_tx: Some(shutdown_tx),
185
+ }
186
+ })
187
+ .join()
188
+ .unwrap()
189
+ }
190
+
191
+ #[allow(unused)]
192
+ async fn low_level_server_client<F>(mut client_socket: TcpStream, do_response: F)
193
+ where
194
+ for<'c> F: Fn(&'c [u8], &'c mut TcpStream) -> Box<dyn Future<Output = ()> + Send + 'c>,
195
+ {
196
+ loop {
197
+ let request = low_level_read_http_request(&mut client_socket)
198
+ .await
199
+ .expect("read_http_request failed");
200
+ if request.is_empty() {
201
+ // connection closed by client
202
+ break;
203
+ }
204
+
205
+ Box::into_pin(do_response(&request, &mut client_socket)).await;
206
+ }
207
+ }
208
+
209
+ #[allow(unused)]
210
+ async fn low_level_read_http_request(
211
+ client_socket: &mut TcpStream,
212
+ ) -> core::result::Result<Vec<u8>, std::io::Error> {
213
+ let mut buf = Vec::new();
214
+
215
+ // Read until the delimiter "\r\n\r\n" is found
216
+ loop {
217
+ let mut temp_buffer = [0; 1024];
218
+ let n = client_socket.read(&mut temp_buffer).await?;
219
+
220
+ if n == 0 {
221
+ break;
222
+ }
223
+
224
+ buf.extend_from_slice(&temp_buffer[..n]);
225
+
226
+ if let Some(pos) = buf.windows(4).position(|window| window == b"\r\n\r\n") {
227
+ return Ok(buf.drain(..pos + 4).collect());
228
+ }
229
+ }
230
+
231
+ Ok(buf)
232
+ }
@@ -11,7 +11,7 @@ require_relative "../lib/wreq"
11
11
  # Set when creating the Wreq::Client instance.
12
12
  # All requests from this client will use the specified emulation unless overridden.
13
13
  client = Wreq::Client.new(emulation: Wreq::Emulation.new(
14
- profile: Wreq::Profile::Chrome149,
14
+ profile: Wreq::Profile::Chrome150,
15
15
  platform: Wreq::Platform::MacOS,
16
16
  http2: true,
17
17
  headers: true
data/lib/wreq.rb CHANGED
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  # Load type hint definitions
11
11
  require_relative "wreq_ruby/http"
12
+ require_relative "wreq_ruby/emulate"
12
13
  require_relative "wreq_ruby/client"
13
14
  require_relative "wreq_ruby/response"
14
15
  require_relative "wreq_ruby/body"
@@ -18,22 +19,30 @@ require_relative "wreq_ruby/cookie"
18
19
 
19
20
  unless defined?(Wreq)
20
21
  module Wreq
22
+ # Current wreq gem version.
23
+ # @return [String]
21
24
  VERSION = nil
22
25
 
26
+ # Module request methods accept only the options documented for each
27
+ # method. Unknown, ambiguous, ineffective, and unavailable platform options
28
+ # raise ArgumentError. Known values retain the error class from their Ruby
29
+ # or native conversion, such as TypeError or Wreq::BuilderError. Validation
30
+ # finishes before network I/O.
31
+
23
32
  # Send an HTTP request.
24
33
  #
25
34
  # @param method [Wreq::Method] HTTP method to use
26
35
  # @param url [String] Target URL
27
36
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
28
37
  # @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
38
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
30
39
  # @param query [Hash, nil] URL query parameters
31
40
  # @param auth [String, nil] Authorization header value
32
41
  # @param bearer_auth [String, nil] Bearer token for Authorization header
33
42
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
34
43
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
35
44
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
36
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
45
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
37
46
  # @param gzip [Boolean, nil] Enable gzip compression
38
47
  # @param brotli [Boolean, nil] Enable Brotli compression
39
48
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -42,13 +51,15 @@ unless defined?(Wreq)
42
51
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
43
52
  # @param proxy [String, nil] Proxy server URI
44
53
  # @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).
54
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
46
55
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
47
56
  # @param version [Wreq::Version, nil] HTTP version to use
48
57
  # @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)
58
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
59
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
51
60
  # @return [Wreq::Response] HTTP response
61
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
62
+ # value cannot be converted, validated, or built
52
63
  def self.request(method, url, **options)
53
64
  end
54
65
 
@@ -57,14 +68,14 @@ unless defined?(Wreq)
57
68
  # @param url [String] Target URL
58
69
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
59
70
  # @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
71
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
61
72
  # @param query [Hash, nil] URL query parameters
62
73
  # @param auth [String, nil] Authorization header value
63
74
  # @param bearer_auth [String, nil] Bearer token for Authorization header
64
75
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
65
76
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
66
77
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
67
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
78
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
68
79
  # @param gzip [Boolean, nil] Enable gzip compression
69
80
  # @param brotli [Boolean, nil] Enable Brotli compression
70
81
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -73,13 +84,15 @@ unless defined?(Wreq)
73
84
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
74
85
  # @param proxy [String, nil] Proxy server URI
75
86
  # @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).
87
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
77
88
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
78
89
  # @param version [Wreq::Version, nil] HTTP version to use
79
90
  # @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)
91
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
92
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
82
93
  # @return [Wreq::Response] HTTP response
94
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
95
+ # value cannot be converted, validated, or built
83
96
  def self.get(url, **options)
84
97
  end
85
98
 
@@ -88,14 +101,14 @@ unless defined?(Wreq)
88
101
  # @param url [String] Target URL
89
102
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
90
103
  # @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
104
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
92
105
  # @param query [Hash, nil] URL query parameters
93
106
  # @param auth [String, nil] Authorization header value
94
107
  # @param bearer_auth [String, nil] Bearer token for Authorization header
95
108
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
96
109
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
97
110
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
98
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
111
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
99
112
  # @param gzip [Boolean, nil] Enable gzip compression
100
113
  # @param brotli [Boolean, nil] Enable Brotli compression
101
114
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -104,13 +117,15 @@ unless defined?(Wreq)
104
117
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
105
118
  # @param proxy [String, nil] Proxy server URI
106
119
  # @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).
120
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
108
121
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
109
122
  # @param version [Wreq::Version, nil] HTTP version to use
110
123
  # @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)
124
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
125
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
113
126
  # @return [Wreq::Response] HTTP response
127
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
128
+ # value cannot be converted, validated, or built
114
129
  def self.head(url, **options)
115
130
  end
116
131
 
@@ -119,14 +134,14 @@ unless defined?(Wreq)
119
134
  # @param url [String] Target URL
120
135
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
121
136
  # @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
137
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
123
138
  # @param query [Hash, nil] URL query parameters
124
139
  # @param auth [String, nil] Authorization header value
125
140
  # @param bearer_auth [String, nil] Bearer token for Authorization header
126
141
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
127
142
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
128
143
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
129
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
144
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
130
145
  # @param gzip [Boolean, nil] Enable gzip compression
131
146
  # @param brotli [Boolean, nil] Enable Brotli compression
132
147
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -135,13 +150,15 @@ unless defined?(Wreq)
135
150
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
136
151
  # @param proxy [String, nil] Proxy server URI
137
152
  # @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).
153
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
139
154
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
140
155
  # @param version [Wreq::Version, nil] HTTP version to use
141
156
  # @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)
157
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
158
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
144
159
  # @return [Wreq::Response] HTTP response
160
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
161
+ # value cannot be converted, validated, or built
145
162
  def self.post(url, **options)
146
163
  end
147
164
 
@@ -150,14 +167,14 @@ unless defined?(Wreq)
150
167
  # @param url [String] Target URL
151
168
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
152
169
  # @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
170
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
154
171
  # @param query [Hash, nil] URL query parameters
155
172
  # @param auth [String, nil] Authorization header value
156
173
  # @param bearer_auth [String, nil] Bearer token for Authorization header
157
174
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
158
175
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
159
176
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
160
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
177
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
161
178
  # @param gzip [Boolean, nil] Enable gzip compression
162
179
  # @param brotli [Boolean, nil] Enable Brotli compression
163
180
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -166,13 +183,15 @@ unless defined?(Wreq)
166
183
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
167
184
  # @param proxy [String, nil] Proxy server URI
168
185
  # @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).
186
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
170
187
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
171
188
  # @param version [Wreq::Version, nil] HTTP version to use
172
189
  # @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)
190
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
191
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
175
192
  # @return [Wreq::Response] HTTP response
193
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
194
+ # value cannot be converted, validated, or built
176
195
  def self.put(url, **options)
177
196
  end
178
197
 
@@ -181,14 +200,14 @@ unless defined?(Wreq)
181
200
  # @param url [String] Target URL
182
201
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
183
202
  # @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
203
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
185
204
  # @param query [Hash, nil] URL query parameters
186
205
  # @param auth [String, nil] Authorization header value
187
206
  # @param bearer_auth [String, nil] Bearer token for Authorization header
188
207
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
189
208
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
190
209
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
191
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
210
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
192
211
  # @param gzip [Boolean, nil] Enable gzip compression
193
212
  # @param brotli [Boolean, nil] Enable Brotli compression
194
213
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -197,13 +216,15 @@ unless defined?(Wreq)
197
216
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
198
217
  # @param proxy [String, nil] Proxy server URI
199
218
  # @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).
219
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
201
220
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
202
221
  # @param version [Wreq::Version, nil] HTTP version to use
203
222
  # @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)
223
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
224
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
206
225
  # @return [Wreq::Response] HTTP response
226
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
227
+ # value cannot be converted, validated, or built
207
228
  def self.delete(url, **options)
208
229
  end
209
230
 
@@ -212,14 +233,14 @@ unless defined?(Wreq)
212
233
  # @param url [String] Target URL
213
234
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
214
235
  # @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
236
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
216
237
  # @param query [Hash, nil] URL query parameters
217
238
  # @param auth [String, nil] Authorization header value
218
239
  # @param bearer_auth [String, nil] Bearer token for Authorization header
219
240
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
220
241
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
221
242
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
222
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
243
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
223
244
  # @param gzip [Boolean, nil] Enable gzip compression
224
245
  # @param brotli [Boolean, nil] Enable Brotli compression
225
246
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -228,13 +249,15 @@ unless defined?(Wreq)
228
249
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
229
250
  # @param proxy [String, nil] Proxy server URI
230
251
  # @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).
252
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
232
253
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
233
254
  # @param version [Wreq::Version, nil] HTTP version to use
234
255
  # @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)
256
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
257
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
237
258
  # @return [Wreq::Response] HTTP response
259
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
260
+ # value cannot be converted, validated, or built
238
261
  def self.options(url, **options)
239
262
  end
240
263
 
@@ -243,14 +266,14 @@ unless defined?(Wreq)
243
266
  # @param url [String] Target URL
244
267
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
245
268
  # @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
269
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
247
270
  # @param query [Hash, nil] URL query parameters
248
271
  # @param auth [String, nil] Authorization header value
249
272
  # @param bearer_auth [String, nil] Bearer token for Authorization header
250
273
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
251
274
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
252
275
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
253
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
276
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
254
277
  # @param gzip [Boolean, nil] Enable gzip compression
255
278
  # @param brotli [Boolean, nil] Enable Brotli compression
256
279
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -259,13 +282,15 @@ unless defined?(Wreq)
259
282
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
260
283
  # @param proxy [String, nil] Proxy server URI
261
284
  # @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).
285
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
263
286
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
264
287
  # @param version [Wreq::Version, nil] HTTP version to use
265
288
  # @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)
289
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
290
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
268
291
  # @return [Wreq::Response] HTTP response
292
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
293
+ # value cannot be converted, validated, or built
269
294
  def self.trace(url, **options)
270
295
  end
271
296
 
@@ -274,14 +299,14 @@ unless defined?(Wreq)
274
299
  # @param url [String] Target URL
275
300
  # @param headers [Wreq::Headers, Hash{String=>String}, nil] Custom headers for this request
276
301
  # @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
302
+ # @param default_headers [Boolean, nil] Whether to apply native default headers
278
303
  # @param query [Hash, nil] URL query parameters
279
304
  # @param auth [String, nil] Authorization header value
280
305
  # @param bearer_auth [String, nil] Bearer token for Authorization header
281
306
  # @param basic_auth [Array<String>, nil] Username and password for basic auth
282
307
  # @param cookies [Hash{String=>String}, String, nil] Cookies to send
283
308
  # @param allow_redirects [Boolean, nil] Whether to follow redirects
284
- # @param max_redirects [Integer, nil] Maximum number of redirects to follow
309
+ # @param max_redirects [Integer, nil] Maximum redirects; requires allow_redirects: true
285
310
  # @param gzip [Boolean, nil] Enable gzip compression
286
311
  # @param brotli [Boolean, nil] Enable Brotli compression
287
312
  # @param deflate [Boolean, nil] Enable deflate compression
@@ -290,13 +315,15 @@ unless defined?(Wreq)
290
315
  # @param read_timeout [Integer, nil] Per-chunk read timeout (seconds)
291
316
  # @param proxy [String, nil] Proxy server URI
292
317
  # @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).
318
+ # @param interface [String, nil] Bind to an interface on supported platforms; unsupported platforms raise ArgumentError.
294
319
  # @param emulation [Wreq::Emulation, nil] Device/OS emulation for this request
295
320
  # @param version [Wreq::Version, nil] HTTP version to use
296
321
  # @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)
322
+ # @param json [Object, nil] JSON body serialized by the native encoder; Integer values retain arbitrary precision
323
+ # @param body [String, Wreq::BodySender, nil] Raw or streaming request body
299
324
  # @return [Wreq::Response] HTTP response
325
+ # @raise [TypeError, ArgumentError, Wreq::BuilderError] if a known option
326
+ # value cannot be converted, validated, or built
300
327
  def self.patch(url, **options)
301
328
  end
302
329
  end