httpx 0.20.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +0 -48
  3. data/README.md +54 -45
  4. data/doc/release_notes/0_10_0.md +2 -2
  5. data/doc/release_notes/0_11_0.md +3 -5
  6. data/doc/release_notes/0_12_0.md +5 -5
  7. data/doc/release_notes/0_13_0.md +5 -5
  8. data/doc/release_notes/0_14_0.md +2 -2
  9. data/doc/release_notes/0_16_0.md +3 -3
  10. data/doc/release_notes/0_17_0.md +1 -1
  11. data/doc/release_notes/0_18_0.md +4 -4
  12. data/doc/release_notes/0_18_2.md +1 -1
  13. data/doc/release_notes/0_19_0.md +1 -1
  14. data/doc/release_notes/0_19_8.md +1 -1
  15. data/doc/release_notes/0_20_0.md +2 -2
  16. data/doc/release_notes/0_20_1.md +5 -0
  17. data/doc/release_notes/0_20_2.md +7 -0
  18. data/doc/release_notes/0_20_3.md +6 -0
  19. data/doc/release_notes/0_20_4.md +17 -0
  20. data/doc/release_notes/0_20_5.md +3 -0
  21. data/doc/release_notes/0_21_0.md +96 -0
  22. data/doc/release_notes/0_21_1.md +12 -0
  23. data/doc/release_notes/0_22_0.md +13 -0
  24. data/doc/release_notes/0_22_1.md +11 -0
  25. data/doc/release_notes/0_22_2.md +5 -0
  26. data/doc/release_notes/0_22_3.md +55 -0
  27. data/doc/release_notes/0_22_4.md +6 -0
  28. data/doc/release_notes/0_22_5.md +6 -0
  29. data/doc/release_notes/0_23_0.md +42 -0
  30. data/doc/release_notes/0_23_1.md +5 -0
  31. data/doc/release_notes/0_23_2.md +5 -0
  32. data/doc/release_notes/0_23_3.md +6 -0
  33. data/doc/release_notes/0_23_4.md +5 -0
  34. data/doc/release_notes/0_24_0.md +48 -0
  35. data/doc/release_notes/0_24_1.md +12 -0
  36. data/doc/release_notes/0_24_2.md +12 -0
  37. data/doc/release_notes/0_24_3.md +12 -0
  38. data/doc/release_notes/0_24_4.md +18 -0
  39. data/doc/release_notes/0_24_5.md +6 -0
  40. data/doc/release_notes/0_24_6.md +5 -0
  41. data/doc/release_notes/0_24_7.md +10 -0
  42. data/doc/release_notes/1_0_0.md +60 -0
  43. data/doc/release_notes/1_0_1.md +5 -0
  44. data/doc/release_notes/1_0_2.md +7 -0
  45. data/doc/release_notes/1_1_0.md +32 -0
  46. data/doc/release_notes/1_1_1.md +17 -0
  47. data/doc/release_notes/1_1_2.md +12 -0
  48. data/doc/release_notes/1_1_3.md +18 -0
  49. data/doc/release_notes/1_1_4.md +6 -0
  50. data/doc/release_notes/1_1_5.md +12 -0
  51. data/doc/release_notes/1_2_0.md +49 -0
  52. data/doc/release_notes/1_2_1.md +6 -0
  53. data/doc/release_notes/1_2_2.md +10 -0
  54. data/doc/release_notes/1_2_3.md +16 -0
  55. data/doc/release_notes/1_2_4.md +8 -0
  56. data/doc/release_notes/1_2_5.md +7 -0
  57. data/doc/release_notes/1_2_6.md +13 -0
  58. data/doc/release_notes/1_3_0.md +18 -0
  59. data/doc/release_notes/1_3_1.md +17 -0
  60. data/lib/httpx/adapters/datadog.rb +215 -122
  61. data/lib/httpx/adapters/faraday.rb +145 -107
  62. data/lib/httpx/adapters/sentry.rb +26 -7
  63. data/lib/httpx/adapters/webmock.rb +34 -18
  64. data/lib/httpx/altsvc.rb +63 -26
  65. data/lib/httpx/base64.rb +27 -0
  66. data/lib/httpx/buffer.rb +12 -0
  67. data/lib/httpx/callbacks.rb +5 -3
  68. data/lib/httpx/chainable.rb +54 -39
  69. data/lib/httpx/connection/http1.rb +75 -44
  70. data/lib/httpx/connection/http2.rb +31 -38
  71. data/lib/httpx/connection.rb +287 -117
  72. data/lib/httpx/domain_name.rb +10 -13
  73. data/lib/httpx/errors.rb +52 -2
  74. data/lib/httpx/extensions.rb +24 -131
  75. data/lib/httpx/io/ssl.rb +83 -77
  76. data/lib/httpx/io/tcp.rb +48 -71
  77. data/lib/httpx/io/udp.rb +18 -52
  78. data/lib/httpx/io/unix.rb +10 -15
  79. data/lib/httpx/io.rb +3 -9
  80. data/lib/httpx/loggable.rb +4 -19
  81. data/lib/httpx/options.rb +176 -118
  82. data/lib/httpx/parser/http1.rb +4 -0
  83. data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
  84. data/lib/httpx/plugins/{authentication → auth}/digest.rb +14 -14
  85. data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
  86. data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
  87. data/lib/httpx/plugins/auth.rb +25 -0
  88. data/lib/httpx/plugins/aws_sdk_authentication.rb +4 -3
  89. data/lib/httpx/plugins/aws_sigv4.rb +12 -9
  90. data/lib/httpx/plugins/basic_auth.rb +29 -0
  91. data/lib/httpx/plugins/brotli.rb +50 -0
  92. data/lib/httpx/plugins/callbacks.rb +91 -0
  93. data/lib/httpx/plugins/circuit_breaker/circuit.rb +100 -0
  94. data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +53 -0
  95. data/lib/httpx/plugins/circuit_breaker.rb +148 -0
  96. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
  97. data/lib/httpx/plugins/cookies.rb +30 -17
  98. data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +14 -12
  99. data/lib/httpx/plugins/expect.rb +21 -14
  100. data/lib/httpx/plugins/follow_redirects.rb +140 -41
  101. data/lib/httpx/plugins/grpc/call.rb +2 -3
  102. data/lib/httpx/plugins/grpc/grpc_encoding.rb +88 -0
  103. data/lib/httpx/plugins/grpc/message.rb +7 -37
  104. data/lib/httpx/plugins/grpc.rb +36 -29
  105. data/lib/httpx/plugins/h2c.rb +26 -19
  106. data/lib/httpx/plugins/internal_telemetry.rb +16 -0
  107. data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +7 -5
  108. data/lib/httpx/plugins/oauth.rb +175 -0
  109. data/lib/httpx/plugins/persistent.rb +1 -1
  110. data/lib/httpx/plugins/proxy/http.rb +23 -13
  111. data/lib/httpx/plugins/proxy/socks4.rb +9 -7
  112. data/lib/httpx/plugins/proxy/socks5.rb +11 -9
  113. data/lib/httpx/plugins/proxy.rb +80 -61
  114. data/lib/httpx/plugins/push_promise.rb +1 -1
  115. data/lib/httpx/plugins/rate_limiter.rb +5 -1
  116. data/lib/httpx/plugins/response_cache/file_store.rb +40 -0
  117. data/lib/httpx/plugins/response_cache/store.rb +62 -25
  118. data/lib/httpx/plugins/response_cache.rb +105 -12
  119. data/lib/httpx/plugins/retries.rb +87 -17
  120. data/lib/httpx/plugins/ssrf_filter.rb +145 -0
  121. data/lib/httpx/plugins/stream.rb +27 -23
  122. data/lib/httpx/plugins/upgrade/h2.rb +4 -4
  123. data/lib/httpx/plugins/upgrade.rb +8 -10
  124. data/lib/httpx/plugins/webdav.rb +80 -0
  125. data/lib/httpx/pool/synch_pool.rb +93 -0
  126. data/lib/httpx/pool.rb +102 -27
  127. data/lib/httpx/punycode.rb +9 -291
  128. data/lib/httpx/request/body.rb +154 -0
  129. data/lib/httpx/request.rb +130 -146
  130. data/lib/httpx/resolver/https.rb +62 -27
  131. data/lib/httpx/resolver/multi.rb +9 -13
  132. data/lib/httpx/resolver/native.rb +192 -76
  133. data/lib/httpx/resolver/resolver.rb +34 -9
  134. data/lib/httpx/resolver/system.rb +16 -11
  135. data/lib/httpx/resolver.rb +38 -16
  136. data/lib/httpx/response/body.rb +242 -0
  137. data/lib/httpx/response/buffer.rb +96 -0
  138. data/lib/httpx/response.rb +159 -217
  139. data/lib/httpx/selector.rb +9 -4
  140. data/lib/httpx/session.rb +137 -89
  141. data/lib/httpx/session_extensions.rb +4 -1
  142. data/lib/httpx/timers.rb +34 -8
  143. data/lib/httpx/transcoder/body.rb +0 -2
  144. data/lib/httpx/transcoder/chunker.rb +0 -1
  145. data/lib/httpx/transcoder/deflate.rb +37 -0
  146. data/lib/httpx/transcoder/form.rb +52 -33
  147. data/lib/httpx/transcoder/gzip.rb +74 -0
  148. data/lib/httpx/transcoder/json.rb +21 -8
  149. data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
  150. data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +4 -4
  151. data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
  152. data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
  153. data/lib/httpx/transcoder/multipart.rb +17 -0
  154. data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
  155. data/lib/httpx/transcoder/utils/deflater.rb +72 -0
  156. data/lib/httpx/transcoder/utils/inflater.rb +19 -0
  157. data/lib/httpx/transcoder/xml.rb +52 -0
  158. data/lib/httpx/transcoder.rb +5 -6
  159. data/lib/httpx/utils.rb +36 -16
  160. data/lib/httpx/version.rb +1 -1
  161. data/lib/httpx.rb +12 -14
  162. data/sig/altsvc.rbs +33 -0
  163. data/sig/buffer.rbs +2 -1
  164. data/sig/callbacks.rbs +3 -3
  165. data/sig/chainable.rbs +11 -9
  166. data/sig/connection/http1.rbs +8 -7
  167. data/sig/connection/http2.rbs +19 -19
  168. data/sig/connection.rbs +64 -24
  169. data/sig/errors.rbs +22 -3
  170. data/sig/httpx.rbs +5 -4
  171. data/sig/io/ssl.rbs +27 -0
  172. data/sig/io/tcp.rbs +60 -0
  173. data/sig/io/udp.rbs +20 -0
  174. data/sig/io/unix.rbs +27 -0
  175. data/sig/io.rbs +6 -0
  176. data/sig/options.rbs +32 -22
  177. data/sig/parser/http1.rbs +1 -1
  178. data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
  179. data/sig/plugins/{authentication → auth}/digest.rbs +2 -1
  180. data/sig/plugins/auth.rbs +13 -0
  181. data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
  182. data/sig/plugins/brotli.rbs +22 -0
  183. data/sig/plugins/callbacks.rbs +38 -0
  184. data/sig/plugins/circuit_breaker.rbs +71 -0
  185. data/sig/plugins/compression.rbs +7 -5
  186. data/sig/plugins/cookies/jar.rbs +2 -2
  187. data/sig/plugins/cookies.rbs +2 -0
  188. data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
  189. data/sig/plugins/follow_redirects.rbs +18 -4
  190. data/sig/plugins/grpc/call.rbs +19 -0
  191. data/sig/plugins/grpc/grpc_encoding.rbs +37 -0
  192. data/sig/plugins/grpc/message.rbs +17 -0
  193. data/sig/plugins/grpc.rbs +7 -32
  194. data/sig/plugins/h2c.rbs +1 -1
  195. data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
  196. data/sig/plugins/oauth.rbs +54 -0
  197. data/sig/plugins/proxy/http.rbs +3 -0
  198. data/sig/plugins/proxy/socks4.rbs +9 -6
  199. data/sig/plugins/proxy/socks5.rbs +10 -6
  200. data/sig/plugins/proxy/ssh.rbs +1 -1
  201. data/sig/plugins/proxy.rbs +13 -5
  202. data/sig/plugins/push_promise.rbs +3 -3
  203. data/sig/plugins/rate_limiter.rbs +1 -1
  204. data/sig/plugins/response_cache.rbs +36 -7
  205. data/sig/plugins/retries.rbs +30 -8
  206. data/sig/plugins/stream.rbs +24 -17
  207. data/sig/plugins/upgrade.rbs +5 -3
  208. data/sig/pool.rbs +10 -7
  209. data/sig/request/body.rbs +38 -0
  210. data/sig/request.rbs +15 -24
  211. data/sig/resolver/https.rbs +8 -3
  212. data/sig/resolver/native.rbs +17 -4
  213. data/sig/resolver/resolver.rbs +8 -6
  214. data/sig/resolver/system.rbs +2 -0
  215. data/sig/resolver.rbs +9 -5
  216. data/sig/response/body.rbs +53 -0
  217. data/sig/response/buffer.rbs +24 -0
  218. data/sig/response.rbs +24 -39
  219. data/sig/selector.rbs +1 -1
  220. data/sig/session.rbs +29 -18
  221. data/sig/timers.rbs +18 -8
  222. data/sig/transcoder/body.rbs +4 -3
  223. data/sig/transcoder/deflate.rbs +11 -0
  224. data/sig/transcoder/form.rbs +5 -3
  225. data/sig/transcoder/gzip.rbs +24 -0
  226. data/sig/transcoder/json.rbs +8 -3
  227. data/sig/{plugins → transcoder}/multipart.rbs +15 -19
  228. data/sig/transcoder/utils/body_reader.rbs +15 -0
  229. data/sig/transcoder/utils/deflater.rbs +29 -0
  230. data/sig/transcoder/utils/inflater.rbs +12 -0
  231. data/sig/transcoder/xml.rbs +22 -0
  232. data/sig/transcoder.rbs +24 -9
  233. data/sig/utils.rbs +8 -2
  234. metadata +163 -41
  235. data/lib/httpx/plugins/authentication.rb +0 -20
  236. data/lib/httpx/plugins/basic_authentication.rb +0 -30
  237. data/lib/httpx/plugins/compression/brotli.rb +0 -54
  238. data/lib/httpx/plugins/compression/deflate.rb +0 -49
  239. data/lib/httpx/plugins/compression/gzip.rb +0 -88
  240. data/lib/httpx/plugins/compression.rb +0 -164
  241. data/lib/httpx/plugins/multipart/decoder.rb +0 -187
  242. data/lib/httpx/plugins/multipart.rb +0 -84
  243. data/lib/httpx/registry.rb +0 -85
  244. data/sig/plugins/authentication.rbs +0 -11
  245. data/sig/plugins/compression/brotli.rbs +0 -21
  246. data/sig/plugins/compression/deflate.rbs +0 -17
  247. data/sig/plugins/compression/gzip.rbs +0 -29
  248. data/sig/registry.rbs +0 -12
  249. /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
  250. /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
