wreq 1.2.7 → 1.2.9
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.lock +5 -5
- data/Cargo.toml +3 -3
- data/lib/wreq_ruby/error.rb +4 -0
- data/src/client/body/stream.rs +1 -1
- data/src/error.rs +13 -2
- data/src/rt.rs +1 -1
- data/test/error_handling_test.rb +54 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25b79ef76824f974c6f5f00e86bc1ad5ff1cbe76a5b87aad4f22e96e53d082d5
|
|
4
|
+
data.tar.gz: 4881b9242c6e672d67429406b2a029a8094904334d848ede43d3a97b44552334
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 737b77b0962becd596b4ebc05f0f8d3aebe547a9c6826aa1d6a76e1367f98d69abfa0874f345f635a570ef4478260660d7c83f802d18a5663b96b14e4a28abc8
|
|
7
|
+
data.tar.gz: 5bfdf49fe4df28390b08579298dac69422fd7c01cc9ab2055a739d8c165c3ec7362d21dde2ced8b751a81e80013c74a59a6bea832af654710353bd741bcce1a3
|
data/Cargo.lock
CHANGED
|
@@ -113,7 +113,7 @@ dependencies = [
|
|
|
113
113
|
[[package]]
|
|
114
114
|
name = "btls"
|
|
115
115
|
version = "0.5.6"
|
|
116
|
-
source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#
|
|
116
|
+
source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#67bc8c3547acabe5aa97f8e4529813926f2f7d4d"
|
|
117
117
|
dependencies = [
|
|
118
118
|
"bitflags",
|
|
119
119
|
"btls-sys",
|
|
@@ -125,7 +125,7 @@ dependencies = [
|
|
|
125
125
|
[[package]]
|
|
126
126
|
name = "btls-sys"
|
|
127
127
|
version = "0.5.6"
|
|
128
|
-
source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#
|
|
128
|
+
source = "git+https://github.com/0x676e67/btls?branch=demo%2Fmerge-upstream-boring-20260616#67bc8c3547acabe5aa97f8e4529813926f2f7d4d"
|
|
129
129
|
dependencies = [
|
|
130
130
|
"bindgen",
|
|
131
131
|
"cmake",
|
|
@@ -260,9 +260,9 @@ dependencies = [
|
|
|
260
260
|
|
|
261
261
|
[[package]]
|
|
262
262
|
name = "either"
|
|
263
|
-
version = "1.
|
|
263
|
+
version = "1.17.0"
|
|
264
264
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
265
|
-
checksum = "
|
|
265
|
+
checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"
|
|
266
266
|
|
|
267
267
|
[[package]]
|
|
268
268
|
name = "encoding_rs"
|
|
@@ -1549,7 +1549,7 @@ dependencies = [
|
|
|
1549
1549
|
|
|
1550
1550
|
[[package]]
|
|
1551
1551
|
name = "wreq-ruby"
|
|
1552
|
-
version = "1.2.
|
|
1552
|
+
version = "1.2.9"
|
|
1553
1553
|
dependencies = [
|
|
1554
1554
|
"arc-swap",
|
|
1555
1555
|
"bytes",
|
data/Cargo.toml
CHANGED
|
@@ -5,7 +5,7 @@ authors = ["SearchApi <support@searchapi.io>"]
|
|
|
5
5
|
homepage = "https://github.com/SearchApi/wreq-ruby"
|
|
6
6
|
repository = "https://github.com/SearchApi/wreq-ruby"
|
|
7
7
|
edition = "2024"
|
|
8
|
-
version = "1.2.
|
|
8
|
+
version = "1.2.9"
|
|
9
9
|
rust-version = "1.95"
|
|
10
10
|
|
|
11
11
|
[lib]
|
|
@@ -16,7 +16,7 @@ name = "wreq_ruby"
|
|
|
16
16
|
[dependencies]
|
|
17
17
|
magnus = { version = "0.8.2", features = ["bytes"] }
|
|
18
18
|
rb-sys = { version = "0.9.128", default-features = false }
|
|
19
|
-
tokio = { version = "1.
|
|
19
|
+
tokio = { version = "1.53.1", features = ["full"] }
|
|
20
20
|
wreq = { version = "6.0.0-rc", features = [
|
|
21
21
|
"query",
|
|
22
22
|
"form",
|
|
@@ -64,4 +64,4 @@ strip = true
|
|
|
64
64
|
[patch.crates-io]
|
|
65
65
|
btls = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" }
|
|
66
66
|
btls-sys = { git = "https://github.com/0x676e67/btls", branch = "demo/merge-upstream-boring-20260616" }
|
|
67
|
-
wreq-util = { path = "crates/wreq-util" }
|
|
67
|
+
wreq-util = { path = "crates/wreq-util" }
|
data/lib/wreq_ruby/error.rb
CHANGED
data/src/client/body/stream.rs
CHANGED
|
@@ -113,7 +113,7 @@ impl BodySender {
|
|
|
113
113
|
/// # Errors
|
|
114
114
|
///
|
|
115
115
|
/// Returns `IOError` after either channel side has closed. An interrupted
|
|
116
|
-
/// wait raises
|
|
116
|
+
/// wait raises `Wreq::InterruptError`.
|
|
117
117
|
pub fn push(ruby: &Ruby, rb_self: &Self, data: RString) -> Result<(), Error> {
|
|
118
118
|
// Clone during the shared borrow, then release it before waiting
|
|
119
119
|
// for capacity. Request attachment needs a mutable borrow.
|
data/src/error.rs
CHANGED
|
@@ -84,14 +84,18 @@ define_exception!(DECODING_ERROR, "DecodingError", exception_runtime_error);
|
|
|
84
84
|
// Configuration and builder errors
|
|
85
85
|
define_exception!(BUILDER_ERROR, "BuilderError", exception_runtime_error);
|
|
86
86
|
|
|
87
|
+
// Keep interruption outside StandardError so a broad transport rescue
|
|
88
|
+
// never swallows a Ruby interrupt.
|
|
89
|
+
define_exception!(INTERRUPT_ERROR, "InterruptError", exception_interrupt);
|
|
90
|
+
|
|
87
91
|
/// Memory error constant
|
|
88
92
|
pub fn memory_error(ruby: &Ruby) -> MagnusError {
|
|
89
93
|
MagnusError::new(ruby.get_inner(&MEMORY), RACE_CONDITION_ERROR_MSG)
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
/// Create Ruby
|
|
96
|
+
/// Create a `Wreq::InterruptError` when Ruby interrupts a request.
|
|
93
97
|
pub fn interrupt_error(ruby: &Ruby) -> MagnusError {
|
|
94
|
-
MagnusError::new(ruby.
|
|
98
|
+
MagnusError::new(ruby.get_inner(&INTERRUPT_ERROR), "request interrupted")
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
/// Map a Tokio runtime initialization failure to `Wreq::BuilderError`.
|
|
@@ -312,5 +316,12 @@ pub fn include(ruby: &Ruby, gem_module: &RModule) -> Result<(), MagnusError> {
|
|
|
312
316
|
"BuilderError",
|
|
313
317
|
exception_runtime_error
|
|
314
318
|
);
|
|
319
|
+
initialize_exception!(
|
|
320
|
+
ruby,
|
|
321
|
+
gem_module,
|
|
322
|
+
INTERRUPT_ERROR,
|
|
323
|
+
"InterruptError",
|
|
324
|
+
exception_interrupt
|
|
325
|
+
);
|
|
315
326
|
Ok(())
|
|
316
327
|
}
|
data/src/rt.rs
CHANGED
|
@@ -29,7 +29,7 @@ enum BlockOnError<E> {
|
|
|
29
29
|
/// # Errors
|
|
30
30
|
///
|
|
31
31
|
/// Returns `Wreq::BuilderError` if the Tokio runtime cannot be initialized,
|
|
32
|
-
///
|
|
32
|
+
/// `Wreq::InterruptError` if Ruby interrupts the request, or the error produced
|
|
33
33
|
/// by `map_err` if the future fails.
|
|
34
34
|
pub fn try_block_on<F, T, E, M>(ruby: &Ruby, future: F, map_err: M) -> Result<T, magnus::Error>
|
|
35
35
|
where
|
data/test/error_handling_test.rb
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
require "test_helper"
|
|
2
|
+
require "socket"
|
|
3
|
+
require "timeout"
|
|
2
4
|
|
|
3
5
|
class ErrorHandlingTest < Minitest::Test
|
|
6
|
+
def test_interrupt_error_stays_outside_standard_error
|
|
7
|
+
assert_equal Interrupt, Wreq::InterruptError.superclass
|
|
8
|
+
refute_operator Wreq::InterruptError, :<, StandardError
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_request_interruption_raises_interrupt_error
|
|
12
|
+
request_thread = nil
|
|
13
|
+
with_hanging_server do |url, accepted|
|
|
14
|
+
request_thread = Thread.new do
|
|
15
|
+
Wreq.get(url, timeout: 60)
|
|
16
|
+
rescue Interrupt, StandardError => error
|
|
17
|
+
error
|
|
18
|
+
end
|
|
19
|
+
request_thread.report_on_exception = false
|
|
20
|
+
|
|
21
|
+
Timeout.timeout(5) { accepted.pop }
|
|
22
|
+
request_thread.wakeup
|
|
23
|
+
|
|
24
|
+
assert request_thread.join(5), "Interrupted request thread should stop"
|
|
25
|
+
|
|
26
|
+
error = request_thread.value
|
|
27
|
+
assert_instance_of Wreq::InterruptError, error
|
|
28
|
+
refute_kind_of StandardError, error
|
|
29
|
+
end
|
|
30
|
+
ensure
|
|
31
|
+
request_thread&.kill
|
|
32
|
+
request_thread&.join(1)
|
|
33
|
+
end
|
|
34
|
+
|
|
4
35
|
def test_network_error_handling
|
|
5
36
|
# Try to connect to a non-existent domain
|
|
6
37
|
response = Wreq.get("https://definitely-not-a-real-domain-12345.com")
|
|
@@ -89,4 +120,27 @@ class ErrorHandlingTest < Minitest::Test
|
|
|
89
120
|
end
|
|
90
121
|
end
|
|
91
122
|
end
|
|
123
|
+
|
|
124
|
+
private
|
|
125
|
+
|
|
126
|
+
def with_hanging_server
|
|
127
|
+
server = TCPServer.new("127.0.0.1", 0)
|
|
128
|
+
accepted = Queue.new
|
|
129
|
+
thread = Thread.new do
|
|
130
|
+
socket = server.accept
|
|
131
|
+
accepted << true
|
|
132
|
+
sleep
|
|
133
|
+
rescue IOError, SystemCallError
|
|
134
|
+
nil
|
|
135
|
+
ensure
|
|
136
|
+
socket&.close unless socket&.closed?
|
|
137
|
+
end
|
|
138
|
+
thread.report_on_exception = false
|
|
139
|
+
|
|
140
|
+
yield "http://127.0.0.1:#{server.addr[1]}/", accepted
|
|
141
|
+
ensure
|
|
142
|
+
server&.close unless server&.closed?
|
|
143
|
+
thread&.kill
|
|
144
|
+
thread&.join(1)
|
|
145
|
+
end
|
|
92
146
|
end
|