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
data/sig/options.rbs CHANGED
@@ -2,21 +2,25 @@ module HTTPX
2
2
  class Options
3
3
  # include _ToHash
4
4
 
5
+ BUFFER_SIZE: Integer
5
6
  WINDOW_SIZE: Integer
6
7
  MAX_BODY_THRESHOLD_SIZE: Integer
7
8
  CONNECT_TIMEOUT: Integer
9
+ READ_TIMEOUT: Integer
10
+ WRITE_TIMEOUT: Integer
11
+ REQUEST_TIMEOUT: Integer
8
12
  OPERATION_TIMEOUT: Integer
9
13
  KEEP_ALIVE_TIMEOUT: Integer
10
14
  SETTINGS_TIMEOUT: Integer
15
+ CLOSE_HANDSHAKE_TIMEOUT: Integer
11
16
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
17
+ REQUEST_BODY_IVARS: Array[Symbol]
12
18
 
13
- type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout
14
- type timeout = Hash[timeout_type, Numeric]
19
+ type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
20
+ type timeout = Hash[timeout_type, Numeric?]
15
21
 
16
22
  def self.new: (?options) -> instance
17
23
 
18
- def self.def_option: (Symbol, ?String) -> void
19
- | (Symbol) { (*nil) -> untyped } -> void
20
24
  # headers
21
25
  attr_reader uri: URI?
22
26
 
@@ -33,38 +37,38 @@ module HTTPX
33
37
  attr_reader max_concurrent_requests: Integer?
34
38
 
35
39
  # max_requests
36
- attr_reader max_requests: Integer?
40
+ attr_reader max_requests: Numeric?
37
41
 
38
42
  # window_size
39
43
  attr_reader window_size: Integer
40
44
 
45
+ # buffer_size
46
+ attr_reader buffer_size: Integer
47
+
41
48
  # body_threshold_size
42
49
  attr_reader body_threshold_size: Integer
43
50
 
44
51
  # transport
45
- attr_reader transport: String?
46
-
47
- # transport_options
48
- attr_reader transport_options: Hash[untyped, untyped]?
52
+ attr_reader transport: io_type | nil
49
53
 
50
54
  # addresses
51
55
  attr_reader addresses: Array[ipaddr]?
52
56
 
53
- # params
54
- attr_reader params: Transcoder::urlencoded_input?
57
+ # supported_compression_formats
58
+ attr_reader supported_compression_formats: Array[String]
55
59
 
56
- # form
57
- attr_reader form: Transcoder::urlencoded_input?
60
+ # compress_request_body
61
+ attr_reader compress_request_body: bool
58
62
 
59
- # json
60
- attr_reader json: _ToJson?
63
+ # decompress_response_body
64
+ attr_reader decompress_response_body: bool
61
65
 
62
- # body
63
- attr_reader body: bodyIO?
64
-
65
- # body
66
+ # origin
66
67
  attr_reader origin: URI::Generic?
67
68
 
69
+ # base_path
70
+ attr_reader base_path: String?
71
+
68
72
  # ssl
69
73
 
70
74
  # http2_settings
@@ -109,17 +113,23 @@ module HTTPX
109
113
  # ip_families
110
114
  attr_reader ip_families: Array[ip_family]
111
115
 
112
- def ==: (untyped other) -> bool
116
+ def ==: (Options other) -> bool
117
+
118
+ def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
119
+
113
120
  def merge: (_ToHash[Symbol, untyped] other) -> instance
121
+
114
122
  def to_hash: () -> Hash[Symbol, untyped]
115
123
 
124
+ def extend_with_plugin_classes: (Module pl) -> void
125
+
116
126
  private
117
127
 
118
128
  REQUEST_IVARS: Array[Symbol]
119
129
 
120
- def initialize: (?options options) -> untyped
130
+ def initialize: (?options options) -> void
121
131
 
122
- def __initialize__: (?options options) -> untyped
132
+ def do_initialize: (?options options) -> void
123
133
  end
124
134
 
125
135
  type options = Options | Hash[Symbol, untyped]
data/sig/parser/http1.rbs CHANGED
@@ -29,7 +29,7 @@ module HTTPX
29
29
  @_has_trailers: bool
30
30
  @upgrade: bool
31
31
 
32
- def <<: (String chunk) -> void
32
+ def <<: (string chunk) -> void
33
33
 