@@ -1,20 +1,23 @@
1
1
  module HTTPX
2
- Socks4Error: singleton(Error)
2
+ class Socks4Error < HTTPProxyError
3
+ end
3
4
 
4
5
  module Plugins
5
6
  module Proxy
6
7
  module Socks4
7
-
8
+
8
9
  module ConnectionMethods
9
10
  def __socks4_proxy_connect: () -> void
10
11
  def __socks4_on_packet: (String packet) -> void
11
12
  def on_socks4_error: (string) -> void
12
13
  end
13
-
14
+
14
15
  class SocksParser
15
- include Callbacks
16
+ include HTTPX::Callbacks
17
+
18
+ @buffer: Buffer
19
+ @options: Options
16
20
 
17
- def timeout: () -> Integer
18
21
  def close: () -> void
19
22
  def consume: (*untyped) -> void
20
23
  def empty: () -> bool
@@ -22,7 +25,7 @@ module HTTPX
22
25
 
23
26
  private
24
27
 
25
- def initialize: (Buffer buffer, Options) -> untyped
28
+ def initialize: (Buffer buffer, Options options) -> untyped
26
29
  end
27
30
 
28
31
  module Packet
@@ -1,21 +1,25 @@
1
1
  module HTTPX
2
- Socks5Error: singleton(Error)
2
+ class Socks5Error < HTTPProxyError
3
+ end
3
4
 
