wreq-rb 0.5.0 → 0.5.1
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 +1922 -397
- data/LICENSE +203 -0
- data/README.md +19 -15
- data/ext/wreq_rb/Cargo.toml +4 -6
- data/ext/wreq_rb/src/client.rs +41 -48
- data/lib/wreq-rb/version.rb +1 -1
- data/patches/0001-add-transfer-size-tracking.patch +76 -67
- data/vendor/wreq/Cargo.toml +119 -71
- data/vendor/wreq/README.md +25 -20
- data/vendor/wreq/bench/http1.rs +25 -0
- data/vendor/wreq/bench/http1_over_tls.rs +25 -0
- data/vendor/wreq/bench/http2.rs +25 -0
- data/vendor/wreq/bench/http2_over_tls.rs +25 -0
- data/vendor/wreq/bench/support/bench.rs +91 -0
- data/vendor/wreq/bench/support/client.rs +217 -0
- data/vendor/wreq/bench/support/server.rs +188 -0
- data/vendor/wreq/bench/support.rs +56 -0
- data/vendor/wreq/examples/cert_store.rs +4 -4
- data/vendor/wreq/examples/{emulation.rs → emulate.rs} +2 -2
- data/vendor/wreq/examples/http2_websocket.rs +2 -2
- data/vendor/wreq/examples/keylog.rs +3 -3
- data/vendor/wreq/examples/{request_with_emulation.rs → request_with_emulate.rs} +2 -2
- data/vendor/wreq/examples/rt.rs +23 -0
- data/vendor/wreq/src/client/body.rs +23 -61
- data/vendor/wreq/src/client/emulate.rs +119 -0
- data/vendor/wreq/src/client/{http/future.rs → future.rs} +11 -32
- data/vendor/wreq/src/client/{http → layer}/client/pool.rs +66 -61
- data/vendor/wreq/src/client/{http → layer}/client.rs +416 -270
- data/vendor/wreq/src/client/layer/config.rs +27 -6
- data/vendor/wreq/src/client/layer/decoder.rs +9 -4
- data/vendor/wreq/src/client/layer/redirect/future.rs +6 -3
- data/vendor/wreq/src/client/layer/redirect.rs +4 -5
- data/vendor/wreq/src/client/layer/retry.rs +8 -5
- data/vendor/wreq/src/client/layer/timeout/body.rs +15 -6
- data/vendor/wreq/src/client/layer/timeout/future.rs +23 -18
- data/vendor/wreq/src/client/layer/timeout.rs +24 -74
- data/vendor/wreq/src/client/layer.rs +1 -2
- data/vendor/wreq/src/client/multipart.rs +137 -154
- data/vendor/wreq/src/client/request.rs +202 -118
- data/vendor/wreq/src/client/response.rs +46 -45
- data/vendor/wreq/src/client/upgrade.rs +15 -0
- data/vendor/wreq/src/client/ws.rs +73 -25
- data/vendor/wreq/src/client.rs +1655 -17
- data/vendor/wreq/src/config.rs +11 -11
- data/vendor/wreq/src/{client/conn → conn}/connector.rs +139 -137
- data/vendor/wreq/src/conn/descriptor.rs +143 -0
- data/vendor/wreq/src/conn/http.rs +484 -0
- data/vendor/wreq/src/conn/net/io.rs +75 -0
- data/vendor/wreq/src/conn/net/tcp/compio.rs +71 -0
- data/vendor/wreq/src/conn/net/tcp/tokio.rs +57 -0
- data/vendor/wreq/src/conn/net/tcp.rs +561 -0
- data/vendor/wreq/src/conn/net/uds/compio.rs +60 -0
- data/vendor/wreq/src/{client/conn/uds.rs → conn/net/uds/tokio.rs} +18 -12
- data/vendor/wreq/src/conn/net/uds.rs +11 -0
- data/vendor/wreq/src/conn/net.rs +130 -0
- data/vendor/wreq/src/{client/conn → conn}/proxy/socks.rs +2 -9
- data/vendor/wreq/src/{client/conn → conn}/proxy/tunnel.rs +21 -56
- data/vendor/wreq/src/conn/tls_info.rs +47 -0
- data/vendor/wreq/src/{client/conn.rs → conn.rs} +202 -54
- data/vendor/wreq/src/cookie.rs +302 -142
- data/vendor/wreq/src/dns/gai/compio.rs +77 -0
- data/vendor/wreq/src/dns/gai/tokio.rs +90 -0
- data/vendor/wreq/src/dns/gai.rs +14 -164
- data/vendor/wreq/src/dns/hickory.rs +16 -23
- data/vendor/wreq/src/dns/resolve.rs +7 -41
- data/vendor/wreq/src/dns.rs +90 -7
- data/vendor/wreq/src/error.rs +57 -31
- data/vendor/wreq/src/ext.rs +25 -0
- data/vendor/wreq/src/group.rs +211 -0
- data/vendor/wreq/src/header.rs +100 -112
- data/vendor/wreq/src/lib.rs +124 -73
- data/vendor/wreq/src/proxy.rs +6 -20
- data/vendor/wreq/src/redirect.rs +1 -1
- data/vendor/wreq/src/rt.rs +208 -0
- data/vendor/wreq/src/sync.rs +97 -98
- data/vendor/wreq/src/tls/compress.rs +124 -0
- data/vendor/wreq/src/tls/conn/ext.rs +54 -45
- data/vendor/wreq/src/tls/conn/service.rs +14 -18
- data/vendor/wreq/src/tls/conn.rs +169 -241
- data/vendor/wreq/src/tls/keylog.rs +68 -5
- data/vendor/wreq/src/tls/session.rs +205 -0
- data/vendor/wreq/src/tls/{x509 → trust}/identity.rs +4 -21
- data/vendor/wreq/src/tls/{x509/parser.rs → trust/parse.rs} +1 -1
- data/vendor/wreq/src/tls/{x509 → trust}/store.rs +42 -81
- data/vendor/wreq/src/tls/{x509.rs → trust.rs} +8 -2
- data/vendor/wreq/src/tls.rs +489 -25
- data/vendor/wreq/src/trace.rs +0 -12
- data/vendor/wreq/src/util.rs +1 -1
- data/vendor/wreq/tests/badssl.rs +10 -10
- data/vendor/wreq/tests/client.rs +3 -9
- data/vendor/wreq/tests/cookie.rs +6 -8
- data/vendor/wreq/tests/{emulation.rs → emulate.rs} +130 -22
- data/vendor/wreq/tests/multipart.rs +43 -1
- data/vendor/wreq/tests/proxy.rs +1 -1
- data/vendor/wreq/tests/support/layer.rs +1 -0
- metadata +49 -71
- data/patches/0002-add-cancel-connections.patch +0 -181
- data/vendor/wreq/src/client/conn/conn.rs +0 -231
- data/vendor/wreq/src/client/conn/http.rs +0 -1023
- data/vendor/wreq/src/client/conn/tls_info.rs +0 -98
- data/vendor/wreq/src/client/core/body/incoming.rs +0 -485
- data/vendor/wreq/src/client/core/body/length.rs +0 -118
- data/vendor/wreq/src/client/core/body.rs +0 -34
- data/vendor/wreq/src/client/core/common/buf.rs +0 -149
- data/vendor/wreq/src/client/core/common/rewind.rs +0 -141
- data/vendor/wreq/src/client/core/common/watch.rs +0 -76
- data/vendor/wreq/src/client/core/common.rs +0 -3
- data/vendor/wreq/src/client/core/conn/http1.rs +0 -342
- data/vendor/wreq/src/client/core/conn/http2.rs +0 -307
- data/vendor/wreq/src/client/core/conn.rs +0 -11
- data/vendor/wreq/src/client/core/dispatch.rs +0 -299
- data/vendor/wreq/src/client/core/error.rs +0 -435
- data/vendor/wreq/src/client/core/ext.rs +0 -201
- data/vendor/wreq/src/client/core/http1.rs +0 -178
- data/vendor/wreq/src/client/core/http2.rs +0 -483
- data/vendor/wreq/src/client/core/proto/h1/conn.rs +0 -988
- data/vendor/wreq/src/client/core/proto/h1/decode.rs +0 -1170
- data/vendor/wreq/src/client/core/proto/h1/dispatch.rs +0 -684
- data/vendor/wreq/src/client/core/proto/h1/encode.rs +0 -580
- data/vendor/wreq/src/client/core/proto/h1/io.rs +0 -879
- data/vendor/wreq/src/client/core/proto/h1/role.rs +0 -694
- data/vendor/wreq/src/client/core/proto/h1.rs +0 -104
- data/vendor/wreq/src/client/core/proto/h2/client.rs +0 -650
- data/vendor/wreq/src/client/core/proto/h2/ping.rs +0 -539
- data/vendor/wreq/src/client/core/proto/h2.rs +0 -379
- data/vendor/wreq/src/client/core/proto/headers.rs +0 -138
- data/vendor/wreq/src/client/core/proto.rs +0 -58
- data/vendor/wreq/src/client/core/rt/bounds.rs +0 -57
- data/vendor/wreq/src/client/core/rt/timer.rs +0 -150
- data/vendor/wreq/src/client/core/rt/tokio.rs +0 -99
- data/vendor/wreq/src/client/core/rt.rs +0 -25
- data/vendor/wreq/src/client/core/upgrade.rs +0 -267
- data/vendor/wreq/src/client/core.rs +0 -16
- data/vendor/wreq/src/client/emulation.rs +0 -161
- data/vendor/wreq/src/client/http/client/error.rs +0 -142
- data/vendor/wreq/src/client/http/client/exec.rs +0 -29
- data/vendor/wreq/src/client/http/client/extra.rs +0 -77
- data/vendor/wreq/src/client/http/client/util.rs +0 -104
- data/vendor/wreq/src/client/http.rs +0 -1629
- data/vendor/wreq/src/client/layer/config/options.rs +0 -156
- data/vendor/wreq/src/client/layer/cookie.rs +0 -161
- data/vendor/wreq/src/hash.rs +0 -143
- data/vendor/wreq/src/tls/conn/cache.rs +0 -123
- data/vendor/wreq/src/tls/conn/cert_compression.rs +0 -125
- data/vendor/wreq/src/tls/keylog/handle.rs +0 -64
- data/vendor/wreq/src/tls/options.rs +0 -464
- /data/vendor/wreq/src/client/{http → layer}/client/lazy.rs +0 -0
- /data/vendor/wreq/src/{client/conn → conn}/proxy.rs +0 -0
- /data/vendor/wreq/src/{client/conn → conn}/verbose.rs +0 -0
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
#[allow(clippy::module_inception)]
|
|
2
|
-
mod conn;
|
|
3
|
-
mod connector;
|
|
4
|
-
mod http;
|
|
5
|
-
mod proxy;
|
|
6
1
|
mod tls_info;
|
|
7
|
-
#[cfg(unix)]
|
|
8
|
-
mod uds;
|
|
9
2
|
mod verbose;
|
|
10
3
|
|
|
4
|
+
pub(super) mod connector;
|
|
5
|
+
pub(super) mod descriptor;
|
|
6
|
+
pub(super) mod http;
|
|
7
|
+
pub(super) mod net;
|
|
8
|
+
pub(super) mod proxy;
|
|
9
|
+
|
|
11
10
|
use std::{
|
|
12
11
|
fmt::{self, Debug, Formatter},
|
|
12
|
+
io,
|
|
13
|
+
io::IoSlice,
|
|
14
|
+
pin::Pin,
|
|
13
15
|
sync::{
|
|
14
16
|
Arc,
|
|
15
17
|
atomic::{AtomicBool, Ordering},
|
|
16
18
|
},
|
|
19
|
+
task::{Context, Poll},
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
use ::http::{Extensions, HeaderMap, HeaderValue};
|
|
20
|
-
|
|
23
|
+
#[cfg(any(feature = "tokio-rt", feature = "compio-rt"))]
|
|
24
|
+
use net::TcpConnector;
|
|
25
|
+
use pin_project_lite::pin_project;
|
|
26
|
+
use tls_info::TlsInfoFactory;
|
|
27
|
+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
|
28
|
+
use tokio_btls::SslStream;
|
|
21
29
|
use tower::{
|
|
22
30
|
BoxError,
|
|
23
31
|
util::{BoxCloneSyncService, BoxCloneSyncServiceLayer},
|
|
24
32
|
};
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
connector::Connector,
|
|
31
|
-
http::{HttpInfo, TcpConnectOptions},
|
|
32
|
-
proxy::tunnel,
|
|
33
|
-
tls_info::TlsInfoFactory,
|
|
34
|
+
use crate::{
|
|
35
|
+
dns::DynResolver,
|
|
36
|
+
proxy::matcher::Intercept,
|
|
37
|
+
tls::{AlpnProtocol, TlsInfo},
|
|
34
38
|
};
|
|
35
|
-
use crate::{client::ConnectRequest, dns::DynResolver, proxy::matcher::Intercept};
|
|
36
39
|
|
|
37
40
|
/// HTTP connector with dynamic DNS resolver.
|
|
38
|
-
pub type HttpConnector =
|
|
41
|
+
pub type HttpConnector = http::HttpConnector<DynResolver, TcpConnector>;
|
|
39
42
|
|
|
40
43
|
/// Boxed connector service for establishing connections.
|
|
41
44
|
pub type BoxedConnectorService = BoxCloneSyncService<Unnameable, Conn, BoxError>;
|
|
@@ -44,12 +47,12 @@ pub type BoxedConnectorService = BoxCloneSyncService<Unnameable, Conn, BoxError>
|
|
|
44
47
|
pub type BoxedConnectorLayer =
|
|
45
48
|
BoxCloneSyncServiceLayer<BoxedConnectorService, Unnameable, Conn, BoxError>;
|
|
46
49
|
|
|
47
|
-
/// A wrapper type for [`
|
|
50
|
+
/// A wrapper type for [`descriptor::ConnectionDescriptor`] used to erase its concrete type.
|
|
48
51
|
///
|
|
49
52
|
/// [`Unnameable`] allows passing connection requests through trait objects or
|
|
50
53
|
/// type-erased interfaces where the concrete type of the request is not important.
|
|
51
54
|
/// This is mainly used internally to simplify service composition and dynamic dispatch.
|
|
52
|
-
pub struct Unnameable(pub(super)
|
|
55
|
+
pub struct Unnameable(pub(super) descriptor::ConnectionDescriptor);
|
|
53
56
|
|
|
54
57
|
/// A trait alias for types that can be used as async connections.
|
|
55
58
|
///
|
|
@@ -69,6 +72,31 @@ impl<T> AsyncConn for T where T: AsyncRead + AsyncWrite + Connection + Send + Sy
|
|
|
69
72
|
|
|
70
73
|
impl<T> AsyncConnWithInfo for T where T: AsyncConn + TlsInfoFactory {}
|
|
71
74
|
|
|
75
|
+
pin_project! {
|
|
76
|
+
/// Note: the `is_proxy` member means *is plain text HTTP proxy*.
|
|
77
|
+
/// This tells core whether the URI should be written in
|
|
78
|
+
/// * origin-form (`GET /just/a/path HTTP/1.1`), when `proxy == None`, or
|
|
79
|
+
/// * absolute-form (`GET http://foo.bar/and/a/path HTTP/1.1`), otherwise.
|
|
80
|
+
pub struct Conn {
|
|
81
|
+
tls_info: bool,
|
|
82
|
+
proxy: Option<Intercept>,
|
|
83
|
+
#[pin]
|
|
84
|
+
stream: Box<dyn AsyncConnWithInfo>,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pin_project! {
|
|
89
|
+
/// A wrapper around `SslStream` that adapts it for use as a generic async connection.
|
|
90
|
+
///
|
|
91
|
+
/// This type enables unified handling of plain TCP and TLS-encrypted streams by providing
|
|
92
|
+
/// implementations of `Connection`, `Read`, `Write`, and `TlsInfoFactory`.
|
|
93
|
+
/// It is mainly used internally to abstract over different connection types.
|
|
94
|
+
pub struct TlsConn<T> {
|
|
95
|
+
#[pin]
|
|
96
|
+
stream: SslStream<T>,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
72
100
|
/// Describes a type returned by a connector.
|
|
73
101
|
pub trait Connection {
|
|
74
102
|
/// Return metadata describing the connection.
|
|
@@ -84,9 +112,7 @@ enum Alpn {
|
|
|
84
112
|
|
|
85
113
|
/// A pill that can be poisoned to indicate that a connection should not be reused.
|
|
86
114
|
#[derive(Clone)]
|
|
87
|
-
struct PoisonPill
|
|
88
|
-
poisoned: Arc<AtomicBool>,
|
|
89
|
-
}
|
|
115
|
+
struct PoisonPill(Arc<AtomicBool>);
|
|
90
116
|
|
|
91
117
|
/// A boxed asynchronous connection with associated information.
|
|
92
118
|
#[derive(Debug)]
|
|
@@ -121,7 +147,7 @@ struct ProxyIdentity {
|
|
|
121
147
|
///
|
|
122
148
|
/// This can be used to inform recipients about things like if ALPN
|
|
123
149
|
/// was used, or if connected to an HTTP proxy.
|
|
124
|
-
#[derive(Debug)]
|
|
150
|
+
#[derive(Debug, Clone)]
|
|
125
151
|
pub struct Connected {
|
|
126
152
|
alpn: Alpn,
|
|
127
153
|
proxy: Box<ProxyIdentity>,
|
|
@@ -129,6 +155,151 @@ pub struct Connected {
|
|
|
129
155
|
poisoned: PoisonPill,
|
|
130
156
|
}
|
|
131
157
|
|
|
158
|
+
// ==== impl Conn ====
|
|
159
|
+
|
|
160
|
+
impl Connection for Conn {
|
|
161
|
+
fn connected(&self) -> Connected {
|
|
162
|
+
let mut connected = self.stream.connected();
|
|
163
|
+
|
|
164
|
+
if let Some(proxy) = &self.proxy {
|
|
165
|
+
connected = connected.proxy(proxy.clone());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if self.tls_info {
|
|
169
|
+
if let Some(tls_info) = self.stream.tls_info() {
|
|
170
|
+
connected.extra(tls_info)
|
|
171
|
+
} else {
|
|
172
|
+
connected
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
connected
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
impl AsyncRead for Conn {
|
|
181
|
+
#[inline]
|
|
182
|
+
fn poll_read(
|
|
183
|
+
self: Pin<&mut Self>,
|
|
184
|
+
cx: &mut Context,
|
|
185
|
+
buf: &mut ReadBuf<'_>,
|
|
186
|
+
) -> Poll<io::Result<()>> {
|
|
187
|
+
AsyncRead::poll_read(self.project().stream, cx, buf)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
impl AsyncWrite for Conn {
|
|
192
|
+
#[inline]
|
|
193
|
+
fn poll_write(
|
|
194
|
+
self: Pin<&mut Self>,
|
|
195
|
+
cx: &mut Context,
|
|
196
|
+
buf: &[u8],
|
|
197
|
+
) -> Poll<Result<usize, io::Error>> {
|
|
198
|
+
AsyncWrite::poll_write(self.project().stream, cx, buf)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#[inline]
|
|
202
|
+
fn poll_write_vectored(
|
|
203
|
+
self: Pin<&mut Self>,
|
|
204
|
+
cx: &mut Context<'_>,
|
|
205
|
+
bufs: &[IoSlice<'_>],
|
|
206
|
+
) -> Poll<Result<usize, io::Error>> {
|
|
207
|
+
AsyncWrite::poll_write_vectored(self.project().stream, cx, bufs)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#[inline]
|
|
211
|
+
fn is_write_vectored(&self) -> bool {
|
|
212
|
+
self.stream.is_write_vectored()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
#[inline]
|
|
216
|
+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
|
217
|
+
AsyncWrite::poll_flush(self.project().stream, cx)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
#[inline]
|
|
221
|
+
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
|
222
|
+
AsyncWrite::poll_shutdown(self.project().stream, cx)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ===== impl TlsConn =====
|
|
227
|
+
|
|
228
|
+
impl<T> Connection for TlsConn<T>
|
|
229
|
+
where
|
|
230
|
+
T: Connection,
|
|
231
|
+
{
|
|
232
|
+
fn connected(&self) -> Connected {
|
|
233
|
+
let connected = self.stream.get_ref().connected();
|
|
234
|
+
if self
|
|
235
|
+
.stream
|
|
236
|
+
.ssl()
|
|
237
|
+
.selected_alpn_protocol()
|
|
238
|
+
.is_some_and(|alpn| AlpnProtocol::HTTP2.eq(alpn))
|
|
239
|
+
{
|
|
240
|
+
connected.negotiated_h2()
|
|
241
|
+
} else {
|
|
242
|
+
connected
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
impl<T: AsyncRead + AsyncWrite + Unpin> AsyncRead for TlsConn<T> {
|
|
248
|
+
#[inline]
|
|
249
|
+
fn poll_read(
|
|
250
|
+
self: Pin<&mut Self>,
|
|
251
|
+
cx: &mut Context,
|
|
252
|
+
buf: &mut ReadBuf<'_>,
|
|
253
|
+
) -> Poll<tokio::io::Result<()>> {
|
|
254
|
+
AsyncRead::poll_read(self.project().stream, cx, buf)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
impl<T: AsyncRead + AsyncWrite + Unpin> AsyncWrite for TlsConn<T> {
|
|
259
|
+
#[inline]
|
|
260
|
+
fn poll_write(
|
|
261
|
+
self: Pin<&mut Self>,
|
|
262
|
+
cx: &mut Context,
|
|
263
|
+
buf: &[u8],
|
|
264
|
+
) -> Poll<Result<usize, tokio::io::Error>> {
|
|
265
|
+
AsyncWrite::poll_write(self.project().stream, cx, buf)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
#[inline]
|
|
269
|
+
fn poll_write_vectored(
|
|
270
|
+
self: Pin<&mut Self>,
|
|
271
|
+
cx: &mut Context<'_>,
|
|
272
|
+
bufs: &[IoSlice<'_>],
|
|
273
|
+
) -> Poll<Result<usize, io::Error>> {
|
|
274
|
+
AsyncWrite::poll_write_vectored(self.project().stream, cx, bufs)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
#[inline]
|
|
278
|
+
fn is_write_vectored(&self) -> bool {
|
|
279
|
+
self.stream.is_write_vectored()
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
#[inline]
|
|
283
|
+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), tokio::io::Error>> {
|
|
284
|
+
AsyncWrite::poll_flush(self.project().stream, cx)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#[inline]
|
|
288
|
+
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), tokio::io::Error>> {
|
|
289
|
+
AsyncWrite::poll_shutdown(self.project().stream, cx)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
impl<T> TlsInfoFactory for TlsConn<T>
|
|
294
|
+
where
|
|
295
|
+
SslStream<T>: TlsInfoFactory,
|
|
296
|
+
{
|
|
297
|
+
#[inline]
|
|
298
|
+
fn tls_info(&self) -> Option<TlsInfo> {
|
|
299
|
+
self.stream.tls_info()
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
132
303
|
// ===== impl PoisonPill =====
|
|
133
304
|
|
|
134
305
|
impl fmt::Debug for PoisonPill {
|
|
@@ -137,8 +308,8 @@ impl fmt::Debug for PoisonPill {
|
|
|
137
308
|
write!(
|
|
138
309
|
f,
|
|
139
310
|
"PoisonPill@{:p} {{ poisoned: {} }}",
|
|
140
|
-
self.
|
|
141
|
-
self.
|
|
311
|
+
self.0,
|
|
312
|
+
self.0.load(Ordering::Relaxed)
|
|
142
313
|
)
|
|
143
314
|
}
|
|
144
315
|
}
|
|
@@ -147,21 +318,7 @@ impl PoisonPill {
|
|
|
147
318
|
/// Create a healthy (not poisoned) pill.
|
|
148
319
|
#[inline]
|
|
149
320
|
fn healthy() -> Self {
|
|
150
|
-
Self
|
|
151
|
-
poisoned: Arc::new(AtomicBool::new(false)),
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/// Poison this pill.
|
|
156
|
-
#[inline]
|
|
157
|
-
fn poison(&self) {
|
|
158
|
-
self.poisoned.store(true, Ordering::Relaxed)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/// Check if this pill is poisoned.
|
|
162
|
-
#[inline]
|
|
163
|
-
fn poisoned(&self) -> bool {
|
|
164
|
-
self.poisoned.load(Ordering::Relaxed)
|
|
321
|
+
Self(Arc::new(AtomicBool::new(false)))
|
|
165
322
|
}
|
|
166
323
|
}
|
|
167
324
|
|
|
@@ -189,6 +346,7 @@ impl Connected {
|
|
|
189
346
|
}
|
|
190
347
|
|
|
191
348
|
/// Copies the extra connection information into an `Extensions` map.
|
|
349
|
+
#[inline]
|
|
192
350
|
pub fn set_extras(&self, extensions: &mut Extensions) {
|
|
193
351
|
if let Some(extra) = &self.extra {
|
|
194
352
|
extra.set(extensions);
|
|
@@ -244,30 +402,20 @@ impl Connected {
|
|
|
244
402
|
/// Determine if this connection is poisoned
|
|
245
403
|
#[inline]
|
|
246
404
|
pub fn poisoned(&self) -> bool {
|
|
247
|
-
self.poisoned.
|
|
405
|
+
self.poisoned.0.load(Ordering::Relaxed)
|
|
248
406
|
}
|
|
249
407
|
|
|
250
408
|
/// Poison this connection
|
|
251
409
|
///
|
|
252
410
|
/// A poisoned connection will not be reused for subsequent requests by the pool
|
|
411
|
+
#[allow(unused)]
|
|
253
412
|
#[inline]
|
|
254
413
|
pub fn poison(&self) {
|
|
255
|
-
self.poisoned.
|
|
414
|
+
self.poisoned.0.store(true, Ordering::Relaxed);
|
|
256
415
|
debug!(
|
|
257
416
|
"connection was poisoned. this connection will not be reused for subsequent requests"
|
|
258
417
|
);
|
|
259
418
|
}
|
|
260
|
-
|
|
261
|
-
// Don't public expose that `Connected` is `Clone`, unsure if we want to
|
|
262
|
-
// keep that contract...
|
|
263
|
-
pub(crate) fn clone(&self) -> Connected {
|
|
264
|
-
Connected {
|
|
265
|
-
alpn: self.alpn,
|
|
266
|
-
proxy: self.proxy.clone(),
|
|
267
|
-
extra: self.extra.clone(),
|
|
268
|
-
poisoned: self.poisoned.clone(),
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
419
|
}
|
|
272
420
|
|
|
273
421
|
// ===== impl Extra =====
|