34
34
  def reset!: () -> void
35
35
 
@@ -5,8 +5,6 @@ module HTTPX
5
5
  @user: String
6
6
  @password: String
7
7
 
8
- def can_authenticate?: (String? authenticate) -> boolish
9
-
10
8
  def authenticate: (*untyped) -> String
11
9
 
12
10
  private
@@ -4,6 +4,7 @@ module HTTPX
4
4
  class Digest
5
5
  @user: String
6
6
  @password: String
7
+ @hashed: bool
7
8
 
8
9
  def can_authenticate?: (String? authenticate) -> boolish
9
10
 
@@ -13,7 +14,7 @@ module HTTPX
13
14
 
14
15
  def generate_header: (String meth, String uri, String authenticate) -> String
15
16
 
16
- def initialize: (string user, string password) -> void
17
+ def initialize: (string user, string password, ?hashed: bool, **untyped) -> void
17
18
 
18
19
  def make_cnonce: () -> String
19
20
 
@@ -0,0 +1,13 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Authorization
4
+ module InstanceMethods
5
+ def authorization: (string token) -> instance
6
+
7
+ def bearer_auth: (string token) -> instance
8
+ end
9
+ end
10
+
11
+ type sessionAuthorization = Session & Authorization::InstanceMethods
12
+ end
13
+ end
@@ -6,10 +6,10 @@ module HTTPX
6
6
  def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  module InstanceMethods
9
- def basic_authentication: (string user, string password) -> instance
9
+ def basic_auth: (string user, string password) -> instance
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuth = sessionAuthentication & Authentication::InstanceMethods & BasicAuth::InstanceMethods
13
+ type sessionBasicAuth = sessionAuthorization & BasicAuth::InstanceMethods
14
14
  end
15
15
  end
@@ -0,0 +1,22 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Brotli
4
+ def self?.load_dependencies: (singleton(Session)) -> void
5
+
6
+ def self?.encode: (body_encoder body) -> Deflater
7
+
8
+ def self?.decode: (HTTPX::Response response, ?bytesize: Integer) -> Transcoder::_Decoder
9
+
10
+ class Deflater < Transcoder::Deflater
11
+ end
12
+
13
+ module RequestBodyClassMethods
14
+ def initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
15
+ end
16
+
17
+ module ResponseBodyClassMethods
18
+ def initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> (Transcoder::_Decoder | Transcoder::GZIP::Inflater)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,38 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Callbacks
4
+ class CallbackError < Exception
5
+ end
6
+
7
+ module InstanceMethods
8
+ include HTTPX::Callbacks
9
+
10
+ type socket = TCPSocket | OpenSSL::SSL::SSLSocket | UNIXSocket
11
+
12
+ def on_connection_opened: () { (http_uri origin, socket sock) -> void } -> self
13
+
14
+ def on_connection_closed: () { (http_uri origin) -> void } -> self
15
+
16
+ def on_request_error: () { (Request request, StandardError error) -> void } -> self
17
+
18
+ def on_request_started: () { (Request request) -> void } -> self
19
+
20
+ def on_request_body_chunk: () { (Request request, String chunk) -> void } -> self
21
+
22
+ def on_request_completed: () { (Request request) -> void } -> self
23
+
24
+ def on_response_started: () { (Request request, Response response) -> void } -> self
25
+
26
+ def on_response_body_chunk: () { (Request request, Response response, String chunk) -> void } -> self
27
+
28
+ def on_response_completed: () { (Request request, response response) -> void } -> self
29
+
30
+ private
31
+
32
+ def emit_or_callback_error: (*untyped) -> void
33
+ end
34
+ end
35
+
36
+ type sessionCallbacks = Session & Callbacks::InstanceMethods
37
+ end
38
+ end
@@ -0,0 +1,71 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module CircuitBreaker
4
+
5
+ class CircuitStore
6
+ @circuits: Hash[String, Circuit]
7
+
8
+ @circuits_mutex: Thread::Mutex
9
+
10
+ def try_open: (uri uri, response response) -> response?
11
+
12
+ def try_respond: (Request request) -> response?
13
+
14
+ def try_close: (http_uri uri) -> void
15
+
16
+ private
17
+
18
+ def get_circuit_for_uri: (uri uri) -> Circuit
19
+
20
+ def initialize: (Options & _CircuitOptions options) -> void
21
+ end
22
+
23
+ class Circuit
24
+ @state: :closed | :open | :half_open
25
+ @max_attempts: Integer
26
+ @reset_attempts_in: Float
27
+ @break_in: Float
28
+ @circuit_breaker_half_open_drip_rate: Float
29
+ @attempts: Integer
30
+ @real_attempts: Integer
31
+ @drip_factor: Integer
32
+
33
+ @response: response?
34
+ @opened_at: Float?
35
+ @attempted_at: Float?
36
+
37
+ def respond: () -> response?
38
+
39
+ def try_open: (response) -> response?
40
+
41
+ def try_close: () -> void
42
+
43
+ private
44
+
45
+ def initialize: (Integer max_attempts, Float reset_attempts_in, Float break_in, Float circuit_breaker_half_open_drip_rate) -> void
46
+ end
47
+
48
+ interface _CircuitOptions
49
+ def circuit_breaker_max_attempts: () -> Integer
50
+ def circuit_breaker_reset_attempts_in: () -> Float
51
+ def circuit_breaker_break_in: () -> Float
52
+ def circuit_breaker_half_open_drip_rate: () -> Float
53
+ def circuit_breaker_break_on: () -> (^(Response) -> boolish | nil)
54
+ end
55
+
56
+ def self.load_dependencies: (singleton(Session)) -> void
57
+ def self.extra_options: (Options) -> (Options & _CircuitOptions)
58
+
59
+ module InstanceMethods
60
+ @circuit_store: CircuitStore
61
+
62
+ private
63
+
64
+ def try_circuit_open: (Request request, response response) -> response?
65
+ end
66
+
67
+ end
68
+
69
+ type sessionCircuitBreaker = Session & CircuitBreaker::InstanceMethods
70
+ end
71
+ end
@@ -1,7 +1,6 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Compression
4
- type encodings_registry = Registry[Symbol, Class]
5
4
 