4
5
  module Plugins
5
6
  module Proxy
6
7
  module Socks5
7
-
8
+ VERSION: Integer
9
+
8
10
  module ConnectionMethods
9
11
  def __socks5_proxy_connect: () -> void
10
12
  def __socks5_on_packet: (String packet) -> void
11
13
  def __socks5_check_version: (int) -> void
12
14
  def __on_socks5_error: (string) -> void
13
15
  end
14
-
16
+
15
17
  class SocksParser
16
- include Callbacks
18
+ include HTTPX::Callbacks
19
+
20
+ @buffer: Buffer
21
+ @options: Options
17
22
 
18
- def timeout: () -> Integer
19
23
  def close: () -> void
20
24
  def consume: (*untyped) -> void
21
25
  def empty: () -> bool
@@ -23,7 +27,7 @@ module HTTPX
23
27
 
24
28
  private
25
29
 
26
- def initialize: (Buffer buffer, Options) -> untyped
30
+ def initialize: (Buffer buffer, Options options) -> untyped
27
31
  end
28
32
 
29
33
  module Packet
@@ -7,7 +7,7 @@ module HTTPX
7
7
  module InstanceMethods
8
8
  private
9
9
 
10
- def build_gateway_socket: (int, URI::HTTP | URI::HTTPS, Options) -> _ToIO
10
+ def build_gateway_socket: (int, http_uri, Options) -> _ToIO
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,8 @@
1
1
  module HTTPX
