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/resolver.rbs CHANGED
@@ -2,9 +2,7 @@ module HTTPX
2
2
  type ipaddr = IPAddr | String
3
3
 
4
4
  module Resolver
5
- extend Registry[Symbol, Class]
6
-
7
- RESOLVE_TIMEOUT: Integer | Float
5
+ RESOLVE_TIMEOUT: Array[Integer]
8
6
 
9
7
  @lookup_mutex: Thread::Mutex
10
8
 
@@ -13,6 +11,7 @@ module HTTPX
13
11
  type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
14
12
  | { "name" => String, "TTL" => Numeric, "data" => String }
15
13
 
14
+ type dns_decoding_response = [:ok, Array[dns_result]] | [:decode_error, Resolv::DNS::DecodeError] | [:dns_error, Integer] | Symbol
16
15
 
17
16
  def nolookup_resolve: (String hostname) -> Array[IPAddr]
18
17
 
@@ -20,6 +19,11 @@ module HTTPX
20
19
 
21
20
  def system_resolve: (String hostname) -> Array[IPAddr]?
22
21
 
22
+ def self?.resolver_for: (:native resolver_type) -> singleton(Native) |
23
+ (:system resolver_type) -> singleton(System) |
24
+ (:https resolver_type) -> singleton(HTTPS) |
25
+ [U] (U resolver_type) -> U
26
+
23
27
  def self?.cached_lookup: (String hostname) -> Array[IPAddr]?
24
28
 
25
29
  def self?.cached_lookup_set: (String hostname, ip_family family, Array[dns_result] addresses) -> void
@@ -28,8 +32,8 @@ module HTTPX
28
32
 
29
33
  def self?.generate_id: () -> Integer
30
34
 
31
- def self?.encode_dns_query: (String hostname, ?type: dns_resource) -> String
35
+ def self?.encode_dns_query: (String hostname, ?type: dns_resource, ?message_id: Integer) -> String
32
36
 
33
- def self?.decode_dns_answer: (String) -> Array[dns_result]
37
+ def self?.decode_dns_answer: (String) -> dns_decoding_response
34
38
  end
35
39
  end
@@ -0,0 +1,53 @@
1
+ module HTTPX
2
+ class Response::Body
3
+ include _Reader
4
+ include _ToS
5
+ include _ToStr
6
+
7
+ attr_reader encoding: Encoding | String
8
+ attr_reader encodings: Array[Encoding | String]
9
+
10
+ @response: Response
11
+ @headers: Headers
12
+ @options: Options
13
+ @state: :idle | :memory | :buffer | :closed
14
+ @window_size: Integer
15
+ @length: Integer
16
+ @buffer: StringIO | Tempfile | nil
17
+ @reader: StringIO | Tempfile | nil
18
+ @inflaters: Array[Transcoder::_Inflater]
19
+
20
+ def initialize: (Response, Options) -> void
21
+
22
+ def closed?: () -> bool
23
+
24
+ def write:(String chunk) -> Integer?
25
+
26
+ def filename: () -> String?
27
+
28
+ def bytesize: () -> Integer
29
+
30
+ def each: () { (String) -> void } -> void
31
+ | () -> Enumerable[String]
32
+
33
+ def empty?: () -> bool
34
+
35
+ def copy_to: (String | File | _Writer destination) -> void
36
+
37
+ def close: () -> void
38
+
39
+ def rewind: () -> void
40
+
41
+ private
42
+
43
+ def initialize_inflaters: () -> void
44
+
45
+ def self.initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> Transcoder::GZIP::Inflater
46
+
47
+ def decode_chunk: (String chunk) -> String
48
+
49
+ def transition: (Symbol nextstate) -> void
50
+
51
+ def _with_same_buffer_pos: [A] () { () -> A } -> A
52
+ end
53
+ end
@@ -0,0 +1,24 @@
1
+ module HTTPX
2
+ class Response::Buffer
3
+ @threshold_size: Integer
4
+ @bytesize: Integer
5
+ @encoding: Encoding
6
+ @buffer: StringIO | Tempfile
7
+
8
+ def initialize: (threshold_size: Integer, ?bytesize: Integer, ?encoding: Encoding | String) -> void
9
+
10
+ def size: () -> Integer
11
+
12
+ def write: (String) -> void
13
+
14
+ def to_s: () -> String
15
+
16
+ def close: () -> void
17
+
18
+ private
19
+
20
+ def try_upgrade_buffer: () -> void
21
+
22
+ def _with_same_buffer_pos: () { () -> void } -> void
23
+ end
24
+ end
data/sig/response.rbs CHANGED
@@ -1,5 +1,7 @@
1
1
  module HTTPX