6
5
  type deflatable = _Reader | _ToS
7
6
 
@@ -13,15 +12,18 @@ module HTTPX
13
12
  interface _Inflater
14
13
  def inflate: (string) -> String
15
14
 
16
- def initialize: (Numeric bytesize) -> untyped
15
+ def initialize: (Integer | Float bytesize) -> untyped
16
+ end
17
+
18
+ interface _Compressor
19
+ def deflater: () -> _Deflater
20
+ def inflater: (Integer | Float bytesize) -> _Inflater
17
21
  end
18
22
 
19
23
  def self.configure: (singleton(Session)) -> void
20
24
 
21
25
  interface _CompressionOptions
22
- def compression_threshold_size: () -> Integer?
23
-
24
- def encodings: () -> encodings_registry?
26
+ def encodings: () -> Hash[String, _Compressor]
25
27
  end
26
28
 
27
29
  def self.extra_options: (Options) -> (Options & _CompressionOptions)
@@ -13,8 +13,8 @@ module HTTPX
13
13
 
14
14
  def []: (uri) -> Array[Cookie]
15
15
 
16
- def each: (?uri) { (Cookie) -> void } -> void
17
- | (?uri) -> Enumerable[Cookie]
16
+ def each: (?uri?) { (Cookie) -> void } -> void
17
+ | (?uri?) -> Enumerable[Cookie]
18
18
 
19
19
  def merge: (_Each[cookie] cookies) -> instance
20
20
 
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  interface _CookieOptions
7
7
  def cookies: () -> Jar?
8
+
9
+ def merge_cookie_in_jar: (Array[String] cookies, Jar jar) -> void
8
10
  end
9
11
 
10
12
  def self.extra_options: (Options) -> (Options & _CookieOptions)
@@ -12,10 +12,10 @@ module HTTPX
12
12
  def self.load_dependencies: (*untyped) -> void
13
13
 
14
14
  module InstanceMethods
15
- def digest_authentication: (string user, string password) -> instance
15
+ def digest_auth: (string user, string password, ?hashed: bool) -> instance
16
16
  end
17
17
  end
18
18
 
19
- type sessionDigestAuth = sessionAuthentication & DigestAuth::InstanceMethods
19
+ type sessionDigestAuth = sessionAuthorization & DigestAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -5,11 +5,18 @@ module HTTPX
5
5
  module FollowRedirects
6
6
  MAX_REDIRECTS: Integer
7
7
  REDIRECT_STATUS: Range[Integer]