2
- class HTTPProxyError < Error
2
+ class HTTPProxyError < ConnectionError
3
+ end
4
+
5
+ class ProxySSL < SSL
3
6
  end
4
7
 
5
8
  module Plugins
@@ -21,7 +24,7 @@ module HTTPX
21
24
 
22
25
  private
23
26
 
24
- def initialize: (uri: generic_uri, ?scheme: String, ?username: String, ?password: String, **extra) -> untyped
27
+ def initialize: (uri: generic_uri, ?scheme: String, ?username: String, ?password: String, **untyped) -> untyped
25
28
  end
26
29
 
27
30
  def self.configure: (singleton(Session)) -> void
@@ -35,11 +38,16 @@ module HTTPX
35
38
  def self.extra_options: (Options) -> (Options & _ProxyOptions)
36
39
 
37
40
  module InstanceMethods
41
+ @__proxy_uris: Array[generic_uri]
42
+
38
43
  private
39
44
 
40
- def proxy_uris: (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri, username: String, password: String }
41
- | (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri }
42
- | (generic_uri, Options & _ProxyOptions) -> nil
45
+ def proxy_error?: (Request request, response) -> bool
46
+
47
+ def proxy_options: (http_uri request_uri, Options & _ProxyOptions options) -> (Options & _ProxyOptions)
48
+ end
49
+
50
+ module ConnectionMethods
43
51
  end
