httpx 0.21.0 → 1.2.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 (229) 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 +4 -4
  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_20_0.md +1 -1
  15. data/doc/release_notes/0_21_0.md +7 -5
  16. data/doc/release_notes/0_21_1.md +12 -0
  17. data/doc/release_notes/0_22_0.md +13 -0
  18. data/doc/release_notes/0_22_1.md +11 -0
  19. data/doc/release_notes/0_22_2.md +5 -0
  20. data/doc/release_notes/0_22_3.md +55 -0
  21. data/doc/release_notes/0_22_4.md +6 -0
  22. data/doc/release_notes/0_22_5.md +6 -0
  23. data/doc/release_notes/0_23_0.md +42 -0
  24. data/doc/release_notes/0_23_1.md +5 -0
  25. data/doc/release_notes/0_23_2.md +5 -0
  26. data/doc/release_notes/0_23_3.md +6 -0
  27. data/doc/release_notes/0_23_4.md +5 -0
  28. data/doc/release_notes/0_24_0.md +48 -0
  29. data/doc/release_notes/0_24_1.md +12 -0
  30. data/doc/release_notes/0_24_2.md +12 -0
  31. data/doc/release_notes/0_24_3.md +12 -0
  32. data/doc/release_notes/0_24_4.md +18 -0
  33. data/doc/release_notes/0_24_5.md +6 -0
  34. data/doc/release_notes/0_24_6.md +5 -0
  35. data/doc/release_notes/0_24_7.md +10 -0
  36. data/doc/release_notes/1_0_0.md +60 -0
  37. data/doc/release_notes/1_0_1.md +5 -0
  38. data/doc/release_notes/1_0_2.md +7 -0
  39. data/doc/release_notes/1_1_0.md +32 -0
  40. data/doc/release_notes/1_1_1.md +17 -0
  41. data/doc/release_notes/1_1_2.md +12 -0
  42. data/doc/release_notes/1_1_3.md +18 -0
  43. data/doc/release_notes/1_1_4.md +6 -0
  44. data/doc/release_notes/1_1_5.md +12 -0
  45. data/doc/release_notes/1_2_0.md +49 -0
  46. data/doc/release_notes/1_2_1.md +6 -0
  47. data/lib/httpx/adapters/datadog.rb +100 -106
  48. data/lib/httpx/adapters/faraday.rb +143 -107
  49. data/lib/httpx/adapters/sentry.rb +26 -7
  50. data/lib/httpx/adapters/webmock.rb +33 -17
  51. data/lib/httpx/altsvc.rb +61 -24
  52. data/lib/httpx/base64.rb +27 -0
  53. data/lib/httpx/buffer.rb +12 -0
  54. data/lib/httpx/callbacks.rb +5 -3
  55. data/lib/httpx/chainable.rb +54 -39
  56. data/lib/httpx/connection/http1.rb +62 -37
  57. data/lib/httpx/connection/http2.rb +16 -27
  58. data/lib/httpx/connection.rb +213 -120
  59. data/lib/httpx/domain_name.rb +10 -13
  60. data/lib/httpx/errors.rb +34 -2
  61. data/lib/httpx/extensions.rb +4 -134
  62. data/lib/httpx/io/ssl.rb +77 -71
  63. data/lib/httpx/io/tcp.rb +46 -70
  64. data/lib/httpx/io/udp.rb +18 -52
  65. data/lib/httpx/io/unix.rb +6 -13
  66. data/lib/httpx/io.rb +3 -9
  67. data/lib/httpx/loggable.rb +4 -19
  68. data/lib/httpx/options.rb +168 -110
  69. data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
  70. data/lib/httpx/plugins/{authentication → auth}/digest.rb +13 -14
  71. data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
  72. data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
  73. data/lib/httpx/plugins/auth.rb +25 -0
  74. data/lib/httpx/plugins/aws_sdk_authentication.rb +1 -3
  75. data/lib/httpx/plugins/aws_sigv4.rb +5 -6
  76. data/lib/httpx/plugins/basic_auth.rb +29 -0
  77. data/lib/httpx/plugins/brotli.rb +50 -0
  78. data/lib/httpx/plugins/callbacks.rb +91 -0
  79. data/lib/httpx/plugins/circuit_breaker/circuit.rb +40 -16
  80. data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +14 -5
  81. data/lib/httpx/plugins/circuit_breaker.rb +30 -7
  82. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
  83. data/lib/httpx/plugins/cookies.rb +20 -10
  84. data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +11 -12
  85. data/lib/httpx/plugins/expect.rb +15 -13
  86. data/lib/httpx/plugins/follow_redirects.rb +71 -29
  87. data/lib/httpx/plugins/grpc/call.rb +2 -3
  88. data/lib/httpx/plugins/grpc/grpc_encoding.rb +88 -0
  89. data/lib/httpx/plugins/grpc/message.rb +7 -37
  90. data/lib/httpx/plugins/grpc.rb +35 -29
  91. data/lib/httpx/plugins/h2c.rb +25 -18
  92. data/lib/httpx/plugins/internal_telemetry.rb +16 -0
  93. data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +7 -5
  94. data/lib/httpx/plugins/oauth.rb +170 -0
  95. data/lib/httpx/plugins/persistent.rb +1 -1
  96. data/lib/httpx/plugins/proxy/http.rb +15 -10
  97. data/lib/httpx/plugins/proxy/socks4.rb +8 -6
  98. data/lib/httpx/plugins/proxy/socks5.rb +10 -8
  99. data/lib/httpx/plugins/proxy.rb +69 -67
  100. data/lib/httpx/plugins/push_promise.rb +1 -1
  101. data/lib/httpx/plugins/rate_limiter.rb +3 -1
  102. data/lib/httpx/plugins/response_cache/file_store.rb +40 -0
  103. data/lib/httpx/plugins/response_cache/store.rb +34 -17
  104. data/lib/httpx/plugins/response_cache.rb +6 -6
  105. data/lib/httpx/plugins/retries.rb +61 -12
  106. data/lib/httpx/plugins/ssrf_filter.rb +142 -0
  107. data/lib/httpx/plugins/stream.rb +27 -32
  108. data/lib/httpx/plugins/upgrade/h2.rb +4 -4
  109. data/lib/httpx/plugins/upgrade.rb +8 -10
  110. data/lib/httpx/plugins/webdav.rb +10 -8
  111. data/lib/httpx/pool.rb +85 -23
  112. data/lib/httpx/punycode.rb +9 -291
  113. data/lib/httpx/request/body.rb +158 -0
  114. data/lib/httpx/request.rb +86 -121
  115. data/lib/httpx/resolver/https.rb +54 -17
  116. data/lib/httpx/resolver/multi.rb +8 -12
  117. data/lib/httpx/resolver/native.rb +163 -70
  118. data/lib/httpx/resolver/resolver.rb +28 -13
  119. data/lib/httpx/resolver/system.rb +15 -10
  120. data/lib/httpx/resolver.rb +38 -16
  121. data/lib/httpx/response/body.rb +242 -0
  122. data/lib/httpx/response/buffer.rb +96 -0
  123. data/lib/httpx/response.rb +113 -211
  124. data/lib/httpx/selector.rb +2 -4
  125. data/lib/httpx/session.rb +91 -64
  126. data/lib/httpx/session_extensions.rb +4 -1
  127. data/lib/httpx/timers.rb +28 -8
  128. data/lib/httpx/transcoder/body.rb +0 -2
  129. data/lib/httpx/transcoder/chunker.rb +0 -1
  130. data/lib/httpx/transcoder/deflate.rb +37 -0
  131. data/lib/httpx/transcoder/form.rb +52 -33
  132. data/lib/httpx/transcoder/gzip.rb +74 -0
  133. data/lib/httpx/transcoder/json.rb +2 -5
  134. data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
  135. data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +3 -3
  136. data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
  137. data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
  138. data/lib/httpx/transcoder/multipart.rb +17 -0
  139. data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
  140. data/lib/httpx/transcoder/utils/deflater.rb +72 -0
  141. data/lib/httpx/transcoder/utils/inflater.rb +19 -0
  142. data/lib/httpx/transcoder/xml.rb +0 -5
  143. data/lib/httpx/transcoder.rb +4 -6
  144. data/lib/httpx/utils.rb +36 -16
  145. data/lib/httpx/version.rb +1 -1
  146. data/lib/httpx.rb +12 -14
  147. data/sig/altsvc.rbs +33 -0
  148. data/sig/buffer.rbs +1 -0
  149. data/sig/callbacks.rbs +3 -3
  150. data/sig/chainable.rbs +10 -9
  151. data/sig/connection/http1.rbs +5 -4
  152. data/sig/connection/http2.rbs +1 -1
  153. data/sig/connection.rbs +46 -24
  154. data/sig/errors.rbs +9 -3
  155. data/sig/httpx.rbs +5 -4
  156. data/sig/io/ssl.rbs +26 -0
  157. data/sig/io/tcp.rbs +60 -0
  158. data/sig/io/udp.rbs +20 -0
  159. data/sig/io/unix.rbs +10 -0
  160. data/sig/options.rbs +28 -12
  161. data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
  162. data/sig/plugins/{authentication → auth}/digest.rbs +2 -1
  163. data/sig/plugins/auth.rbs +13 -0
  164. data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
  165. data/sig/plugins/brotli.rbs +22 -0
  166. data/sig/plugins/callbacks.rbs +38 -0
  167. data/sig/plugins/circuit_breaker.rbs +13 -3
  168. data/sig/plugins/compression.rbs +6 -4
  169. data/sig/plugins/cookies/jar.rbs +2 -2
  170. data/sig/plugins/cookies.rbs +2 -0
  171. data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
  172. data/sig/plugins/follow_redirects.rbs +11 -2
  173. data/sig/plugins/grpc/call.rbs +19 -0
  174. data/sig/plugins/grpc/grpc_encoding.rbs +37 -0
  175. data/sig/plugins/grpc/message.rbs +17 -0
  176. data/sig/plugins/grpc.rbs +2 -32
  177. data/sig/plugins/h2c.rbs +1 -1
  178. data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
  179. data/sig/plugins/oauth.rbs +54 -0
  180. data/sig/plugins/proxy/socks4.rbs +4 -4
  181. data/sig/plugins/proxy/socks5.rbs +2 -2
  182. data/sig/plugins/proxy/ssh.rbs +1 -1
  183. data/sig/plugins/proxy.rbs +10 -4
  184. data/sig/plugins/response_cache.rbs +12 -3
  185. data/sig/plugins/retries.rbs +28 -8
  186. data/sig/plugins/stream.rbs +24 -17
  187. data/sig/plugins/upgrade.rbs +5 -3
  188. data/sig/pool.rbs +5 -4
  189. data/sig/request/body.rbs +40 -0
  190. data/sig/request.rbs +12 -28
  191. data/sig/resolver/https.rbs +7 -2
  192. data/sig/resolver/native.rbs +10 -4
  193. data/sig/resolver/resolver.rbs +6 -4
  194. data/sig/resolver/system.rbs +2 -0
  195. data/sig/resolver.rbs +9 -5
  196. data/sig/response/body.rbs +53 -0
  197. data/sig/response/buffer.rbs +24 -0
  198. data/sig/response.rbs +17 -38
  199. data/sig/session.rbs +24 -18
  200. data/sig/timers.rbs +17 -7
  201. data/sig/transcoder/body.rbs +4 -3
  202. data/sig/transcoder/deflate.rbs +11 -0
  203. data/sig/transcoder/form.rbs +5 -3
  204. data/sig/transcoder/gzip.rbs +24 -0
  205. data/sig/transcoder/json.rbs +4 -2
  206. data/sig/{plugins → transcoder}/multipart.rbs +3 -12
  207. data/sig/transcoder/utils/body_reader.rbs +15 -0
  208. data/sig/transcoder/utils/deflater.rbs +29 -0
  209. data/sig/transcoder/utils/inflater.rbs +12 -0
  210. data/sig/transcoder/xml.rbs +1 -1
  211. data/sig/transcoder.rbs +22 -7
  212. data/sig/utils.rbs +2 -0
  213. metadata +127 -40
  214. data/lib/httpx/plugins/authentication.rb +0 -20
  215. data/lib/httpx/plugins/basic_authentication.rb +0 -30
  216. data/lib/httpx/plugins/compression/brotli.rb +0 -54
  217. data/lib/httpx/plugins/compression/deflate.rb +0 -49
  218. data/lib/httpx/plugins/compression/gzip.rb +0 -88
  219. data/lib/httpx/plugins/compression.rb +0 -164
  220. data/lib/httpx/plugins/multipart/decoder.rb +0 -187
  221. data/lib/httpx/plugins/multipart.rb +0 -84
  222. data/lib/httpx/registry.rb +0 -85
  223. data/sig/plugins/authentication.rbs +0 -11
  224. data/sig/plugins/compression/brotli.rbs +0 -21
  225. data/sig/plugins/compression/deflate.rbs +0 -17
  226. data/sig/plugins/compression/gzip.rbs +0 -29
  227. data/sig/registry.rbs +0 -13
  228. /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
  229. /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