8
+ REQUEST_BODY_HEADERS: Array[String]
9
+
10
+ type redirect_request = Request & RequestMethods
8
11
 
9
12
  interface _FollowRedirectsOptions
10
13
  def max_redirects: () -> Integer?
11
14
 
12
15
  def follow_insecure_redirects: () -> bool?
16
+
17
+ def allow_auth_to_other_origins: () -> bool?
18
+
19
+ def redirect_on: () -> (^(http_uri) -> boolish | nil)
13
20
  end
14
21
 
15
22
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
@@ -17,13 +24,20 @@ module HTTPX
17
24
  module InstanceMethods
18
25
  def max_redirects: (_ToI) -> instance
19
26
 
20
- def build_redirect_request: (Request, Response, Options) -> Request
21
- def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
27
+ def handle_after_redirect_request: (http_uri original_uri, http_uri redirect_uri, Request request, Options & _FollowRedirectsOptions options) -> void
28
+
29
+ def __get_location_from_response: (Response) -> http_uri
22
30
  end
23
31
 
24
32
  module RequestMethods
25
- def redirect_request: () -> Request
26
- def redirect_request=: (Request) -> void
33
+ attr_accessor root_request: instance?
34
+
35
+ @redirect_request: redirect_request
36
+
37
+ def redirect_request: () -> redirect_request
38
+
39
+ def redirect_request=: (redirect_request req) -> void
40
+
27
41
  def max_redirects: () -> Integer
28
42
  end
29
43
  end
@@ -0,0 +1,19 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module GRPC
4
+ class Call
5
+ attr_writer decoder: _Callable
6
+
7
+ def metadata: () -> headers
8
+
9
+ def trailing_metadata: () -> headers?
10
+
11
+ private
12
+
13
+ def initialize: (Response | StreamResponse response) -> untyped
14
+
15
+ def grpc_response: () -> grpc_response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module GRPCEncoding
4
+
5
+ def self?.encode: (body_encoder body, compressed: bool) -> Deflater
6
+
7
+ def self?.decode: (Response | StreamResponse response) -> Inflater
8
+
9
+ class Deflater
10
+ attr_reader content_type: String
11
+
12
+ @body: BodyReader
13
+ @compressed: bool
14
+
15
+ def initialize: (body_encoder body, compressed: bool) -> void
16
+
17
+ def bytesize: () -> (Integer | Float)
18
+
19
+ def read: (?int? length, ?string outbuf) -> String?
20
+ end
21
+
22
+ class Inflater
23
+ @response: Response
24
+ @grpc_encodings: Array[String]
25
+
26
+ def initialize: (Response | StreamResponse response) -> void
27
+
28
+ def call: (String message) ?{ (String) -> void } -> String
29
+
30
+ private
31
+
32
+ def grpc_encodings: () -> Array[String]
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module HTTPX
3
+ module Plugins
4
+ module GRPC
5
+ module Message
6
+ def self?.unary: (response) -> grpc_message
7
+
8
+ def self?.stream: (StreamResponse) { (String) -> void } -> void
9
+ | (StreamResponse) -> Enumerable[String]
10
+
11
+ def self?.cancel: (Request) -> void
12
+
13
+ def self?.verify_status: (StreamResponse | response) -> void
14
+ end
15
+ end
16
+ end
17
+ end
data/sig/plugins/grpc.rbs CHANGED
@@ -7,6 +7,11 @@ module HTTPX
7
7
 
8
8
  module Plugins
9
9
  module GRPC
10
+ DEADLINE: Integer
11
+ MARSHAL_METHOD: Symbol
12
+ UNMARSHAL_METHOD: Symbol
13
+ HEADERS: Hash[String, String]
14
+
10
15
  type compression_option = bool | String
11
16
  type rpc_def = [String, untyped, untyped, Hash[Symbol, untyped]]
12
17
 
@@ -17,36 +22,6 @@ module HTTPX
17
22
 
18
23
  type credentials = Proc
19
24
 