44
52
  end
45
53
 
@@ -9,9 +9,9 @@ module HTTPX
9
9
  module InstanceMethods
10
10
  private
11
11
 
12
- def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
13
- def __on_promise_request: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
14
- def __on_promise_response: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
12
+ def promise_headers: () -> Hash[::HTTP2::Stream, Request]
13
+ def __on_promise_request: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
14
+ def __on_promise_response: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
15
15
  end
16
16
  end
17
17
 
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.retry_on_rate_limited_response: (_Response) -> bool
7
7
 
8
- def self.retry_after_rate_limit: (untyped, _Response) -> Numeric?
8
+ def self.retry_after_rate_limit: (untyped, response) -> Numeric?
9
9
  end
10
10
  end
11
11
  end
@@ -1,22 +1,33 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module ResponseCache
4
- CACHEABLE_VERBS: Array[Symbol]
4
+ CACHEABLE_VERBS: Array[verb]
5
+ CACHEABLE_STATUS_CODES: Array[Integer]
5
6
 
6
- def self?.cacheable_request?: (Request request) -> bool
7
- def self?.cacheable_response?: (response response) -> bool
7
+ def self?.cacheable_request?: (Request & RequestMethods request) -> bool
8
+ def self?.cacheable_response?: (::HTTPX::ErrorResponse | (Response & ResponseMethods) response) -> bool
8
9
  def self?.cached_response?: (response response) -> bool
9
10
 
10
11
  class Store
11
- @store: Hash[URI::Generic, Response]
12
+ @store: Hash[String, Array[Response]]
12
13
 
13
- def lookup: (URI::Generic uri) -> Response?
14
+ @store_mutex: Thread::Mutex
14
15
 
15
- def cached?: (URI::Generic uri) -> bool
16
+ def lookup: (Request request) -> Response?
16
17
 
17
- def cache: (URI::Generic uri, Response response) -> void
18
+ def cached?: (Request request) -> boolish
19
+
20
+ def cache: (Request request, Response response) -> void
18
21
 
19
22
  def prepare: (Request request) -> void
23
+
24
+ private
25
+
26
+ def match_by_vary?: (Request request, Response response) -> bool
27
+
28
+ def _get: (Request request) -> Array[Response]?
29
+
30
+ def _set: (Request request, Response response) -> void
20
31
  end
21
32
 
22
33
  module InstanceMethods
@@ -25,8 +36,26 @@ module HTTPX
25
36
  def clear_response_cache: () -> void
26
37
  end
27
38
 
39
+ module RequestMethods
40
+ @response_cache_key: String
41
+
42
+ def response_cache_key: () -> String
43
+ end
44
+
28
45
  module ResponseMethods
29
46
  def copy_from_cached: (Response other) -> void
47
+
48
+ def fresh?: () -> bool
49
+
50
+ def cache_control: () -> Array[String]?
51
+
52
+ def vary: () -> Array[String]?
53
+
54
+ private
55
+
56
+ def age: () -> Integer
57
+
58
+ def date: () -> Time
30
59
  end
31
60
  end
32
61
 
@@ -2,40 +2,62 @@ module HTTPX
2
2
  module Plugins
3
3
  module Retries
4
4
  MAX_RETRIES: Integer
5
- IDEMPOTENT_METHODS: Array[verb]
5
+ IDEMPOTENT_METHODS: Array[String]
6
6
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
7
7
  DEFAULT_JITTER: ^(Numeric) -> Numeric
8
8
 
9
9
  interface _RetryCallback
10
- def call: (response) -> bool?
10
+ def call: (response response) -> bool?
11
11
  end
12
12
 
13
13
  interface _RetriesOptions
14
14
  def retry_after: () -> Numeric?
15
15
 
16
- def retry_jitter: () -> ^(Numeric) -> Numeric
16
+ def retry_jitter: () -> ^(Numeric jitter) -> Numeric
17
17
 
18
- def max_retries: () -> Integer?
18
+ def max_retries: () -> Integer
19
19
 
20
20
  def retry_change_requests: () -> boolish
21
21
 
22
22
  def retry_on: () -> _RetryCallback?
23
23
  end
24
24
 
25
- def self.extra_options: (Options) -> (Options & _RetriesOptions)
25
+ def self.extra_options: (Options options) -> retriesOptions
26
26
 
27
27
  module InstanceMethods
