wreq-rb 0.4.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.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +1922 -397
  3. data/LICENSE +203 -0
  4. data/README.md +47 -16
  5. data/exe/wreq +211 -0
  6. data/ext/wreq_rb/Cargo.toml +4 -6
  7. data/ext/wreq_rb/src/client.rs +145 -41
  8. data/lib/wreq-rb/version.rb +1 -1
  9. data/patches/0001-add-transfer-size-tracking.patch +76 -67
  10. data/vendor/wreq/Cargo.toml +119 -71
  11. data/vendor/wreq/README.md +25 -20
  12. data/vendor/wreq/bench/http1.rs +25 -0
  13. data/vendor/wreq/bench/http1_over_tls.rs +25 -0
  14. data/vendor/wreq/bench/http2.rs +25 -0
  15. data/vendor/wreq/bench/http2_over_tls.rs +25 -0
  16. data/vendor/wreq/bench/support/bench.rs +91 -0
  17. data/vendor/wreq/bench/support/client.rs +217 -0
  18. data/vendor/wreq/bench/support/server.rs +188 -0
  19. data/vendor/wreq/bench/support.rs +56 -0
  20. data/vendor/wreq/examples/cert_store.rs +4 -4
  21. data/vendor/wreq/examples/{emulation.rs → emulate.rs} +2 -2
  22. data/vendor/wreq/examples/http2_websocket.rs +2 -2
  23. data/vendor/wreq/examples/keylog.rs +3 -3
  24. data/vendor/wreq/examples/{request_with_emulation.rs → request_with_emulate.rs} +2 -2
  25. data/vendor/wreq/examples/rt.rs +23 -0
  26. data/vendor/wreq/src/client/body.rs +23 -61
  27. data/vendor/wreq/src/client/emulate.rs +119 -0
  28. data/vendor/wreq/src/client/{http/future.rs → future.rs} +11 -32
  29. data/vendor/wreq/src/client/{http → layer}/client/pool.rs +66 -61
  30. data/vendor/wreq/src/client/{http → layer}/client.rs +416 -270
  31. data/vendor/wreq/src/client/layer/config.rs +27 -6
  32. data/vendor/wreq/src/client/layer/decoder.rs +9 -4
  33. data/vendor/wreq/src/client/layer/redirect/future.rs +6 -3
  34. data/vendor/wreq/src/client/layer/redirect.rs +4 -5
  35. data/vendor/wreq/src/client/layer/retry.rs +8 -5
  36. data/vendor/wreq/src/client/layer/timeout/body.rs +15 -6
  37. data/vendor/wreq/src/client/layer/timeout/future.rs +23 -18
  38. data/vendor/wreq/src/client/layer/timeout.rs +24 -74
  39. data/vendor/wreq/src/client/layer.rs +1 -2
  40. data/vendor/wreq/src/client/multipart.rs +137 -154
  41. data/vendor/wreq/src/client/request.rs +202 -118
  42. data/vendor/wreq/src/client/response.rs +46 -45
  43. data/vendor/wreq/src/client/upgrade.rs +15 -0
  44. data/vendor/wreq/src/client/ws.rs +73 -25
  45. data/vendor/wreq/src/client.rs +1655 -17
  46. data/vendor/wreq/src/config.rs +11 -11
  47. data/vendor/wreq/src/{client/conn → conn}/connector.rs +139 -137
  48. data/vendor/wreq/src/conn/descriptor.rs +143 -0
  49. data/vendor/wreq/src/conn/http.rs +484 -0
  50. data/vendor/wreq/src/conn/net/io.rs +75 -0
  51. data/vendor/wreq/src/conn/net/tcp/compio.rs +71 -0
  52. data/vendor/wreq/src/conn/net/tcp/tokio.rs +57 -0
  53. data/vendor/wreq/src/conn/net/tcp.rs +561 -0
  54. data/vendor/wreq/src/conn/net/uds/compio.rs +60 -0
  55. data/vendor/wreq/src/{client/conn/uds.rs → conn/net/uds/tokio.rs} +18 -12
  56. data/vendor/wreq/src/conn/net/uds.rs +11 -0
  57. data/vendor/wreq/src/conn/net.rs +130 -0
  58. data/vendor/wreq/src/{client/conn → conn}/proxy/socks.rs +2 -9
  59. data/vendor/wreq/src/{client/conn → conn}/proxy/tunnel.rs +21 -56
  60. data/vendor/wreq/src/conn/tls_info.rs +47 -0
  61. data/vendor/wreq/src/{client/conn.rs → conn.rs} +202 -54
  62. data/vendor/wreq/src/cookie.rs +302 -142
  63. data/vendor/wreq/src/dns/gai/compio.rs +77 -0
  64. data/vendor/wreq/src/dns/gai/tokio.rs +90 -0
  65. data/vendor/wreq/src/dns/gai.rs +14 -164
  66. data/vendor/wreq/src/dns/hickory.rs +16 -23
  67. data/vendor/wreq/src/dns/resolve.rs +7 -41
  68. data/vendor/wreq/src/dns.rs +90 -7
  69. data/vendor/wreq/src/error.rs +57 -31
  70. data/vendor/wreq/src/ext.rs +25 -0
  71. data/vendor/wreq/src/group.rs +211 -0
  72. data/vendor/wreq/src/header.rs +100 -112
  73. data/vendor/wreq/src/lib.rs +124 -73
  74. data/vendor/wreq/src/proxy.rs +6 -20
  75. data/vendor/wreq/src/redirect.rs +1 -1
  76. data/vendor/wreq/src/rt.rs +208 -0
  77. data/vendor/wreq/src/sync.rs +97 -98
  78. data/vendor/wreq/src/tls/compress.rs +124 -0
  79. data/vendor/wreq/src/tls/conn/ext.rs +54 -45
  80. data/vendor/wreq/src/tls/conn/service.rs +14 -18
  81. data/vendor/wreq/src/tls/conn.rs +169 -241
  82. data/vendor/wreq/src/tls/keylog.rs +68 -5
  83. data/vendor/wreq/src/tls/session.rs +205 -0
  84. data/vendor/wreq/src/tls/{x509 → trust}/identity.rs +4 -21
  85. data/vendor/wreq/src/tls/{x509/parser.rs → trust/parse.rs} +1 -1
  86. data/vendor/wreq/src/tls/{x509 → trust}/store.rs +42 -81
  87. data/vendor/wreq/src/tls/{x509.rs → trust.rs} +8 -2
  88. data/vendor/wreq/src/tls.rs +489 -25
  89. data/vendor/wreq/src/trace.rs +0 -12
  90. data/vendor/wreq/src/util.rs +1 -1
  91. data/vendor/wreq/tests/badssl.rs +10 -10
  92. data/vendor/wreq/tests/client.rs +3 -9
  93. data/vendor/wreq/tests/cookie.rs +6 -8
  94. data/vendor/wreq/tests/{emulation.rs → emulate.rs} +130 -22
  95. data/vendor/wreq/tests/multipart.rs +43 -1
  96. data/vendor/wreq/tests/proxy.rs +1 -1
  97. data/vendor/wreq/tests/support/layer.rs +1 -0
  98. metadata +53 -72
  99. data/vendor/wreq/src/client/conn/conn.rs +0 -231
  100. data/vendor/wreq/src/client/conn/http.rs +0 -1023
  101. data/vendor/wreq/src/client/conn/tls_info.rs +0 -98
  102. data/vendor/wreq/src/client/core/body/incoming.rs +0 -485
  103. data/vendor/wreq/src/client/core/body/length.rs +0 -118
  104. data/vendor/wreq/src/client/core/body.rs +0 -34
  105. data/vendor/wreq/src/client/core/common/buf.rs +0 -149
  106. data/vendor/wreq/src/client/core/common/rewind.rs +0 -141
  107. data/vendor/wreq/src/client/core/common/watch.rs +0 -76
  108. data/vendor/wreq/src/client/core/common.rs +0 -3
  109. data/vendor/wreq/src/client/core/conn/http1.rs +0 -342
  110. data/vendor/wreq/src/client/core/conn/http2.rs +0 -307
  111. data/vendor/wreq/src/client/core/conn.rs +0 -11
  112. data/vendor/wreq/src/client/core/dispatch.rs +0 -299
  113. data/vendor/wreq/src/client/core/error.rs +0 -435
  114. data/vendor/wreq/src/client/core/ext.rs +0 -201
  115. data/vendor/wreq/src/client/core/http1.rs +0 -178
  116. data/vendor/wreq/src/client/core/http2.rs +0 -483
  117. data/vendor/wreq/src/client/core/proto/h1/conn.rs +0 -988
  118. data/vendor/wreq/src/client/core/proto/h1/decode.rs +0 -1170
  119. data/vendor/wreq/src/client/core/proto/h1/dispatch.rs +0 -684
  120. data/vendor/wreq/src/client/core/proto/h1/encode.rs +0 -580
  121. data/vendor/wreq/src/client/core/proto/h1/io.rs +0 -879
  122. data/vendor/wreq/src/client/core/proto/h1/role.rs +0 -694
  123. data/vendor/wreq/src/client/core/proto/h1.rs +0 -104
  124. data/vendor/wreq/src/client/core/proto/h2/client.rs +0 -650
  125. data/vendor/wreq/src/client/core/proto/h2/ping.rs +0 -539
  126. data/vendor/wreq/src/client/core/proto/h2.rs +0 -379
  127. data/vendor/wreq/src/client/core/proto/headers.rs +0 -138
  128. data/vendor/wreq/src/client/core/proto.rs +0 -58
  129. data/vendor/wreq/src/client/core/rt/bounds.rs +0 -57
  130. data/vendor/wreq/src/client/core/rt/timer.rs +0 -150
  131. data/vendor/wreq/src/client/core/rt/tokio.rs +0 -99
  132. data/vendor/wreq/src/client/core/rt.rs +0 -25
  133. data/vendor/wreq/src/client/core/upgrade.rs +0 -267
  134. data/vendor/wreq/src/client/core.rs +0 -16
  135. data/vendor/wreq/src/client/emulation.rs +0 -161
  136. data/vendor/wreq/src/client/http/client/error.rs +0 -142
  137. data/vendor/wreq/src/client/http/client/exec.rs +0 -29
  138. data/vendor/wreq/src/client/http/client/extra.rs +0 -77
  139. data/vendor/wreq/src/client/http/client/util.rs +0 -104
  140. data/vendor/wreq/src/client/http.rs +0 -1629
  141. data/vendor/wreq/src/client/layer/config/options.rs +0 -156
  142. data/vendor/wreq/src/client/layer/cookie.rs +0 -161
  143. data/vendor/wreq/src/hash.rs +0 -143
  144. data/vendor/wreq/src/tls/conn/cache.rs +0 -123
  145. data/vendor/wreq/src/tls/conn/cert_compression.rs +0 -125
  146. data/vendor/wreq/src/tls/keylog/handle.rs +0 -64
  147. data/vendor/wreq/src/tls/options.rs +0 -464
  148. /data/vendor/wreq/src/client/{http → layer}/client/lazy.rs +0 -0
  149. /data/vendor/wreq/src/{client/conn → conn}/proxy.rs +0 -0
  150. /data/vendor/wreq/src/{client/conn → conn}/verbose.rs +0 -0