@@ -38,7 +38,7 @@ module HTTPX
38
38
 
39
39
  alias reset init_connection
40
40
 
41
- def timeout: () -> Numeric
41
+ def timeout: () -> Numeric?
42
42
 
43
43
  private
44
44
 
data/sig/connection.rbs CHANGED
@@ -17,10 +17,9 @@ module HTTPX
17
17
  extend Forwardable
18
18
  include Loggable
19
19
  include Callbacks
20
- include HTTPX::Registry[String, Class]
21
20
 
22
- BUFFER_SIZE: Integer
23
21
 
22
+ attr_reader type: io_type
24
23
  attr_reader origin: URI::Generic
25
24
  attr_reader origins: Array[String]
26
25
  attr_reader state: Symbol
@@ -28,33 +27,40 @@ module HTTPX
28
27
  attr_reader options: Options
29
28
  attr_writer timers: Timers
30
29
 
31
- @type: io_type
30
+ attr_accessor family: Integer?
31
+
32
32
  @window_size: Integer
33
33
  @read_buffer: Buffer
34
34
  @write_buffer: Buffer
35
35
  @inflight: Integer
36
36
  @keep_alive_timeout: Numeric?
37
- @total_timeout: Numeric?
37
+ @timeout: Numeric?
38
+ @current_timeout: Numeric?
39
+ @io: TCP | SSL | UNIX
40
+ @parser: HTTP1 | HTTP2 | _Parser
41
+ @connected_at: Float
42
+ @response_received_at: Float
43
+ @intervals: Array[Timers::Interval]
38
44
 