28
28
  def max_retries: (int) -> instance
29
29
 
30
30
  private
31
31
 
32
- def __repeatable_request?: (Request, Options) -> boolish
33
- def __retryable_error?: (_Exception) -> bool
32
+ def fetch_response: (retriesRequest request, Array[Connection] connections, retriesOptions options) -> (retriesResponse | ErrorResponse)?
33
+
34
+ def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
35
+
36
+ def __retryable_error?: (_Exception error) -> bool
37
+
38
+ def __try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
39
+
34
40
  end
35
41
 
36
42
  module RequestMethods
37
- def retries: () -> Integer
43
+ @options: Options & _RetriesOptions
44
+
45
+ attr_accessor retries: Integer
46
+
47
+ attr_writer partial_response: Response?
48
+
49
+ def response=: (retriesResponse | ErrorResponse response) -> void
50
+ end
51
+
52
+ module ResponseMethods
53
+ def from_partial_response: (Response response) -> void
38
54
  end
55
+
56
+ type retriesOptions = Options & _RetriesOptions
57
+
58
+ type retriesRequest = Request & RequestMethods
59
+
60
+ type retriesResponse = Response & ResponseMethods
39
61
  end
40
62
 
41
63
  type sessionRetries = Session & Retries::InstanceMethods
@@ -1,21 +1,4 @@
1
1
  module HTTPX
2
- class StreamResponse
3
- include _ToS
4
-
5
- def each: () { (String) -> void } -> void
6
- | () -> Enumerable[String]
7
-
8
- def each_line: () { (String) -> void } -> void
9
- | () -> Enumerable[String]
10
-
11
- def on_chunk: (string) -> void
12
-
13
- private
14
-
15
- def response: () -> response
16
- def initialize: (Request, Session, Array[Connection]) -> untyped
17
- end
18
-
19
2
  module Plugins
20
3
  module Stream
21
4
  module InstanceMethods
@@ -37,4 +20,28 @@ module HTTPX
37
20
 
38
21
  type sessionStream = Session & Stream::InstanceMethods
39
22
  end
23
+
24
+ class StreamResponse
25
+ include _ToS
26
+
27
+ type streamRequest = Request & Plugins::Stream::RequestMethods
28
+
29
+ @request: streamRequest
30
+ @session: Plugins::sessionStream
31
+ @on_chunk: ^(String) -> void | nil
32
+
33
+ def each: () { (String) -> void } -> void
34
+ | () -> Enumerable[String]
35
+
36
+ def each_line: () { (String) -> void } -> void
37
+ | () -> Enumerable[String]
38
+
39
+ def on_chunk: (string) -> void
40
+
41
+ def initialize: (streamRequest, Plugins::sessionStream) -> void
42
+
43
+ private
44
+
45
+ def response: () -> response
46
+ end
40
47
  end
@@ -1,18 +1,20 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Upgrade
4
- type handlers_registry = Registry[Symbol, Class]
4
+ interface _Upgrader
5
+ def call: (Connection connection, Request request, Response response) -> void
6
+ end
5
7
 
6
8
  def self.configure: (singleton(Session)) -> void
7
9
 
8
10
  interface _UpgradeOptions
9
- def upgrade_handlers: () -> handlers_registry?
11
+ def upgrade_handlers: () -> Hash[String, _Upgrader]
10
12
  end
11
13
 
12
14
  def self.extra_options: (Options) -> (Options & _UpgradeOptions)
13
15
 
14
16
  module ConnectionMethods
15
- attr_reader upgrade_protocol: Symbol?
17
+ attr_reader upgrade_protocol: String?
16
18
  attr_reader hijacked: boolish
17
19
 
18
20
  def hijack_io: () -> void
data/sig/pool.rbs CHANGED
@@ -6,7 +6,8 @@ module HTTPX
6
6
  @timers: Timers
7
7
  @selector: Selector
8
8
  @connections: Array[Connection]
9
- @connected_connections: Integer
9
+
10
+ def wrap: () { (instance) -> void } -> void
10
11
 
11
12
  def empty?: () -> void
12
13
 
@@ -18,11 +19,13 @@ module HTTPX
18
19
 
19
20
  def find_connection: (URI::Generic uri, Options options) -> Connection?
20
21
 
21
- def deactivate: (*Array[Connection]) -> void
22
+ def deactivate: (*Connection connections) -> void
22
23
 
23
24
  private
24
25
 
25
- def initialize: () -> untyped
26
+ def initialize: () -> void
27
+
28
+ def try_clone_connection: (Connection connection, Integer? family) -> Connection
26
29
 
27
30
  def resolve_connection: (Connection) -> void
28
31
 
@@ -34,15 +37,15 @@ module HTTPX
34
37
 
35
38
  def register_connection: (Connection) -> void