@@ -1,231 +0,0 @@
1
- use std::{
2
- io::{self, IoSlice},
3
- pin::Pin,
4
- task::{Context, Poll},
5
- };
6
-
7
- use pin_project_lite::pin_project;
8
- #[cfg(unix)]
9
- use tokio::net::UnixStream;
10
- use tokio::{
11
- io::{AsyncRead, AsyncWrite, ReadBuf},
12
- net::TcpStream,
13
- };
14
- use tokio_boring2::SslStream;
15
-
16
- use super::{AsyncConnWithInfo, Connected, Connection, TlsInfoFactory};
17
- use crate::{
18
- proxy::matcher::Intercept,
19
- tls::{TlsInfo, conn::MaybeHttpsStream},
20
- };
21
-
22
- pin_project! {
23
- /// Note: the `is_proxy` member means *is plain text HTTP proxy*.
24
- /// This tells core whether the URI should be written in
25
- /// * origin-form (`GET /just/a/path HTTP/1.1`), when `is_proxy == false`, or
26
- /// * absolute-form (`GET http://foo.bar/and/a/path HTTP/1.1`), otherwise.
27
- pub struct Conn {
28
- #[pin]
29
- pub(super) inner: Box<dyn AsyncConnWithInfo>,
30
- pub(super) tls_info: bool,
31
- pub(super) proxy: Option<Intercept>,
32
- }
33
- }
34
-
35
- pin_project! {
36
- /// A wrapper around `SslStream` that adapts it for use as a generic async connection.
37
- ///
38
- /// This type enables unified handling of plain TCP and TLS-encrypted streams by providing
39
- /// implementations of `Connection`, `Read`, `Write`, and `TlsInfoFactory`.
40
- /// It is mainly used internally to abstract over different connection types.
41
- pub struct TlsConn<T> {
42
- #[pin]
43
- inner: SslStream<T>,
44
- }
45
- }
46
-
47
- // ==== impl Conn ====
48
-
49
- impl Connection for Conn {
50
- fn connected(&self) -> Connected {
51
- let mut connected = self.inner.connected();
52
-
53
- if let Some(proxy) = &self.proxy {
54
- connected = connected.proxy(proxy.clone());
55
- }
56
-
57
- if self.tls_info {
58
- if let Some(tls_info) = self.inner.tls_info() {
59
- connected.extra(tls_info)
60
- } else {
61
- connected
62
- }
63
- } else {
64
- connected
65
- }
66
- }
67
- }
68
-
69
- impl AsyncRead for Conn {
70
- #[inline]
71
- fn poll_read(
72
- self: Pin<&mut Self>,
73
- cx: &mut Context,
74
- buf: &mut ReadBuf<'_>,
75
- ) -> Poll<io::Result<()>> {
76
- AsyncRead::poll_read(self.project().inner, cx, buf)
77
- }
78
- }
79
-
80
- impl AsyncWrite for Conn {
81
- #[inline]
82
- fn poll_write(
83
- self: Pin<&mut Self>,
84
- cx: &mut Context,
85
- buf: &[u8],
86
- ) -> Poll<Result<usize, io::Error>> {
87
- AsyncWrite::poll_write(self.project().inner, cx, buf)
88
- }
89
-
90
- #[inline]
91
- fn poll_write_vectored(
92
- self: Pin<&mut Self>,
93
- cx: &mut Context<'_>,
94
- bufs: &[IoSlice<'_>],
95
- ) -> Poll<Result<usize, io::Error>> {
96
- AsyncWrite::poll_write_vectored(self.project().inner, cx, bufs)
97
- }
98
-
99
- #[inline]
100
- fn is_write_vectored(&self) -> bool {
101
- self.inner.is_write_vectored()
102
- }
103
-
104
- #[inline]
105
- fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
106
- AsyncWrite::poll_flush(self.project().inner, cx)
107
- }
108
-
109
- #[inline]
110
- fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
111
- AsyncWrite::poll_shutdown(self.project().inner, cx)
112
- }
113
- }
114
-
115
- // ==== impl TlsConn ====
116
-
117
- impl<T> TlsConn<T>
118
- where
119
- T: AsyncRead + AsyncWrite + Unpin,
120
- {
121
- /// Creates a new `TlsConn` wrapping the provided `SslStream`.
122
- #[inline(always)]
123
- pub fn new(inner: SslStream<T>) -> Self {
124
- Self { inner }
125
- }
126
- }
127
-
128
- // ===== impl TcpStream =====
129
-
130
- impl Connection for TlsConn<TcpStream> {
131
- fn connected(&self) -> Connected {
132
- let connected = self.inner.get_ref().connected();
133
- if self.inner.ssl().selected_alpn_protocol() == Some(b"h2") {
134
- connected.negotiated_h2()
135
- } else {
136
- connected
137
- }
138
- }
139
- }
140
-
141
- impl Connection for TlsConn<MaybeHttpsStream<TcpStream>> {
142
- fn connected(&self) -> Connected {
143
- let connected = self.inner.get_ref().connected();
144
- if self.inner.ssl().selected_alpn_protocol() == Some(b"h2") {
145
- connected.negotiated_h2()
146
- } else {
147
- connected
148
- }
149
- }
150
- }
151
-
152
- // ===== impl UnixStream =====
153
-
154
- #[cfg(unix)]
155
- impl Connection for TlsConn<UnixStream> {
156
- fn connected(&self) -> Connected {
157
- let connected = self.inner.get_ref().connected();
158
- if self.inner.ssl().selected_alpn_protocol() == Some(b"h2") {
159
- connected.negotiated_h2()
160
- } else {
161
- connected
162
- }
163
- }
164
- }
165
-
166
- #[cfg(unix)]
167
- impl Connection for TlsConn<MaybeHttpsStream<UnixStream>> {
168
- fn connected(&self) -> Connected {
169
- let connected = self.inner.get_ref().connected();
170
- if self.inner.ssl().selected_alpn_protocol() == Some(b"h2") {
171
- connected.negotiated_h2()
172
- } else {
173
- connected
174
- }
175
- }
176
- }
177
-
178
- impl<T: AsyncRead + AsyncWrite + Unpin> AsyncRead for TlsConn<T> {
179
- #[inline]
180
- fn poll_read(
181
- self: Pin<&mut Self>,
182
- cx: &mut Context,
183
- buf: &mut ReadBuf<'_>,
184
- ) -> Poll<tokio::io::Result<()>> {
185
- AsyncRead::poll_read(self.project().inner, cx, buf)
186
- }
187
- }
188
-
189
- impl<T: AsyncRead + AsyncWrite + Unpin> AsyncWrite for TlsConn<T> {
190
- #[inline]
191
- fn poll_write(
192
- self: Pin<&mut Self>,
193
- cx: &mut Context,
194
- buf: &[u8],
195
- ) -> Poll<Result<usize, tokio::io::Error>> {
196
- AsyncWrite::poll_write(self.project().inner, cx, buf)
197
- }
198
-
199
- #[inline]
200
- fn poll_write_vectored(
201
- self: Pin<&mut Self>,
202
- cx: &mut Context<'_>,
203
- bufs: &[IoSlice<'_>],
204
- ) -> Poll<Result<usize, io::Error>> {
205
- AsyncWrite::poll_write_vectored(self.project().inner, cx, bufs)
206
- }
207
-
208
- #[inline]
209
- fn is_write_vectored(&self) -> bool {
210
- self.inner.is_write_vectored()
211
- }
212
-
213
- #[inline]
214
- fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), tokio::io::Error>> {
215
- AsyncWrite::poll_flush(self.project().inner, cx)
216
- }
217
-
218
- #[inline]
219
- fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), tokio::io::Error>> {
220
- AsyncWrite::poll_shutdown(self.project().inner, cx)
221
- }
222
- }
223
-
224
- impl<T> TlsInfoFactory for TlsConn<T>
225
- where
226
- SslStream<T>: TlsInfoFactory,
227
- {
228
- fn tls_info(&self) -> Option<TlsInfo> {
229
- self.inner.tls_info()
230
- }
231
- }