20
- class Call
21
- attr_writer decoder: _Callable
22
-
23
- def metadata: () -> headers
24
-
25
- def trailing_metadata: () -> headers?
26
-
27
- private
28
-
29
- def initialize: (Response | StreamResponse response) -> untyped
30
-
31
- def grpc_response: () -> grpc_response
32
- end
33
-
34
- module Message
35
- def self?.unary: (response) -> grpc_message
36
-
37
- def self?.stream: (StreamResponse) { (String) -> void } -> void
38
- | (StreamResponse) -> Enumerable[String]
39
-
40
- def self?.encode: (String bytes, ?deflater: Compression::_Deflater?) -> String
41
-
42
- def self?.decode: (String message, encodings: Array[String], encoders: Compression::encodings_registry) -> String
43
- | (String message, encodings: Array[String], encoders: Compression::encodings_registry) { (String) -> void } -> void
44
-
45
- def self?.cancel: (Request) -> void
46
-
47
- def self?.verify_status: (StreamResponse | response) -> void
48
- end
49
-
50
25
  interface _GRPCOptions
51
26
  def grpc_service: () -> String?
52
27
 
@@ -63,9 +38,9 @@ module HTTPX
63
38
  def self.load_dependencies: (singleton(Session)) -> void
64
39
 
65
40
  module ResponseMethods
66
- def merge_headers: (headers_input trailers) -> void
41
+ attr_reader trailing_metadata: Hash[String, untyped]
67
42
 
68
- def encoders: () -> Compression::encodings_registry
43
+ def encoders: () -> Array[String | Encoding]
69
44
  end
70
45
 
71
46
  module InstanceMethods
data/sig/plugins/h2c.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module H2C
4
- VALID_H2C_VERBS: Array[Symbol]
4
+ VALID_H2C_VERBS: Array[verb]
5
5
 
6
6
  def self.load_dependencies: (*untyped) -> void
7
7
  def self.configure: (singleton(Session)) -> void
@@ -11,11 +11,11 @@ module HTTPX
11
11
  def self.load_dependencies: (*untyped) -> void
12
12
 
13
13
  module InstanceMethods
14
- def ntlm_authentication: (string user, string password, ?string? domain) -> instance
14
+ def ntlm_auth: (string user, string password, ?string? domain) -> instance
15
15
  end
16
16
 
17
17
  end
18
18
 
19
- type sessionNTLMAuth = sessionAuthentication & NTLMAuth::InstanceMethods
19
+ type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -0,0 +1,54 @@
1
+ module HTTPX
2
+ module Plugins
3
+ #
4
+ # https://gitlab.com/os85/httpx/wikis/OAuth
5
+ #
6
+ module OAuth
7
+ def self.load_dependencies: (singleton(Session) klass) -> void
8
+
9
+ type grant_type = "client_credentials" | "refresh_token"
10
+
11
+ type token_auth_method = "client_secret_basic" | "client_secret_post"
12
+
13
+ SUPPORTED_GRANT_TYPES: ::Array[grant_type]
14
+
15
+ SUPPORTED_AUTH_METHODS: ::Array[token_auth_method]
16
+
17
+ class OAuthSession
18
+ attr_reader grant_type: grant_type
19
+
20
+ attr_reader client_id: String
21
+
22
+ attr_reader client_secret: String
23
+
24
+ attr_reader access_token: String?
25
+
26
+ attr_reader refresh_token: String?
27
+
28
+ attr_reader scope: Array[String]?
29
+
30
+ def initialize: (issuer: uri, client_id: String, client_secret: String, ?access_token: String?, ?refresh_token: String?, ?scope: (Array[String] | String)?, ?token_endpoint: String?, ?response_type: String?, ?grant_type: String?, ?token_endpoint_auth_method: ::String) -> void
31
+
32
+ def token_endpoint: () -> String
33
+
34
+ def token_endpoint_auth_method: () -> token_auth_method
35
+
36
+ def load: (Session http) -> void
37
+
38
+ def merge: (instance | Hash[untyped, untyped] other) -> instance
39
+ end
40
+
41
+ interface _AwsSdkOptions
42
+ def oauth_session: () -> OAuthSession?
43
+ end
44
+
45
+ module InstanceMethods
46
+ def oauth_auth: (**untyped args) -> instance
47
+
48
+ def with_access_token: () -> instance
49
+ end
50
+ end
51
+
52
+ type sessionOAuth = Session & OAuth::InstanceMethods
53
+ end
54
+ end
@@ -16,6 +16,9 @@ module HTTPX
16
16
  def __http_on_connect: (top, Response) -> void
17
17
  end
18
18
 
19
+ class ConnectRequest < Request
20
+ def initialize: (generic_uri uri, Options options) -> void
21
+ end
19
22
  end
20
23
  end
21
24