2
2
  interface _Response
3
+ def finished?: () -> bool
4
+
3
5
  def raise_for_status: () -> self
4
6
 
5
7
  def error: () -> StandardError?
@@ -7,6 +9,7 @@ module HTTPX
7
9
 
8
10
  class Response
9
11
  extend Forwardable
12
+ include Callbacks
10
13
 
11
14
  include _Response
12
15
  include _ToS
@@ -22,58 +25,30 @@ module HTTPX
22
25
  @content_type: ContentType
23
26
 
24
27
  def copy_to: (_ToPath | _Writer destination) -> void
28
+
25
29
  def close: () -> void
30
+
26
31
  def uri: () -> URI::Generic
27
32
 
33
+ def peer_address: () -> ipaddr?
34
+
28
35
  def merge_headers: (_Each[[String, headers_value]]) -> void
36
+
29
37
  def bodyless?: () -> bool
38
+
30
39
  def content_type: () -> ContentType
40
+
31
41
  def complete?: () -> bool
32
42
 
33
43
  def json: (?json_options opts) -> untyped
34
44
 
35
45
  def form: () -> Hash[String, untyped]
36
46
 
37
- private
38
-
39
- def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
40
- def no_data?: () -> bool
41
-
42
- def decode:(String format, ?untyped options) -> untyped
43
-
44
- class Body
45
- include _Reader
46
- include _ToS
47
- include _ToStr
48
-
49
- @response: Response
50
- @headers: Headers
51
- @options: Options
52
- @state: :idle | :memory | :buffer | :closed
53
- @threshold_size: Integer
54
- @window_size: Integer
55
- @encoding: String
56
- @length: Integer
57
- @buffer: StringIO | Tempfile | nil
47
+ def initialize: (Request request, String | Integer status, String version, headers?) -> void
58
48
 
59
- def write:(String chunk) -> Integer?
60
-
61
- def each: () { (String) -> void } -> void
62
- | () -> Enumerable[String]
63
-
64
- def bytesize: () -> Numeric
65
- def empty?: () -> bool
66
- def copy_to: (String | File | _Writer destination) -> void
67
- def close: () -> void
68
- def closed?: () -> bool
69
-
70
- private
49
+ private
71
50
 
72
- def initialize: (Response, Options) -> untyped
73
- def rewind: () -> void
74
- def transition: () -> void
75
- def _with_same_buffer_pos: [A] () { () -> A } -> A
76
- end
51
+ def decode:(Transcoder::_Decode transcoder, ?untyped options) -> untyped
77
52
  end
78
53
 
79
54
  class ContentType
@@ -95,18 +70,28 @@ module HTTPX
95
70
 
96
71
  class ErrorResponse
97
72
  include _Response
73
+ include _Reader
98
74
  include Loggable
75
+ extend Forwardable
99
76
 
100
77
  @options: Options
101
78
  @error: Exception
102
79
 
103
80
  attr_reader request: Request
104
81
 
82
+ attr_reader response: Response?
83
+
105
84
  def status: () -> (Integer | _ToS)
106
85
 
86
+ def uri: () -> URI::Generic
87
+
88
+ def peer_address: () -> ipaddr?
89
+
90
+ def close: () -> void
91
+
107
92
  private
108
93
 
109
- def initialize: (Request, Exception, options) -> untyped
94
+ def initialize: (Request, Exception) -> untyped
110
95
  end
111
96
 
112
97
  type response = Response | ErrorResponse
data/sig/selector.rbs CHANGED
@@ -7,7 +7,7 @@ module HTTPX
7
7
  @selectables: Array[selectable]
8
8
 
9
9
  def register: (selectable io) -> void
10
- def deregister: (selectable io) -> void
10
+ def deregister: (selectable io) -> selectable?
11
11
 
12
12
  def select: (Numeric? interval) { (selectable) -> void } -> void
13
13
 
data/sig/session.rbs CHANGED
@@ -11,42 +11,53 @@ module HTTPX
11
11
 
12
12
  def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
13
13
 
