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.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/Cargo.lock +2688 -0
  3. data/Cargo.toml +6 -0
  4. data/README.md +179 -0
  5. data/ext/wreq_rb/Cargo.toml +39 -0
  6. data/ext/wreq_rb/extconf.rb +22 -0
  7. data/ext/wreq_rb/src/client.rs +565 -0
  8. data/ext/wreq_rb/src/error.rs +25 -0
  9. data/ext/wreq_rb/src/lib.rs +20 -0
  10. data/ext/wreq_rb/src/response.rs +132 -0
  11. data/lib/wreq-rb/version.rb +5 -0
  12. data/lib/wreq-rb.rb +17 -0
  13. data/patches/0001-add-transfer-size-tracking.patch +292 -0
  14. data/vendor/wreq/Cargo.toml +306 -0
  15. data/vendor/wreq/LICENSE +202 -0
  16. data/vendor/wreq/README.md +122 -0
  17. data/vendor/wreq/examples/cert_store.rs +77 -0
  18. data/vendor/wreq/examples/connect_via_lower_priority_tokio_runtime.rs +258 -0
  19. data/vendor/wreq/examples/emulation.rs +118 -0
  20. data/vendor/wreq/examples/form.rs +14 -0
  21. data/vendor/wreq/examples/http1_websocket.rs +37 -0
  22. data/vendor/wreq/examples/http2_websocket.rs +45 -0
  23. data/vendor/wreq/examples/json_dynamic.rs +41 -0
  24. data/vendor/wreq/examples/json_typed.rs +47 -0
  25. data/vendor/wreq/examples/keylog.rs +16 -0
  26. data/vendor/wreq/examples/request_with_emulation.rs +115 -0
  27. data/vendor/wreq/examples/request_with_interface.rs +37 -0
  28. data/vendor/wreq/examples/request_with_local_address.rs +16 -0
  29. data/vendor/wreq/examples/request_with_proxy.rs +13 -0
  30. data/vendor/wreq/examples/request_with_redirect.rs +22 -0
  31. data/vendor/wreq/examples/request_with_version.rs +15 -0
  32. data/vendor/wreq/examples/tor_socks.rs +24 -0
  33. data/vendor/wreq/examples/unix_socket.rs +33 -0
  34. data/vendor/wreq/src/client/body.rs +304 -0
  35. data/vendor/wreq/src/client/conn/conn.rs +231 -0
  36. data/vendor/wreq/src/client/conn/connector.rs +549 -0
  37. data/vendor/wreq/src/client/conn/http.rs +1023 -0
  38. data/vendor/wreq/src/client/conn/proxy/socks.rs +233 -0
  39. data/vendor/wreq/src/client/conn/proxy/tunnel.rs +260 -0
  40. data/vendor/wreq/src/client/conn/proxy.rs +39 -0
  41. data/vendor/wreq/src/client/conn/tls_info.rs +98 -0
  42. data/vendor/wreq/src/client/conn/uds.rs +44 -0
  43. data/vendor/wreq/src/client/conn/verbose.rs +149 -0
  44. data/vendor/wreq/src/client/conn.rs +323 -0
  45. data/vendor/wreq/src/client/core/body/incoming.rs +485 -0
  46. data/vendor/wreq/src/client/core/body/length.rs +118 -0
  47. data/vendor/wreq/src/client/core/body.rs +34 -0
  48. data/vendor/wreq/src/client/core/common/buf.rs +149 -0
  49. data/vendor/wreq/src/client/core/common/rewind.rs +141 -0
  50. data/vendor/wreq/src/client/core/common/watch.rs +76 -0
  51. data/vendor/wreq/src/client/core/common.rs +3 -0
  52. data/vendor/wreq/src/client/core/conn/http1.rs +342 -0
  53. data/vendor/wreq/src/client/core/conn/http2.rs +307 -0
  54. data/vendor/wreq/src/client/core/conn.rs +11 -0
  55. data/vendor/wreq/src/client/core/dispatch.rs +299 -0
  56. data/vendor/wreq/src/client/core/error.rs +435 -0
  57. data/vendor/wreq/src/client/core/ext.rs +201 -0
  58. data/vendor/wreq/src/client/core/http1.rs +178 -0
  59. data/vendor/wreq/src/client/core/http2.rs +483 -0
  60. data/vendor/wreq/src/client/core/proto/h1/conn.rs +988 -0
  61. data/vendor/wreq/src/client/core/proto/h1/decode.rs +1170 -0
  62. data/vendor/wreq/src/client/core/proto/h1/dispatch.rs +684 -0
  63. data/vendor/wreq/src/client/core/proto/h1/encode.rs +580 -0
  64. data/vendor/wreq/src/client/core/proto/h1/io.rs +879 -0
  65. data/vendor/wreq/src/client/core/proto/h1/role.rs +694 -0
  66. data/vendor/wreq/src/client/core/proto/h1.rs +104 -0
  67. data/vendor/wreq/src/client/core/proto/h2/client.rs +650 -0
  68. data/vendor/wreq/src/client/core/proto/h2/ping.rs +539 -0
  69. data/vendor/wreq/src/client/core/proto/h2.rs +379 -0
  70. data/vendor/wreq/src/client/core/proto/headers.rs +138 -0
  71. data/vendor/wreq/src/client/core/proto.rs +58 -0
  72. data/vendor/wreq/src/client/core/rt/bounds.rs +57 -0
  73. data/vendor/wreq/src/client/core/rt/timer.rs +150 -0
  74. data/vendor/wreq/src/client/core/rt/tokio.rs +99 -0
  75. data/vendor/wreq/src/client/core/rt.rs +25 -0
  76. data/vendor/wreq/src/client/core/upgrade.rs +267 -0
  77. data/vendor/wreq/src/client/core.rs +16 -0
  78. data/vendor/wreq/src/client/emulation.rs +161 -0
  79. data/vendor/wreq/src/client/http/client/error.rs +142 -0
  80. data/vendor/wreq/src/client/http/client/exec.rs +29 -0
  81. data/vendor/wreq/src/client/http/client/extra.rs +77 -0
  82. data/vendor/wreq/src/client/http/client/lazy.rs +79 -0
  83. data/vendor/wreq/src/client/http/client/pool.rs +1105 -0
  84. data/vendor/wreq/src/client/http/client/util.rs +104 -0
  85. data/vendor/wreq/src/client/http/client.rs +1003 -0
  86. data/vendor/wreq/src/client/http/future.rs +99 -0
  87. data/vendor/wreq/src/client/http.rs +1629 -0
  88. data/vendor/wreq/src/client/layer/config/options.rs +156 -0
  89. data/vendor/wreq/src/client/layer/config.rs +116 -0
  90. data/vendor/wreq/src/client/layer/cookie.rs +161 -0
  91. data/vendor/wreq/src/client/layer/decoder.rs +139 -0
  92. data/vendor/wreq/src/client/layer/redirect/future.rs +270 -0
  93. data/vendor/wreq/src/client/layer/redirect/policy.rs +63 -0
  94. data/vendor/wreq/src/client/layer/redirect.rs +145 -0
  95. data/vendor/wreq/src/client/layer/retry/classify.rs +105 -0
  96. data/vendor/wreq/src/client/layer/retry/scope.rs +51 -0
  97. data/vendor/wreq/src/client/layer/retry.rs +151 -0
  98. data/vendor/wreq/src/client/layer/timeout/body.rs +233 -0
  99. data/vendor/wreq/src/client/layer/timeout/future.rs +90 -0
  100. data/vendor/wreq/src/client/layer/timeout.rs +177 -0
  101. data/vendor/wreq/src/client/layer.rs +15 -0
  102. data/vendor/wreq/src/client/multipart.rs +717 -0
  103. data/vendor/wreq/src/client/request.rs +818 -0
  104. data/vendor/wreq/src/client/response.rs +534 -0
  105. data/vendor/wreq/src/client/ws/json.rs +99 -0
  106. data/vendor/wreq/src/client/ws/message.rs +453 -0
  107. data/vendor/wreq/src/client/ws.rs +714 -0
  108. data/vendor/wreq/src/client.rs +27 -0
  109. data/vendor/wreq/src/config.rs +140 -0
  110. data/vendor/wreq/src/cookie.rs +579 -0
  111. data/vendor/wreq/src/dns/gai.rs +249 -0
  112. data/vendor/wreq/src/dns/hickory.rs +78 -0
  113. data/vendor/wreq/src/dns/resolve.rs +180 -0
  114. data/vendor/wreq/src/dns.rs +69 -0
  115. data/vendor/wreq/src/error.rs +502 -0
  116. data/vendor/wreq/src/ext.rs +398 -0
  117. data/vendor/wreq/src/hash.rs +143 -0
  118. data/vendor/wreq/src/header.rs +506 -0
  119. data/vendor/wreq/src/into_uri.rs +187 -0
  120. data/vendor/wreq/src/lib.rs +586 -0
  121. data/vendor/wreq/src/proxy/mac.rs +82 -0
  122. data/vendor/wreq/src/proxy/matcher.rs +806 -0
  123. data/vendor/wreq/src/proxy/uds.rs +66 -0
  124. data/vendor/wreq/src/proxy/win.rs +31 -0
  125. data/vendor/wreq/src/proxy.rs +569 -0
  126. data/vendor/wreq/src/redirect.rs +575 -0
  127. data/vendor/wreq/src/retry.rs +198 -0
  128. data/vendor/wreq/src/sync.rs +129 -0
  129. data/vendor/wreq/src/tls/conn/cache.rs +123 -0
  130. data/vendor/wreq/src/tls/conn/cert_compression.rs +125 -0
  131. data/vendor/wreq/src/tls/conn/ext.rs +82 -0
  132. data/vendor/wreq/src/tls/conn/macros.rs +34 -0
  133. data/vendor/wreq/src/tls/conn/service.rs +138 -0
  134. data/vendor/wreq/src/tls/conn.rs +681 -0
  135. data/vendor/wreq/src/tls/keylog/handle.rs +64 -0
  136. data/vendor/wreq/src/tls/keylog.rs +99 -0
  137. data/vendor/wreq/src/tls/options.rs +464 -0
  138. data/vendor/wreq/src/tls/x509/identity.rs +122 -0
  139. data/vendor/wreq/src/tls/x509/parser.rs +71 -0
  140. data/vendor/wreq/src/tls/x509/store.rs +228 -0
  141. data/vendor/wreq/src/tls/x509.rs +68 -0
  142. data/vendor/wreq/src/tls.rs +154 -0
  143. data/vendor/wreq/src/trace.rs +55 -0
  144. data/vendor/wreq/src/util.rs +122 -0
  145. data/vendor/wreq/tests/badssl.rs +228 -0
  146. data/vendor/wreq/tests/brotli.rs +350 -0
  147. data/vendor/wreq/tests/client.rs +1098 -0
  148. data/vendor/wreq/tests/connector_layers.rs +227 -0
  149. data/vendor/wreq/tests/cookie.rs +306 -0
  150. data/vendor/wreq/tests/deflate.rs +347 -0
  151. data/vendor/wreq/tests/emulation.rs +260 -0
  152. data/vendor/wreq/tests/gzip.rs +347 -0
  153. data/vendor/wreq/tests/layers.rs +261 -0
  154. data/vendor/wreq/tests/multipart.rs +165 -0
  155. data/vendor/wreq/tests/proxy.rs +438 -0
  156. data/vendor/wreq/tests/redirect.rs +629 -0
  157. data/vendor/wreq/tests/retry.rs +135 -0
  158. data/vendor/wreq/tests/support/delay_server.rs +117 -0
  159. data/vendor/wreq/tests/support/error.rs +16 -0
  160. data/vendor/wreq/tests/support/layer.rs +183 -0
  161. data/vendor/wreq/tests/support/mod.rs +9 -0
  162. data/vendor/wreq/tests/support/server.rs +232 -0
  163. data/vendor/wreq/tests/timeouts.rs +281 -0
  164. data/vendor/wreq/tests/unix_socket.rs +135 -0
  165. data/vendor/wreq/tests/upgrade.rs +98 -0
  166. data/vendor/wreq/tests/zstd.rs +559 -0
  167. metadata +225 -0