39
45
  def addresses: () -> Array[ipaddr]?
40
46
 
41
- def addresses=: (Array[ipaddr]) -> void
47
+ def addresses=: (Array[ipaddr] addresses) -> void
42
48
 
43
- def match?: (URI::Generic uri, Options options) -> bool
49
+ def send: (Request request) -> void
44
50
 
45
- def mergeable?: (Connection) -> bool
51
+ def match?: (URI::Generic uri, Options options) -> bool
46
52
 
47
- def coalescable?: (Connection) -> bool
53
+ def expired?: () -> boolish
48
54
 
49
- def create_idle: (?Hash[Symbol, untyped] options) -> Connection
55
+ def mergeable?: (Connection connection) -> bool
50
56
 
51
- def merge: (Connection) -> void
57
+ def coalescable?: (Connection connection) -> bool
52
58
 
53
- def purge_pending: () { (Request) -> void } -> void
59
+ def create_idle: (?Hash[Symbol, untyped] options) -> Connection
54
60
 
55
- def match_altsvcs?: (URI::Generic uri) -> bool
61
+ def merge: (Connection connection) -> void
56
62
 
57
- def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
63
+ def purge_pending: () { (Request request) -> void } -> void
58
64
 
59
65
  def connecting?: () -> bool
60
66
 