14
- def self.default_options: -> Options
15
-
16
14
  def wrap: () { (instance) -> void } -> void
17
15
 
18
16
  def close: (*untyped) -> void
19
17
 
20
- def build_request: (String | verb, generic_uri, ?options) -> Request
18
+ def build_request: (verb verb, generic_uri uri, ?request_params params, ?Options options) -> Request
21
19
 
22
- private
20
+ def initialize: (?options) { (self) -> void } -> void
21
+ | (?options) -> void
23
22
 
24
- def initialize: (?options) { (self) -> void } -> untyped
25
- | (?options) -> untyped
23
+ private
26
24
 
27
25
  def pool: -> Pool
26
+
28
27
  def on_response: (Request, response) -> void
28
+
29
29
  def on_promise: (untyped, untyped) -> void
30
- def fetch_response: (Request request, untyped, untyped) -> response?
31
30
 
32
- def find_connection: (Request, Array[Connection] connections, Options options) -> Connection
31
+ def fetch_response: (Request request, Array[Connection] connections, untyped options) -> response?
32
+
33
+ def find_connection: (Request request, Array[Connection] connections, Options options) -> Connection
33
34
 
34
- def set_connection_callbacks: (Connection, Array[Connection], Options) -> void
35
+ def deactivate_connection: (Request request, Array[Connection] connections, Options options) -> void
35
36
 
36
- def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> Connection?
37
+ def send_request: (Request request, Array[Connection] connections, ?Options options) -> void
37
38
 
38
- def build_requests: (verb | string, uri, options) -> Array[Request]
39
- | (Array[[verb | string, uri, options]], options) -> Array[Request]
40
- | (Array[[verb | string, uri]], options) -> Array[Request]
41
- | (verb | string, _Each[[uri, options]], Options) -> Array[Request]
42
- | (verb | string, _Each[uri], options) -> Array[Request]
39
+ def set_connection_callbacks: (Connection connection, Array[Connection] connections, Options options, ?cloned: bool) -> void
43
40
 