36
39
 
37
- def unregister_connection: (Connection) -> void
40
+ def unregister_connection: (Connection, ?bool cleanup) -> void
38
41
 
39
- def select_connection: (Resolver::Resolver | Connection connection) -> void
42
+ def select_connection: (Selector::selectable) -> void
40
43
 
41
- def deselect_connection: (Resolver::Resolver | Connection connection) -> void
44
+ def deselect_connection: (Selector::selectable) -> Selector::selectable?
42
45
 
43
46
  def coalesce_connections: (Connection coalescable, Connection coalescing) -> void
44
47
 
45
- def next_timeout: () -> (Integer | Float | nil)
48
+ def next_timeout: () -> Numeric?
46
49
 
47
50
  def find_resolver_for: (Connection) { (Resolver::Resolver resolver) -> void } -> resolver_manager
48
51
  end
@@ -0,0 +1,38 @@
1
+ module HTTPX
2
+ class Request::Body
3
+ @headers: Headers
4
+ @body: body_encoder?
5
+ @unbounded_body: bool
6
+
7
+ def initialize: (Headers headers, Options options, ?body: bodyIO, ?form: Transcoder::urlencoded_input?, ?json: _ToJson?, **untyped) -> void
8
+
9
+ def each: () { (String) -> void } -> void
10
+ | () -> Enumerable[String]
11
+
12
+ def rewind: () -> void
13
+
14
+ def empty?: () -> bool
15
+
16
+ def bytesize: () -> (Integer | Float)
17
+
18
+ def stream: (Transcoder::_Encoder) -> bodyIO
19
+
20
+ def unbounded_body?: () -> bool
21
+
22
+ def chunked?: () -> bool
23
+
24
+ def chunk!: () -> void
25
+
26
+ private
27
+
28
+ def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
29
+ end
30
+
31
+ class ProcIO
32
+ @block: ^(String) -> void
33
+
34
+ def initialize: (^(String) -> void) -> untyped
35
+
36
+ def write: (String data) -> Integer
37
+ end
38
+ end
data/sig/request.rbs CHANGED
@@ -6,8 +6,8 @@ module HTTPX
6
6
  METHODS: Array[Symbol]
7
7
  USER_AGENT: String
8
8
 
9
- attr_reader verb: Symbol
10
- attr_reader uri: URI::Generic
9
+ attr_reader verb: verb
10
+ attr_reader uri: http_uri
11
11
  attr_reader headers: Headers
12
12
  attr_reader body: Body
13
13
  attr_reader state: Symbol
@@ -15,12 +15,17 @@ module HTTPX
15
15
  attr_reader response: response?
16
16
  attr_reader drain_error: StandardError?
17
17
 
18
+ attr_accessor peer_address: ipaddr?
19
+
20
+ attr_writer persistent: bool
21
+
22
+ @query_params: Hash[interned, untyped]?
18
23
  @trailers: Headers?
19
24
  @informational_status: Integer?
20
25
  @query: String?
21
26
  @drainer: Enumerator[String, void]?
22
27
 
23
- def initialize: (Symbol | String, generic_uri, ?options) -> untyped
28
+ def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
24
29
 
25
30
  def interests: () -> (:r | :w)
26
31
 
@@ -50,31 +55,17 @@ module HTTPX
50
55
 
51
56
  def trailers?: () -> boolish
52
57
 
53
- class Body
54
- @headers: Headers
55
- @body: body_encoder?
56
- @unbounded_body: bool
58
+ def persistent?: () -> bool
59
+
60
+ def read_timeout: () -> Numeric?
57
61
 
58
- def initialize: (Headers, Options) -> untyped
59
- def each: () { (String) -> void } -> void
60
- | () -> Enumerable[String]
62
+ def write_timeout: () -> Numeric?
61
63
 
62
- def rewind: () -> void
63
- def empty?: () -> bool
64
- def bytesize: () -> Numeric
65
- def stream: (Transcoder::_Encoder) -> bodyIO
66
- def unbounded_body?: () -> bool
67
- def chunked?: () -> bool
68
- def chunk!: () -> void
69
- def inspect: () -> String
70
- end
64
+ def request_timeout: () -> Numeric?
71
65
 
72
- class ProcIO
73
- @block: ^(String) -> void
66
+ private
74
67
 
75
- def initialize: (^(String) -> void) -> untyped
68
+ def initialize_body: (Options options) -> Transcoder::_Encoder?
76
69
 
77
- def write: (String data) -> Integer
78
- end
79
70
  end
80
71
  end
@@ -6,11 +6,12 @@ module HTTPX
6
6
  DEFAULTS: Hash[Symbol, untyped]
7
7
  FAMILY_TYPES: Hash[singleton(Resolv::DNS::Resource), String]
8
8
 