@@ -66,20 +72,29 @@ module HTTPX
66
72
 
67
73
  def call: () -> void
68
74
 
75
+ def terminate: () -> void
76
+
69
77
  def close: () -> void
70
- def reset: () -> void
71
78
 
72
- def send: (Request) -> void
79
+ def reset: () -> void
73
80
 
74
81
  def timeout: () -> Numeric?
75
82
 
83
+ def idling: () -> void
84
+
85
+ def used?: () -> boolish
86
+
76
87
  def deactivate: () -> void
77
88
 
78
- def raise_timeout_error: (Numeric interval) -> void
89
+ def open?: () -> bool
90
+
91
+ def handle_socket_timeout: (Numeric interval) -> void
79
92
 
80
93
  private
81
94
 
82
- def initialize: (io_type, URI::Generic, options) -> untyped
95
+ def initialize: (URI::Generic uri, options) -> void
96
+
97
+ def initialize_type: (URI::Generic uri, options) -> io_type
83
98
 
84
99
  def connect: () -> void
85
100
 
@@ -89,20 +104,23 @@ module HTTPX
89
104
 
90
105
  def send_pending: () -> void
91
106
 
92
- def parser: () -> _Parser
107
+ def parser: () -> (HTTP1 | HTTP2 | _Parser)
93
108
 