44
- def build_connection: (URI::Generic, Options) -> Connection
41
+ def set_request_callbacks: (Request request) -> void
42
+
43
+ def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> (Connection & AltSvc::ConnectionMixin)?
44
+
45
+ def build_requests: (verb, uri, request_params) -> Array[Request]
46
+ | (Array[[verb, uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
47
+ | (Array[[verb, uri]], request_params) -> Array[Request]
48
+ | (verb, _Each[[uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
49
+ | (verb, _Each[uri], request_params) -> Array[Request]
50
+
51
+ def init_connection: (http_uri uri, Options options) -> Connection
45
52
 
46
53
  def send_requests: (*Request) -> Array[response]
47
54
 
48
- def _send_requests: (Array[Request]) -> Array[Connection]
55
+ def _send_requests: (Array[Request] requests) -> Array[Connection]
49
56
 
50
- def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
57
+ def receive_requests: (Array[Request] requests, Array[Connection] connections) -> Array[response]
58
+
59
+ attr_reader self.default_options: Options
51
60
  end
61
+
62
+ OriginalSession: singleton(Session)
52
63
  end
data/sig/timers.rbs CHANGED
@@ -1,32 +1,42 @@
1
1
  module HTTPX
2
2
  class Timers
3
3
  @intervals: Array[Interval]
4
- @next_interval_at: Numeric
4
+ @next_interval_at: Float
5
5
 
6
- def after: (Numeric interval_in_secs) { () -> void } -> void
6
+ def after: (Numeric interval_in_secs, ^() -> void) -> Interval
7
+ | (Numeric interval_in_secs) { () -> void } -> Interval
7
8
 
8
9
  def wait_interval: () -> Numeric?
9
10
 
10
11
  def fire: (?TimeoutError error) -> void
11
12
 
12
- def cancel: () -> void
13
-
14
- private
15
-
16
13
  def initialize: () -> void
17
14
 
18
15
  class Interval
19
16
  include Comparable
20
17
 
18
+ type callback = ^() -> void
19
+
21
20
  attr_reader interval: Numeric
22
21
 
23
- @callbacks: Array[^() -> void]
22
+ @callbacks: Array[callback]
23
+ @on_empty: callback?
24
+
25
+
26
+ def on_empty: () { () -> void } -> void
24
27
 
25
28
  def to_f: () -> Float
26
29
 
27
- def <<: (^() -> void) -> void
30
+ def <<: (callback) -> void
31
+
32
+ def delete: (callback) -> void
28
33
 
29
34
  def elapse: (Numeric elapsed) -> Numeric
35
+
36
+ def elapsed?: () -> bool
37
+
38
+ def no_callbacks?: () -> bool
39
+
30
40
  private
31
41
 
32
42
  def initialize: (Numeric interval) -> void
@@ -7,13 +7,14 @@ module HTTPX
7
7
  class Encoder
8
8
  extend Forwardable
9
9
 
10
- include _Encoder
11
- include _ToS
12
-
13
10
  @raw: bodyIO
14
11
 
12
+ def bytesize: () -> (Integer | Float)
13
+
15
14
  def content_type: () -> String
16
15
 
16
+ def to_s: () -> String
17
+
17
18
  private
18
19
 
19
20
  def initialize: (untyped body) -> untyped
@@ -0,0 +1,11 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module Deflate
4
+ def self?.encode: (_Encoder body) -> Deflater
5
+ def self?.decode: (Response body, ?bytesize: Integer) -> GZIP::Inflater
6
+
7
+ class Deflater < Transcoder::Deflater
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,17 +3,19 @@ module HTTPX::Transcoder
3
3
 
4
4
  type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
5
5
 
6
- type urlencoded_input = Enumerable[[_ToS, form_nested_value]]
6
+ type urlencoded_input = Enumerable[[_ToS, form_nested_value | Multipart::multipart_nested_value]]
7
7
 
8
8
  module Form
9
- def self?.encode: (urlencoded_input form) -> Encoder
9
+ def self?.encode: (urlencoded_input form) -> (Encoder | Multipart::Encoder)
10
10
  def self?.decode: (HTTPX::Response response) -> _Decoder
11
+ def self?.multipart?: (form_nested_value | Multipart::multipart_nested_value data) -> bool
11
12
 
12
13
  class Encoder
13
14
  extend Forwardable
14
- include _Encoder
15
15
  include _ToS
16
16
 
17
+ def bytesize: () -> Integer
18
+
17
19
  def content_type: () -> String
18
20
 
19
21
  private
@@ -0,0 +1,24 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module GZIP
4
+ def self?.encode: (_Encoder body) -> Deflater
5
+ def self?.decode: (Response response, ?bytesize: Integer) -> Inflater
6
+
7
+ class Deflater < Transcoder::Deflater
8
+ @compressed_chunk: String
9
+
10
+ private
11
+
12
+ def write: (String chunk) -> void
13
+
14
+ def compressed_chunk: () -> String
15
+ end
16
+
17
+ class Inflater
18
+ def initialize: (Integer | Float bytesize) -> void
19
+
20
+ def call: (String chunk) -> String
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,19 +5,24 @@ module HTTPX::Transcoder
5
5
  def self?.encode: (_ToJson json) -> Encoder
6
6
  def self?.decode: (HTTPX::Response response) -> _Decoder
7
7
 
8
+ def self?.json_load: (string source, ?json_options) -> untyped
9
+ def self?.json_dump: (_ToJson obj, *untyped) -> String
10
+
8
11
  class Encoder
9
12
  extend Forwardable
10
- include _Encoder
11
- include _ToS
12
13
 
13
14
  @raw: String
14
15
  @charset: String
15
16
 
17
+ def bytesize: () -> Integer
18
+
16
19
  def content_type: () -> String
17
20
 
21
+ def to_s: () -> String
22
+
18
23
  private
19
24
 
20
- def initialize: (_ToJson json) -> untyped
25
+ def initialize: (_ToJson json) -> void
21
26
  end
22
27
  end
23
28
  end
@@ -1,5 +1,5 @@
1
1
  module HTTPX
2
- module Plugins
2
+ module Transcoder
3
3
  module Multipart
4
4
  interface _MultipartInput
5
5
  def filename: () -> String
@@ -9,13 +9,6 @@ module HTTPX
9
9
 
10
10
  MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
11
11
 
12
- def self.load_dependencies: (singleton(Session)) -> void
13
- def self.configure: (*untyped) -> void
14
- def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
15
- def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
16
-
17
- def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> U } -> U
18
-
19
12
  type multipart_value = string | Pathname | File | _Reader
20
13
 
21
14
  type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
@@ -24,14 +17,14 @@ module HTTPX
24
17
  type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
25
18
 
26
19
  class Encoder
27
- include Transcoder::_Encoder
28
-
29
20
  @boundary: String
30
21
  @part_index: Integer
31
22
  @buffer: String
32
23
 
33
- @form: Enumerable[[Symbol | string, multipart_nested_value]]
34
- @parts: Array[_Reader]
24
+ @form: Enumerable[[Symbol | string, Object & multipart_nested_value]]
25
+ @parts: Array[Object & _Reader]
26
+
27
+ def bytesize: () -> Integer
35
28
 
36
29
  def content_type: () -> String
37
30
 
@@ -47,13 +40,18 @@ module HTTPX
47
40
 
48
41
  def header_part: (string key, String content_type, String? filename) -> StringIO
49
42
 
50
- def read_chunks: (String buffer, ?Integer? length) -> void
43
+ def read_chunks: (String buffer, ?int? length) -> void
51
44
 
52
- def read_from_part: (?Integer? max_length) -> String?
45
+ def read_from_part: (?int? max_length) -> String?
53
46
  end
54
47
 
55
48
  class Decoder
49
+ CRLF: String
56
50
  BOUNDARY_RE: Regexp
51
+ MULTIPART_CONTENT_TYPE: Regexp
52
+ MULTIPART_CONTENT_DISPOSITION: Regexp
53
+ MULTIPART_CONTENT_ID: Regexp
54
+ WINDOW_SIZE: Integer
57
55
 
58
56
  @state: :idle | :part_header | :part_body | :parse_boundary | :done
59
57
  @buffer: String
@@ -61,15 +59,13 @@ module HTTPX
61
59
  @boundary: String
62
60
  @intermediate_boundary: String
63
61
 
64
- def call: (Response response, untyped) -> Hash[String, untyped]
62
+ def call: (Response response, *untyped) -> Hash[String, untyped]
65
63
 
66
64
  private
67
65
 
68
66
  def initialize: (Response response) -> void
69
67
 
70
68
  def parse: () -> void
71
-
72
- def get_filename: (String head) -> String?
73
69
  end
74
70
 
75
71
  class FilePart # < SimpleDelegator
@@ -84,8 +80,8 @@ module HTTPX
84
80
  end
85
81
 
86
82
  module Part
87
- def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
88
- | (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
83
+ def self?.call: [U] (Object & _MultipartInput multipart_input) -> [U, String, String]
84
+ | (Object & multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
89
85
  end
90
86
 
91
87
  module MimeTypeDetector
@@ -0,0 +1,15 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ class BodyReader
4
+ @body: _Reader | _Each[String]
5
+
6
+ def initialize: (bodyIO body) -> void
7
+
8
+ def bytesize: () -> (Integer | Float)
9
+
10
+ def read: (?int? length, ?string outbuf) -> String?
11
+
12
+ def close: () -> void
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ class Deflater
4
+ extend Forwardable
5
+
6
+ @body: BodyReader
7
+ @buffer: Response::Buffer?
8
+ @body: _Encoder | StringIO
9
+ @closed: bool
10
+
11
+ attr_reader content_type: String
12
+
13
+ def initialize: (_Encoder body) -> void
14
+
15
+ def bytesize: () -> (Integer | Float)
16
+
17
+ def read: (?int? length, ?string outbuf) -> String?
18
+
19
+ def close: () -> void
20
+
21
+ def deflate: (String? chunk) -> String?
22
+
23
+ private
24
+
25
+ def buffer_deflate!: () -> void
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ class Inflater
4
+ @inflater: Zlib::Inflate
5
+ @bytesize: Integer
6
+
7
+ def initialize: (Integer | Float bytesize) -> void
8
+
9
+ def call: (String chunk) -> String
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ module HTTPX::Transcoder
2
+ module Xml
3
+ MIME_TYPES: Regexp
4
+
5
+ def self?.encode: (untyped xml) -> Encoder
6
+ def self?.decode: (HTTPX::Response response) -> _Decoder
7
+
8
+ class Encoder
9
+ @raw: untyped # can be nokogiri object
10
+
11
+ def content_type: () -> String
12
+
13
+ def bytesize: () -> (Integer | Float)
14
+
15
+ def to_s: () -> String
16
+
17
+ private
18
+
19
+ def initialize: (String xml) -> void
20
+ end
21
+ end
22
+ end