9
- @family: ip_family
9
+ attr_reader family: ip_family
10
+
10
11
  @options: Options
11
12
  @requests: Hash[Request, String]
12
13
  @connections: Array[Connection]
13
- @uri: URI::Generic
14
+ @uri: http_uri
14
15
  @uri_addresses: Array[String]?
15
16
  @resolver: Resolv::DNS
16
17
  @resolver_connection: Connection
@@ -31,9 +32,13 @@ module HTTPX
31
32
 
32
33
  def parse: (Request request, Response response) -> void
33
34
 
35
+ def parse_addresses: (Array[dns_result] answers, Request request) -> void
36
+
34
37
  def build_request: (String hostname) -> Request
35
38
 
36
- def decode_response_body: (Response) -> Array[dns_result]
39
+ def decode_response_body: (Response) -> dns_decoding_response
40
+
41
+ def reset_hostname: (String hostname, ?reset_candidates: bool) -> Connection?
37
42
  end
38
43
  end
39
44
  end
@@ -7,15 +7,22 @@ module HTTPX
7
7
  DEFAULTS: Hash[Symbol, untyped]
8
8
  DNS_PORT: Integer
9
9
 
10
- @family: ip_family
10
+ attr_reader family: ip_family
11
+
11
12
  @options: Options
12
13
  @ns_index: Integer
13
- @nameserver: String
14
+ @nameserver: Array[String]
15
+ @socket_type: :udp | :tcp
16
+ @ndots: Integer
17
+ @start_timeout: Float?
18
+ @search: Array[String]
14
19
  @_timeouts: Array[Numeric]
15
20
  @timeouts: Hash[String, Array[Numeric]]
16
21
  @connections: Array[Connection]
17
22
  @read_buffer: String
18
23
  @write_buffer: Buffer
24
+ @large_packet: Buffer?
25
+ @io: UDP | TCP
19
26
 
20
27
  attr_reader state: Symbol
21
28
 
@@ -27,6 +34,8 @@ module HTTPX
27
34
 
28
35
  def timeout: () -> Numeric?
29
36
 
37
+ def handle_socket_timeout: (Numeric interval) -> void
38
+
30
39
  private
31
40
 
32
41
  def initialize: (ip_family family, options options) -> void
@@ -35,7 +44,7 @@ module HTTPX
35
44
 
36
45
  def consume: () -> void
37
46
 
38
- def do_retry: () -> void
47
+ def do_retry: (?Numeric? loop_time) -> void
39
48
 
40
49
  def dread: (Integer) -> void
41
50
  | () -> void
@@ -48,11 +57,15 @@ module HTTPX
48
57
 
49
58
  def generate_candidates: (String) -> Array[String]
50
59
 
51
- def build_socket: () -> void
60
+ def build_socket: () -> (UDP | TCP)
61
+
62
+ def downgrade_socket: () -> void
52
63
 
53
64
  def transition: (Symbol nextstate) -> void
54
65
 
55
66
  def handle_error: (NativeResolveError | StandardError) -> void
67
+
68
+ def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
56
69
  end
57
70
  end
58
71
  end
@@ -6,8 +6,6 @@ module HTTPX
6
6
 
7
7
  RECORD_TYPES: Hash[Integer, singleton(Resolv::DNS::Resource)]
8
8
 
9
- attr_reader family: ip_family
10
-
11
9
  @record_type: singleton(Resolv::DNS::Resource)
12
10
  @options: Options
13
11
  @resolver_options: Hash[Symbol, untyped]
@@ -16,21 +14,25 @@ module HTTPX
16
14
 
17
15
  def close: () -> void
18
16
 
17
+ alias terminate close
18
+
19
19
  def closed?: () -> bool
20
20
 
21
21
  def empty?: () -> bool
22
22
 
23
- def emit_addresses: (Connection connection, ip_family family, Array[IPAddr]) -> void
23
+ def emit_addresses: (Connection connection, ip_family family, Array[IPAddr], ?bool early_resolve) -> void
24
24
 
25
25
  private
26
26
 
27
- def initialize: (ip_family? family, options options) -> void
27
+ def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
28
+
29
+ def initialize: (ip_family? family, Options options) -> void
28
30
 
29
- def early_resolve: (Connection connection, ?hostname: String) -> void
31
+ def early_resolve: (Connection connection, ?hostname: String) -> boolish
30
32
 
31
33
  def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
32
34
 
33
- def resolve_error: (String hostname, ?StandardError?) -> ResolveError
35
+ def resolve_error: (String hostname, ?StandardError?) -> (ResolveError | ResolveTimeoutError)
34
36
  end
35
37
  end
36
38
  end
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  @resolver: Resolv::DNS
7
7
 
8
+ attr_reader family: nil
9
+
8
10
  def <<: (Connection) -> void
9
11
 
10
12
  private