94
109
  def send_request_to_parser: (Request request) -> void
95
110
 
96
- def build_parser: () -> _Parser
97
- | (String) -> _Parser
111
+ def build_parser: (?String protocol) -> (HTTP1 | HTTP2)
98
112
 
99
- def set_parser_callbacks: (_Parser) -> void
113
+ def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
100
114
 
101
- def transition: (Symbol) -> void
115
+ def transition: (Symbol nextstate) -> void
102
116
 
103
- def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
117
+ def handle_transition: (Symbol nextstate) -> void
104
118
 
105
- def handle_error: (StandardError) -> void
119
+ def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
120
+
121
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error) -> void
122
+
123
+ def handle_error: (StandardError error) -> void
106
124
 
107
125
  def purge_after_closed: () -> void
108
126
 
@@ -111,5 +129,9 @@ module HTTPX
111
129
  def write_timeout_callback: (Request request, Numeric write_timeout) -> void
112
130
 
113
131
  def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
132
+
133
+ def set_request_timeout: (Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
134
+
135
+ def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
114
136
  end
115
137
  end
data/sig/errors.rbs CHANGED
@@ -2,6 +2,12 @@ module HTTPX
2
2
  class Error < StandardError
3
3
  end
4
4
 
5
+ class UnsupportedSchemeError < Error
6
+ end
7
+
8
+ class ConnectionError < Error
9
+ end
10
+
5
11
  class TimeoutError < Error
6
12
  attr_reader timeout: Numeric
7
13
 
@@ -11,9 +17,6 @@ module HTTPX
11
17
  def initialize: (Numeric timeout, String message) -> untyped
12
18
  end
13
19
 
14
- class TotalTimeoutError < TimeoutError
15
- end
16
-
17
20
  class ConnectTimeoutError < TimeoutError
18
21
  end
19
22
 
@@ -55,4 +58,7 @@ module HTTPX
55
58
 
56
59
  def initialize: (Connection connection, String hostname, ?String message) -> untyped
57
60
  end
61
+
62
+ class MisdirectedRequestError < HTTPError
63
+ end
58
64
  end
data/sig/httpx.rbs CHANGED
@@ -5,12 +5,13 @@ module HTTPX
5
5
 
6
6
  VERSION: String
7
7
 
8
- type uri = URI::HTTP | URI::HTTPS | string
8
+ type http_uri = URI::HTTP | URI::HTTPS
9
+ type uri = http_uri | string
9
10
  type generic_uri = String | URI::Generic
10
11
 
11
- type verb = :options | :get | :head | :post | :put | :delete | :trace | :connect |
12
- :propfind | :proppatch | :mkcol | :copy | :move | :lock | :unlock | :orderpatch |
13
- :acl | :report | :patch | :search
12
+ type verb = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" |
13
+ "PROPFIND" | "PROPPATCH" | "MKCOL" | "COPY" | "MOVE" | "LOCK" | "UNLOCK" | "ORDERPATCH" |
14
+ "ACL" | "REPORT" | "PATCH" | "SEARCH"
14
15
 
15
16
  type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
16
17
 
data/sig/io/ssl.rbs ADDED
@@ -0,0 +1,26 @@
1
+ module HTTPX
2
+
3
+ class TLSError < OpenSSL::SSL::SSLError
4
+ end
5
+
6
+ class SSL < TCP
7
+ TLS_OPTIONS: Hash[Symbol, untyped]
8
+
9
+ @ctx: OpenSSL::SSL::SSLContext
10
+ @verify_hostname: bool
11
+
12
+ attr_writer ssl_session: OpenSSL::SSL::Session?
13
+
14
+ # TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
15
+ # def initialize: (URI::Generic origin, Array[ipaddr]? addresses, options options) ?{ (self) -> void } -> void
16
+
17
+ def can_verify_peer?: () -> bool
18
+
19
+ def verify_hostname: (String host) -> bool
20
+
21
+ def ssl_session_expired?: () -> boolish
22
+
23
+ # :nocov:
24
+ def try_ssl_connect: () -> void
25
+ end
26
+ end
data/sig/io/tcp.rbs ADDED
@@ -0,0 +1,60 @@
1
+ module HTTPX
2
+ class TCP
3
+ include Loggable
4
+
5
+ attr_reader ip: ipaddr?
6
+
7
+ attr_reader port: Integer
8
+
9
+ attr_reader addresses: Array[ipaddr]
10
+
11
+ attr_reader state: Symbol
12
+
13
+ attr_reader interests: io_interests
14
+
15
+ alias host ip
16
+
17
+ # TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
18
+ def initialize: (URI::Generic origin, Array[ipaddr]? addresses, options options) ?{ (self) -> void } -> void
19
+
20
+ def add_addresses: (Array[ipaddr] addrs) -> void
21
+
22
+ def to_io: () -> ::IO
23
+
24
+ def protocol: () -> String
25
+
26
+ def connect: () -> void
27
+
28
+ private
29
+
30
+ # :nocov:
31
+ def try_connect: () -> void
32
+
33
+ public
34
+
35
+ def read: (Integer size, ?(Buffer | String) buffer) -> (0 | nil | untyped)
36
+
37
+ def write: (Buffer buffer) -> Integer?
38
+
39
+ def close: () -> void
40
+
41
+ def connected?: () -> bool
42
+
43
+ def expired?: () -> boolish
44
+
45
+ def closed?: () -> bool
46
+
47
+ # :nocov:
48
+ def inspect: () -> ::String
49
+
50
+ private
51
+
52
+ def build_socket: () -> Socket
53
+
54
+ def transition: (Symbol nextstate) -> void
55
+
56
+ def do_transition: (Symbol nextstate) -> void
57
+
58
+ def log_transition_state: (Symbol nextstate) -> void
59
+ end
60
+ end
data/sig/io/udp.rbs ADDED
@@ -0,0 +1,20 @@
1
+ module HTTPX
2
+ class UDP
3
+ include Loggable
4
+
5
+ def initialize: (String ip, Integer port, Options options) -> void
6
+
7
+ def to_io: () -> ::IO
8
+
9
+ def connect: () -> void
10
+
11
+ def connected?: () -> bool
12
+
13
+ # :nocov:
14
+ def close: () -> void
15
+
16
+ def read: (Integer size, ?(Buffer | String) buffer) -> Integer?
17
+
18
+ def write: (Buffer buffer) -> Integer?
19
+ end
20
+ end
data/sig/io/unix.rbs ADDED
@@ -0,0 +1,10 @@
1
+ module HTTPX
2
+ class UNIX < TCP
3
+
4
+ attr_reader path: String
5
+
6
+ alias host path
7
+
8
+ def initialize: (http_uri origin, Array[String]? addresses, options options) -> void
9
+ end
10
+ end
data/sig/options.rbs CHANGED
@@ -2,21 +2,22 @@ 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
8
9
  OPERATION_TIMEOUT: Integer
9
10
  KEEP_ALIVE_TIMEOUT: Integer
10
11
  SETTINGS_TIMEOUT: Integer
12
+ CLOSE_HANDSHAKE_TIMEOUT: Integer
11
13
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
14
+ REQUEST_BODY_IVARS: Array[Symbol]
12
15
 
13
- type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout | :read_timeout | :write_timeout | :request_timeout
14
- type timeout = Hash[timeout_type, Numeric]
16
+ type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
17
+ type timeout = Hash[timeout_type, Numeric?]
15
18
 
16
19
  def self.new: (?options) -> instance
17
20
 
18
- def self.def_option: (Symbol, ?String) -> void
19
- | (Symbol) { (*nil) -> untyped } -> void
20
21
  # headers
21
22
  attr_reader uri: URI?
22
23
 
@@ -33,23 +34,32 @@ module HTTPX
33
34
  attr_reader max_concurrent_requests: Integer?
34
35
 
35
36
  # max_requests
36
- attr_reader max_requests: Integer?
37
+ attr_reader max_requests: Numeric?
37
38
 
38
39
  # window_size
39
40
  attr_reader window_size: Integer
40
41
 
42
+ # buffer_size
43
+ attr_reader buffer_size: Integer
44
+
41
45
  # body_threshold_size
42
46
  attr_reader body_threshold_size: Integer
43
47
 
44
48
  # transport
45
- attr_reader transport: String?
46
-
47
- # transport_options
48
- attr_reader transport_options: Hash[untyped, untyped]?
49
+ attr_reader transport: "unix" | nil
49
50
 
50
51
  # addresses
51
52
  attr_reader addresses: Array[ipaddr]?
52
53
 
54
+ # supported_compression_formats
55
+ attr_reader supported_compression_formats: Array[String]
56
+
57
+ # compress_request_body
58
+ attr_reader compress_request_body: bool
59
+
60
+ # decompress_response_body
61
+ attr_reader decompress_response_body: bool
62
+
53
63
  # params
54
64
  attr_reader params: Transcoder::urlencoded_input?
55
65
 
@@ -112,17 +122,23 @@ module HTTPX
112
122
  # ip_families
113
123
  attr_reader ip_families: Array[ip_family]
114
124
 
115
- def ==: (untyped other) -> bool
125
+ def ==: (Options other) -> bool
126
+
127
+ def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
128
+
116
129
  def merge: (_ToHash[Symbol, untyped] other) -> instance
130
+
117
131
  def to_hash: () -> Hash[Symbol, untyped]
118
132
 
133
+ def extend_with_plugin_classes: (Module pl) -> void
134
+
119
135
  private
120
136
 
121
137
  REQUEST_IVARS: Array[Symbol]
122
138
 
123
- def initialize: (?options options) -> untyped
139
+ def initialize: (?options options) -> void
124
140
 
125
- def __initialize__: (?options options) -> untyped
141
+ def do_initialize: (?options options) -> void
126
142
  end
127
143
 
128
144
  type options = Options | Hash[Symbol, untyped]
@@ -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 | 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
@@ -5,13 +5,17 @@ module HTTPX
5
5
  class CircuitStore
6
6
  @circuits: Hash[String, Circuit]
7
7
 
8
- def try_open: (generic_uri uri, response response) -> void
8
+ @circuits_mutex: Thread::Mutex
9
+
10
+ def try_open: (uri uri, response response) -> response?
9
11
 
10
12
  def try_respond: (Request request) -> response?
11
13
 
14
+ def try_close: (http_uri uri) -> void
15
+
12
16
  private
13
17
 
14
- def get_circuit_for_uri: (generic_uri uri) -> Circuit
18
+ def get_circuit_for_uri: (uri uri) -> Circuit
15
19
 
16
20
  def initialize: (Options & _CircuitOptions options) -> void
17
21
  end
@@ -23,6 +27,8 @@ module HTTPX
23
27
  @break_in: Float
24
28
  @circuit_breaker_half_open_drip_rate: Float
25
29
  @attempts: Integer
30
+ @real_attempts: Integer
31
+ @drip_factor: Integer
26
32
 
27
33
  @response: response?
28
34
  @opened_at: Float?
@@ -30,7 +36,7 @@ module HTTPX
30
36
 
31
37
  def respond: () -> response?
32
38
 
33
- def try_open: (response) -> void
39
+ def try_open: (response) -> response?
34
40
 
35
41
  def try_close: () -> void
36
42
 
@@ -52,6 +58,10 @@ module HTTPX
52
58
 
53
59
  module InstanceMethods
54
60
  @circuit_store: CircuitStore
61
+
62
+ private
63
+
64
+ def try_circuit_open: (Request request, response response) -> response?
55
65
  end
56
66
 
57
67
  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
 
@@ -16,12 +15,15 @@ module HTTPX
16
15
  def initialize: (Integer | Float bytesize) -> untyped
17
16
  end
18
17
 
18
+ interface _Compressor
19
+ def deflater: () -> _Deflater
20
+ def inflater: (Integer | Float bytesize) -> _Inflater
21
+ end
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
@@ -10,6 +10,10 @@ module HTTPX
10
10
  def max_redirects: () -> Integer?
11
11
 
12
12
  def follow_insecure_redirects: () -> bool?
13
+
14
+ def allow_auth_to_other_origins: () -> bool?
15
+
16
+ def redirect_on: (http_uri) -> bool?
13
17
  end
14
18
 
15
19
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
@@ -17,13 +21,18 @@ module HTTPX
17
21
  module InstanceMethods
18
22
  def max_redirects: (_ToI) -> instance
19
23
 
20
- def build_redirect_request: (Request, Response, Options) -> Request
24
+ def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
25
+
21
26
  def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
22
27
  end
23
28
 
24
29
  module RequestMethods
25
- def redirect_request: () -> Request
30
+ attr_accessor root_request: instance?
31
+
32
+ def redirect_request: () -> instance
33
+
26
34
  def redirect_request=: (Request) -> void
35
+
27
36
  def max_redirects: () -> Integer
28
37
  end
29
38
  end