wreq-rb 0.3.0
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 +2688 -0
- data/Cargo.toml +6 -0
- data/README.md +179 -0
- data/ext/wreq_rb/Cargo.toml +39 -0
- data/ext/wreq_rb/extconf.rb +22 -0
- data/ext/wreq_rb/src/client.rs +565 -0
- data/ext/wreq_rb/src/error.rs +25 -0
- data/ext/wreq_rb/src/lib.rs +20 -0
- data/ext/wreq_rb/src/response.rs +132 -0
- data/lib/wreq-rb/version.rb +5 -0
- data/lib/wreq-rb.rb +17 -0
- data/patches/0001-add-transfer-size-tracking.patch +292 -0
- data/vendor/wreq/Cargo.toml +306 -0
- data/vendor/wreq/LICENSE +202 -0
- data/vendor/wreq/README.md +122 -0
- data/vendor/wreq/examples/cert_store.rs +77 -0
- data/vendor/wreq/examples/connect_via_lower_priority_tokio_runtime.rs +258 -0
- data/vendor/wreq/examples/emulation.rs +118 -0
- data/vendor/wreq/examples/form.rs +14 -0
- data/vendor/wreq/examples/http1_websocket.rs +37 -0
- data/vendor/wreq/examples/http2_websocket.rs +45 -0
- data/vendor/wreq/examples/json_dynamic.rs +41 -0
- data/vendor/wreq/examples/json_typed.rs +47 -0
- data/vendor/wreq/examples/keylog.rs +16 -0
- data/vendor/wreq/examples/request_with_emulation.rs +115 -0
- data/vendor/wreq/examples/request_with_interface.rs +37 -0
- data/vendor/wreq/examples/request_with_local_address.rs +16 -0
- data/vendor/wreq/examples/request_with_proxy.rs +13 -0
- data/vendor/wreq/examples/request_with_redirect.rs +22 -0
- data/vendor/wreq/examples/request_with_version.rs +15 -0
- data/vendor/wreq/examples/tor_socks.rs +24 -0
- data/vendor/wreq/examples/unix_socket.rs +33 -0
- data/vendor/wreq/src/client/body.rs +304 -0
- data/vendor/wreq/src/client/conn/conn.rs +231 -0
- data/vendor/wreq/src/client/conn/connector.rs +549 -0
- data/vendor/wreq/src/client/conn/http.rs +1023 -0
- data/vendor/wreq/src/client/conn/proxy/socks.rs +233 -0
- data/vendor/wreq/src/client/conn/proxy/tunnel.rs +260 -0
- data/vendor/wreq/src/client/conn/proxy.rs +39 -0
- data/vendor/wreq/src/client/conn/tls_info.rs +98 -0
- data/vendor/wreq/src/client/conn/uds.rs +44 -0
- data/vendor/wreq/src/client/conn/verbose.rs +149 -0
- data/vendor/wreq/src/client/conn.rs +323 -0
- data/vendor/wreq/src/client/core/body/incoming.rs +485 -0
- data/vendor/wreq/src/client/core/body/length.rs +118 -0
- data/vendor/wreq/src/client/core/body.rs +34 -0
- data/vendor/wreq/src/client/core/common/buf.rs +149 -0
- data/vendor/wreq/src/client/core/common/rewind.rs +141 -0
- data/vendor/wreq/src/client/core/common/watch.rs +76 -0
- data/vendor/wreq/src/client/core/common.rs +3 -0
- data/vendor/wreq/src/client/core/conn/http1.rs +342 -0
- data/vendor/wreq/src/client/core/conn/http2.rs +307 -0
- data/vendor/wreq/src/client/core/conn.rs +11 -0
- data/vendor/wreq/src/client/core/dispatch.rs +299 -0
- data/vendor/wreq/src/client/core/error.rs +435 -0
- data/vendor/wreq/src/client/core/ext.rs +201 -0
- data/vendor/wreq/src/client/core/http1.rs +178 -0
- data/vendor/wreq/src/client/core/http2.rs +483 -0
- data/vendor/wreq/src/client/core/proto/h1/conn.rs +988 -0
- data/vendor/wreq/src/client/core/proto/h1/decode.rs +1170 -0
- data/vendor/wreq/src/client/core/proto/h1/dispatch.rs +684 -0
- data/vendor/wreq/src/client/core/proto/h1/encode.rs +580 -0
- data/vendor/wreq/src/client/core/proto/h1/io.rs +879 -0
- data/vendor/wreq/src/client/core/proto/h1/role.rs +694 -0
- data/vendor/wreq/src/client/core/proto/h1.rs +104 -0
- data/vendor/wreq/src/client/core/proto/h2/client.rs +650 -0
- data/vendor/wreq/src/client/core/proto/h2/ping.rs +539 -0
- data/vendor/wreq/src/client/core/proto/h2.rs +379 -0
- data/vendor/wreq/src/client/core/proto/headers.rs +138 -0
- data/vendor/wreq/src/client/core/proto.rs +58 -0
- data/vendor/wreq/src/client/core/rt/bounds.rs +57 -0
- data/vendor/wreq/src/client/core/rt/timer.rs +150 -0
- data/vendor/wreq/src/client/core/rt/tokio.rs +99 -0
- data/vendor/wreq/src/client/core/rt.rs +25 -0
- data/vendor/wreq/src/client/core/upgrade.rs +267 -0
- data/vendor/wreq/src/client/core.rs +16 -0
- data/vendor/wreq/src/client/emulation.rs +161 -0
- data/vendor/wreq/src/client/http/client/error.rs +142 -0
- data/vendor/wreq/src/client/http/client/exec.rs +29 -0
- data/vendor/wreq/src/client/http/client/extra.rs +77 -0
- data/vendor/wreq/src/client/http/client/lazy.rs +79 -0
- data/vendor/wreq/src/client/http/client/pool.rs +1105 -0
- data/vendor/wreq/src/client/http/client/util.rs +104 -0
- data/vendor/wreq/src/client/http/client.rs +1003 -0
- data/vendor/wreq/src/client/http/future.rs +99 -0
- data/vendor/wreq/src/client/http.rs +1629 -0
- data/vendor/wreq/src/client/layer/config/options.rs +156 -0
- data/vendor/wreq/src/client/layer/config.rs +116 -0
- data/vendor/wreq/src/client/layer/cookie.rs +161 -0
- data/vendor/wreq/src/client/layer/decoder.rs +139 -0
- data/vendor/wreq/src/client/layer/redirect/future.rs +270 -0
- data/vendor/wreq/src/client/layer/redirect/policy.rs +63 -0
- data/vendor/wreq/src/client/layer/redirect.rs +145 -0
- data/vendor/wreq/src/client/layer/retry/classify.rs +105 -0
- data/vendor/wreq/src/client/layer/retry/scope.rs +51 -0
- data/vendor/wreq/src/client/layer/retry.rs +151 -0
- data/vendor/wreq/src/client/layer/timeout/body.rs +233 -0
- data/vendor/wreq/src/client/layer/timeout/future.rs +90 -0
- data/vendor/wreq/src/client/layer/timeout.rs +177 -0
- data/vendor/wreq/src/client/layer.rs +15 -0
- data/vendor/wreq/src/client/multipart.rs +717 -0
- data/vendor/wreq/src/client/request.rs +818 -0
- data/vendor/wreq/src/client/response.rs +534 -0
- data/vendor/wreq/src/client/ws/json.rs +99 -0
- data/vendor/wreq/src/client/ws/message.rs +453 -0
- data/vendor/wreq/src/client/ws.rs +714 -0
- data/vendor/wreq/src/client.rs +27 -0
- data/vendor/wreq/src/config.rs +140 -0
- data/vendor/wreq/src/cookie.rs +579 -0
- data/vendor/wreq/src/dns/gai.rs +249 -0
- data/vendor/wreq/src/dns/hickory.rs +78 -0
- data/vendor/wreq/src/dns/resolve.rs +180 -0
- data/vendor/wreq/src/dns.rs +69 -0
- data/vendor/wreq/src/error.rs +502 -0
- data/vendor/wreq/src/ext.rs +398 -0
- data/vendor/wreq/src/hash.rs +143 -0
- data/vendor/wreq/src/header.rs +506 -0
- data/vendor/wreq/src/into_uri.rs +187 -0
- data/vendor/wreq/src/lib.rs +586 -0
- data/vendor/wreq/src/proxy/mac.rs +82 -0
- data/vendor/wreq/src/proxy/matcher.rs +806 -0
- data/vendor/wreq/src/proxy/uds.rs +66 -0
- data/vendor/wreq/src/proxy/win.rs +31 -0
- data/vendor/wreq/src/proxy.rs +569 -0
- data/vendor/wreq/src/redirect.rs +575 -0
- data/vendor/wreq/src/retry.rs +198 -0
- data/vendor/wreq/src/sync.rs +129 -0
- data/vendor/wreq/src/tls/conn/cache.rs +123 -0
- data/vendor/wreq/src/tls/conn/cert_compression.rs +125 -0
- data/vendor/wreq/src/tls/conn/ext.rs +82 -0
- data/vendor/wreq/src/tls/conn/macros.rs +34 -0
- data/vendor/wreq/src/tls/conn/service.rs +138 -0
- data/vendor/wreq/src/tls/conn.rs +681 -0
- data/vendor/wreq/src/tls/keylog/handle.rs +64 -0
- data/vendor/wreq/src/tls/keylog.rs +99 -0
- data/vendor/wreq/src/tls/options.rs +464 -0
- data/vendor/wreq/src/tls/x509/identity.rs +122 -0
- data/vendor/wreq/src/tls/x509/parser.rs +71 -0
- data/vendor/wreq/src/tls/x509/store.rs +228 -0
- data/vendor/wreq/src/tls/x509.rs +68 -0
- data/vendor/wreq/src/tls.rs +154 -0
- data/vendor/wreq/src/trace.rs +55 -0
- data/vendor/wreq/src/util.rs +122 -0
- data/vendor/wreq/tests/badssl.rs +228 -0
- data/vendor/wreq/tests/brotli.rs +350 -0
- data/vendor/wreq/tests/client.rs +1098 -0
- data/vendor/wreq/tests/connector_layers.rs +227 -0
- data/vendor/wreq/tests/cookie.rs +306 -0
- data/vendor/wreq/tests/deflate.rs +347 -0
- data/vendor/wreq/tests/emulation.rs +260 -0
- data/vendor/wreq/tests/gzip.rs +347 -0
- data/vendor/wreq/tests/layers.rs +261 -0
- data/vendor/wreq/tests/multipart.rs +165 -0
- data/vendor/wreq/tests/proxy.rs +438 -0
- data/vendor/wreq/tests/redirect.rs +629 -0
- data/vendor/wreq/tests/retry.rs +135 -0
- data/vendor/wreq/tests/support/delay_server.rs +117 -0
- data/vendor/wreq/tests/support/error.rs +16 -0
- data/vendor/wreq/tests/support/layer.rs +183 -0
- data/vendor/wreq/tests/support/mod.rs +9 -0
- data/vendor/wreq/tests/support/server.rs +232 -0
- data/vendor/wreq/tests/timeouts.rs +281 -0
- data/vendor/wreq/tests/unix_socket.rs +135 -0
- data/vendor/wreq/tests/upgrade.rs +98 -0
- data/vendor/wreq/tests/zstd.rs +559 -0
- metadata +225 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
fmt::Debug,
|
|
3
|
+
future::Future,
|
|
4
|
+
pin::Pin,
|
|
5
|
+
task::{Context, Poll},
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
use http::{Uri, uri::Scheme};
|
|
9
|
+
use tokio::io::{AsyncRead, AsyncWrite};
|
|
10
|
+
use tokio_boring2::SslStream;
|
|
11
|
+
use tower::Service;
|
|
12
|
+
|
|
13
|
+
use super::{EstablishedConn, HttpsConnector, MaybeHttpsStream};
|
|
14
|
+
use crate::{
|
|
15
|
+
client::{ConnectRequest, Connection},
|
|
16
|
+
error::BoxError,
|
|
17
|
+
ext::UriExt,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type BoxFuture<T, E> = Pin<Box<dyn Future<Output = Result<T, E>> + Send>>;
|
|
21
|
+
|
|
22
|
+
async fn perform_handshake<T>(
|
|
23
|
+
ssl: boring2::ssl::Ssl,
|
|
24
|
+
conn: T,
|
|
25
|
+
) -> Result<MaybeHttpsStream<T>, BoxError>
|
|
26
|
+
where
|
|
27
|
+
T: AsyncRead + AsyncWrite + Unpin,
|
|
28
|
+
{
|
|
29
|
+
let mut stream = SslStream::new(ssl, conn)?;
|
|
30
|
+
Pin::new(&mut stream).connect().await?;
|
|
31
|
+
Ok(MaybeHttpsStream::Https(stream))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
impl<T, S> Service<Uri> for HttpsConnector<S>
|
|
35
|
+
where
|
|
36
|
+
S: Service<Uri, Response = T> + Send,
|
|
37
|
+
S::Error: Into<BoxError>,
|
|
38
|
+
S::Future: Unpin + Send + 'static,
|
|
39
|
+
T: AsyncRead + AsyncWrite + Connection + Unpin + Debug + Sync + Send + 'static,
|
|
40
|
+
{
|
|
41
|
+
type Response = MaybeHttpsStream<T>;
|
|
42
|
+
type Error = BoxError;
|
|
43
|
+
type Future = BoxFuture<Self::Response, Self::Error>;
|
|
44
|
+
|
|
45
|
+
#[inline]
|
|
46
|
+
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
47
|
+
self.http.poll_ready(cx).map_err(Into::into)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fn call(&mut self, uri: Uri) -> Self::Future {
|
|
51
|
+
let connect = self.http.call(uri.clone());
|
|
52
|
+
let inner = self.inner.clone();
|
|
53
|
+
|
|
54
|
+
let f = async move {
|
|
55
|
+
let conn = connect.await.map_err(Into::into)?;
|
|
56
|
+
|
|
57
|
+
// Early return if it is not a tls scheme
|
|
58
|
+
if uri.scheme() != Some(&Scheme::HTTPS) {
|
|
59
|
+
return Ok(MaybeHttpsStream::Http(conn));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let ssl = inner.setup_ssl(uri)?;
|
|
63
|
+
perform_handshake(ssl, conn).await
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Box::pin(f)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
impl<T, S> Service<ConnectRequest> for HttpsConnector<S>
|
|
71
|
+
where
|
|
72
|
+
S: Service<Uri, Response = T> + Send,
|
|
73
|
+
S::Error: Into<BoxError>,
|
|
74
|
+
S::Future: Unpin + Send + 'static,
|
|
75
|
+
T: AsyncRead + AsyncWrite + Connection + Unpin + Debug + Sync + Send + 'static,
|
|
76
|
+
{
|
|
77
|
+
type Response = MaybeHttpsStream<T>;
|
|
78
|
+
type Error = BoxError;
|
|
79
|
+
type Future = BoxFuture<Self::Response, Self::Error>;
|
|
80
|
+
|
|
81
|
+
#[inline]
|
|
82
|
+
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
83
|
+
self.http.poll_ready(cx).map_err(Into::into)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn call(&mut self, req: ConnectRequest) -> Self::Future {
|
|
87
|
+
let uri = req.uri().clone();
|
|
88
|
+
let connect = self.http.call(uri.clone());
|
|
89
|
+
let inner = self.inner.clone();
|
|
90
|
+
|
|
91
|
+
let f = async move {
|
|
92
|
+
let conn = connect.await.map_err(Into::into)?;
|
|
93
|
+
|
|
94
|
+
// Early return if it is not a tls scheme
|
|
95
|
+
if uri.is_http() {
|
|
96
|
+
return Ok(MaybeHttpsStream::Http(conn));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let ssl = inner.setup_ssl2(req)?;
|
|
100
|
+
perform_handshake(ssl, conn).await
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Box::pin(f)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
impl<T, S, IO> Service<EstablishedConn<IO>> for HttpsConnector<S>
|
|
108
|
+
where
|
|
109
|
+
S: Service<Uri, Response = T> + Send + Clone + 'static,
|
|
110
|
+
S::Error: Into<BoxError>,
|
|
111
|
+
S::Future: Unpin + Send + 'static,
|
|
112
|
+
T: AsyncRead + AsyncWrite + Connection + Unpin + Debug + Sync + Send + 'static,
|
|
113
|
+
IO: AsyncRead + AsyncWrite + Unpin + Send + Sync + Debug + 'static,
|
|
114
|
+
{
|
|
115
|
+
type Response = MaybeHttpsStream<IO>;
|
|
116
|
+
type Error = BoxError;
|
|
117
|
+
type Future = BoxFuture<Self::Response, Self::Error>;
|
|
118
|
+
|
|
119
|
+
#[inline]
|
|
120
|
+
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
121
|
+
self.http.poll_ready(cx).map_err(Into::into)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
fn call(&mut self, conn: EstablishedConn<IO>) -> Self::Future {
|
|
125
|
+
let inner = self.inner.clone();
|
|
126
|
+
let fut = async move {
|
|
127
|
+
// Early return if it is not a tls scheme
|
|
128
|
+
if conn.req.uri().is_http() {
|
|
129
|
+
return Ok(MaybeHttpsStream::Http(conn.io));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let ssl = inner.setup_ssl2(conn.req)?;
|
|
133
|
+
perform_handshake(ssl, conn.io).await
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
Box::pin(fut)
|
|
137
|
+
}
|
|
138
|
+
}
|