@@ -0,0 +1,27 @@
1
+ mod body;
2
+ mod conn;
3
+ mod core;
4
+ mod emulation;
5
+ mod http;
6
+ mod request;
7
+ mod response;
8
+
9
+ pub mod layer;
10
+ #[cfg(feature = "multipart")]
11
+ pub mod multipart;
12
+ #[cfg(feature = "ws")]
13
+ pub mod ws;
14
+
15
+ pub use self::{
16
+ body::Body,
17
+ core::{http1, http2, upgrade::Upgraded},
18
+ emulation::{Emulation, EmulationBuilder, EmulationFactory},
19
+ http::{Client, ClientBuilder},
20
+ request::{Request, RequestBuilder},
21
+ response::Response,
22
+ };
23
+ pub(crate) use self::{
24
+ conn::{Connected, Connection},
25
+ core::{Error as CoreError, ext},
26
+ http::{ConnectIdentity, ConnectRequest, client::error::Error},
27
+ };
@@ -0,0 +1,140 @@
1
+ //! The `config` module provides a generic mechanism for loading and managing
2
+ //! request-scoped configuration.
3
+ //!
4
+ //! # Design Overview
5
+ //!
6
+ //! This module is centered around two abstractions:
7
+ //!
8
+ //! - The [`RequestConfigValue`] trait, used to associate a config key type with its value type.
9
+ //! - The [`RequestConfig`] struct, which wraps an optional value of the type linked via
10
+ //! [`RequestConfigValue`].
11
+ //!
12
+ //! Under the hood, the [`RequestConfig`] struct holds a single value for the associated config
13
+ //! type. This value can be conveniently accessed, inserted, or mutated using [`http::Extensions`],
14
+ //! enabling type-safe configuration storage and retrieval on a per-request basis.
15
+ //!
16
+ //! # Motivation
17
+ //!
18
+ //! The key design benefit is the ability to store multiple config types—potentially even with the
19
+ //! same value type (e.g., [`std::time::Duration`])—without code duplication or ambiguity. By
20
+ //! leveraging trait association, each config key is distinct at the type level, while code for
21
+ //! storage and access remains totally generic.
22
+ //!
23
+ //! # Usage
24
+ //!
25
+ //! Implement [`RequestConfigValue`] for any marker type you wish to use as a config key,
26
+ //! specifying the associated value type. Then use [`RequestConfig<T>`] in [`Extensions`]
27
+ //! to set or retrieve config values for each key type in a uniform way.
28
+
29
+ use http::Extensions;
30
+
31
+ /// Associate a marker key type with its associated value type stored in [`http::Extensions`].
32
+ /// Implement this trait for unit/marker types to declare the concrete `Value` used for that key.
33
+ pub(crate) trait RequestConfigValue: Clone + 'static {
34
+ type Value: Clone + Send + Sync + 'static;
35
+ }
36
+
37
+ /// Typed wrapper that holds an optional configuration value for a given marker key `T`.
38
+ /// Instances of [`RequestConfig<T>`] are intended to be inserted into [`http::Extensions`].
39
+ #[derive(Clone, Copy)]
40
+ pub(crate) struct RequestConfig<T: RequestConfigValue>(Option<T::Value>);
41
+
42
+ impl<T: RequestConfigValue> Default for RequestConfig<T> {
43
+ #[inline]
44
+ fn default() -> Self {
45
+ RequestConfig(None)
46
+ }
47
+ }
48
+
49
+ impl<T> RequestConfig<T>
50
+ where
51
+ T: RequestConfigValue,
52
+ {
53
+ /// Creates a new `RequestConfig` with the provided value.
54
+ #[inline]
55
+ pub(crate) const fn new(v: Option<T::Value>) -> Self {
56
+ RequestConfig(v)
57
+ }
58
+
59
+ /// Returns a reference to the inner value of this request-scoped configuration.
60
+ #[inline]
61
+ pub(crate) const fn as_ref(&self) -> Option<&T::Value> {
62
+ self.0.as_ref()
63
+ }
64
+
65
+ /// Retrieve the value from the request-scoped configuration.
66
+ ///
67
+ /// If the request specifies a value, use that value; otherwise, attempt to retrieve it from the
68
+ /// current instance (typically a client instance).
69
+ #[inline]
70
+ pub(crate) fn fetch<'a>(&'a self, ext: &'a Extensions) -> Option<&'a T::Value> {
71
+ ext.get::<RequestConfig<T>>()
72
+ .and_then(Self::as_ref)
73
+ .or(self.as_ref())
74
+ }
75
+
76
+ /// Stores this value into the given [`http::Extensions`], if a value of the same type is not
77
+ /// already present.
78
+ ///
79
+ /// This method checks whether the provided [`http::Extensions`] contains a
80
+ /// [`RequestConfig<T>`]. If not, it clones the current value and inserts it into the
81
+ /// extensions. If a value already exists, the method does nothing.
82
+ #[inline]
83
+ pub(crate) fn store<'a>(&'a self, ext: &'a mut Extensions) -> &'a mut Option<T::Value> {
84
+ &mut ext.get_or_insert_with(|| self.clone()).0
85
+ }
86
+
87
+ /// Loads the internal value from the provided [`http::Extensions`], if present.
88
+ ///
89
+ /// This method attempts to remove a value of type [`RequestConfig<T>`] from the provided
90
+ /// [`http::Extensions`]. If such a value exists, the current internal value is replaced with
91
+ /// the removed value. If not, the internal value remains unchanged.
92
+ #[inline]
93
+ pub(crate) fn load(&mut self, ext: &mut Extensions) -> Option<&T::Value> {
94
+ if let Some(value) = RequestConfig::<T>::remove(ext) {
95
+ self.0.replace(value);
96
+ }
97
+ self.as_ref()
98
+ }
99
+
100
+ /// Returns an immutable reference to the stored value from the given [`http::Extensions`], if
101
+ /// present.
102
+ ///
103
+ /// Internally fetches [`RequestConfig<T>`] and returns a reference to its inner value, if set.
104
+ #[inline]
105
+ pub(crate) fn get(ext: &Extensions) -> Option<&T::Value> {
106
+ ext.get::<RequestConfig<T>>()?.0.as_ref()
107
+ }
108
+
109
+ /// Returns a mutable reference to the inner value in [`http::Extensions`], inserting a default
110
+ /// if missing.
111
+ ///
112
+ /// This ensures a [`RequestConfig<T>`] exists and returns a mutable reference to its inner
113
+ /// `Option<T::Value>`.
114
+ #[inline]
115
+ pub(crate) fn get_mut(ext: &mut Extensions) -> &mut Option<T::Value> {
116
+ &mut ext.get_or_insert_default::<RequestConfig<T>>().0
117
+ }
118
+
119
+ /// Removes and returns the stored value from the given [`http::Extensions`], if present.
120
+ ///
121
+ /// This consumes the [`RequestConfig<T>`] entry and extracts its inner value.
122
+ #[inline]
123
+ pub(crate) fn remove(ext: &mut Extensions) -> Option<T::Value> {
124
+ ext.remove::<RequestConfig<T>>()?.0
125
+ }
126
+ }
127
+
128
+ /// Implements [`RequestConfigValue`] for a given type.
129
+ macro_rules! impl_request_config_value {
130
+ ($type:ty) => {
131
+ impl crate::config::RequestConfigValue for $type {
132
+ type Value = Self;
133
+ }
134
+ };
135
+ ($type:ty, $value:ty) => {
136
+ impl crate::config::RequestConfigValue for $type {
137
+ type Value = $value;
138
+ }
139
+ };
140
+ }