httpx 1.2.6 → 1.4.4

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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/doc/release_notes/1_3_0.md +18 -0
  4. data/doc/release_notes/1_3_1.md +17 -0
  5. data/doc/release_notes/1_3_2.md +6 -0
  6. data/doc/release_notes/1_3_3.md +5 -0
  7. data/doc/release_notes/1_3_4.md +6 -0
  8. data/doc/release_notes/1_4_0.md +43 -0
  9. data/doc/release_notes/1_4_1.md +19 -0
  10. data/doc/release_notes/1_4_2.md +20 -0
  11. data/doc/release_notes/1_4_3.md +11 -0
  12. data/doc/release_notes/1_4_4.md +14 -0
  13. data/lib/httpx/adapters/datadog.rb +56 -80
  14. data/lib/httpx/adapters/faraday.rb +5 -2
  15. data/lib/httpx/adapters/webmock.rb +24 -8
  16. data/lib/httpx/callbacks.rb +2 -7
  17. data/lib/httpx/chainable.rb +3 -1
  18. data/lib/httpx/connection/http1.rb +11 -7
  19. data/lib/httpx/connection/http2.rb +57 -34
  20. data/lib/httpx/connection.rb +270 -71
  21. data/lib/httpx/errors.rb +15 -4
  22. data/lib/httpx/io/ssl.rb +6 -3
  23. data/lib/httpx/io/tcp.rb +1 -1
  24. data/lib/httpx/io/unix.rb +1 -1
  25. data/lib/httpx/loggable.rb +17 -10
  26. data/lib/httpx/options.rb +30 -23
  27. data/lib/httpx/plugins/aws_sdk_authentication.rb +3 -0
  28. data/lib/httpx/plugins/aws_sigv4.rb +36 -17
  29. data/lib/httpx/plugins/callbacks.rb +13 -2
  30. data/lib/httpx/plugins/circuit_breaker.rb +11 -5
  31. data/lib/httpx/plugins/content_digest.rb +202 -0
  32. data/lib/httpx/plugins/cookies.rb +9 -6
  33. data/lib/httpx/plugins/digest_auth.rb +3 -0
  34. data/lib/httpx/plugins/expect.rb +10 -4
  35. data/lib/httpx/plugins/follow_redirects.rb +68 -33
  36. data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -0
  37. data/lib/httpx/plugins/grpc.rb +2 -2
  38. data/lib/httpx/plugins/h2c.rb +23 -20
  39. data/lib/httpx/plugins/internal_telemetry.rb +48 -1
  40. data/lib/httpx/plugins/oauth.rb +1 -1
  41. data/lib/httpx/plugins/persistent.rb +16 -0
  42. data/lib/httpx/plugins/proxy/http.rb +19 -16
  43. data/lib/httpx/plugins/proxy/socks4.rb +1 -1
  44. data/lib/httpx/plugins/proxy/socks5.rb +1 -1
  45. data/lib/httpx/plugins/proxy.rb +96 -85
  46. data/lib/httpx/plugins/retries.rb +28 -10
  47. data/lib/httpx/plugins/ssrf_filter.rb +4 -1
  48. data/lib/httpx/plugins/stream.rb +42 -18
  49. data/lib/httpx/plugins/upgrade.rb +5 -10
  50. data/lib/httpx/plugins/webdav.rb +6 -0
  51. data/lib/httpx/plugins/xml.rb +76 -0
  52. data/lib/httpx/pool.rb +73 -244
  53. data/lib/httpx/request/body.rb +50 -55
  54. data/lib/httpx/request.rb +77 -14
  55. data/lib/httpx/resolver/https.rb +17 -20
  56. data/lib/httpx/resolver/multi.rb +34 -16
  57. data/lib/httpx/resolver/native.rb +140 -61
  58. data/lib/httpx/resolver/resolver.rb +64 -19
  59. data/lib/httpx/resolver/system.rb +32 -16
  60. data/lib/httpx/resolver.rb +21 -14
  61. data/lib/httpx/response/body.rb +12 -1
  62. data/lib/httpx/response.rb +16 -9
  63. data/lib/httpx/selector.rb +170 -91
  64. data/lib/httpx/session.rb +282 -139
  65. data/lib/httpx/timers.rb +17 -2
  66. data/lib/httpx/transcoder/body.rb +15 -29
  67. data/lib/httpx/transcoder/form.rb +2 -0
  68. data/lib/httpx/transcoder/gzip.rb +0 -3
  69. data/lib/httpx/transcoder/json.rb +16 -2
  70. data/lib/httpx/transcoder/multipart/encoder.rb +11 -2
  71. data/lib/httpx/transcoder/multipart/part.rb +1 -1
  72. data/lib/httpx/transcoder/utils/deflater.rb +7 -4
  73. data/lib/httpx/transcoder.rb +0 -1
  74. data/lib/httpx/version.rb +1 -1
  75. data/lib/httpx.rb +20 -21
  76. data/sig/callbacks.rbs +2 -3
  77. data/sig/chainable.rbs +6 -2
  78. data/sig/connection/http1.rbs +2 -2
  79. data/sig/connection/http2.rbs +22 -18
  80. data/sig/connection.rbs +40 -9
  81. data/sig/errors.rbs +9 -3
  82. data/sig/httpx.rbs +3 -3
  83. data/sig/io/tcp.rbs +1 -1
  84. data/sig/io/unix.rbs +1 -1
  85. data/sig/loggable.rbs +4 -2
  86. data/sig/options.rbs +8 -13
  87. data/sig/plugins/aws_sigv4.rbs +8 -2
  88. data/sig/plugins/content_digest.rbs +51 -0
  89. data/sig/plugins/cookies/cookie.rbs +9 -0
  90. data/sig/plugins/follow_redirects.rbs +1 -1
  91. data/sig/plugins/grpc/call.rbs +4 -0
  92. data/sig/plugins/persistent.rbs +4 -1
  93. data/sig/plugins/proxy/http.rbs +3 -0
  94. data/sig/plugins/proxy/socks5.rbs +11 -3
  95. data/sig/plugins/proxy.rbs +18 -9
  96. data/sig/plugins/push_promise.rbs +6 -3
  97. data/sig/plugins/rate_limiter.rbs +2 -0
  98. data/sig/plugins/retries.rbs +1 -1
  99. data/sig/plugins/ssrf_filter.rbs +26 -0
  100. data/sig/plugins/stream.rbs +3 -0
  101. data/sig/plugins/webdav.rbs +23 -0
  102. data/sig/plugins/xml.rbs +37 -0
  103. data/sig/pool.rbs +27 -33
  104. data/sig/request/body.rbs +4 -10
  105. data/sig/request.rbs +14 -1
  106. data/sig/resolver/multi.rbs +26 -1
  107. data/sig/resolver/native.rbs +6 -3
  108. data/sig/resolver/resolver.rbs +22 -3
  109. data/sig/resolver.rbs +5 -1
  110. data/sig/response/body.rbs +2 -2
  111. data/sig/response/buffer.rbs +2 -2
  112. data/sig/response.rbs +9 -4
  113. data/sig/selector.rbs +31 -4
  114. data/sig/session.rbs +54 -20
  115. data/sig/timers.rbs +15 -4
  116. data/sig/transcoder/body.rbs +2 -4
  117. data/sig/transcoder/chunker.rbs +1 -1
  118. data/sig/transcoder/deflate.rbs +1 -0
  119. data/sig/transcoder/form.rbs +8 -0
  120. data/sig/transcoder/gzip.rbs +4 -1
  121. data/sig/transcoder/json.rbs +1 -1
  122. data/sig/transcoder/multipart.rbs +6 -4
  123. data/sig/transcoder/utils/body_reader.rbs +3 -3
  124. data/sig/transcoder/utils/deflater.rbs +2 -3
  125. metadata +32 -14
  126. data/lib/httpx/session2.rb +0 -23
  127. data/lib/httpx/transcoder/utils/inflater.rb +0 -19
  128. data/lib/httpx/transcoder/xml.rb +0 -52
  129. data/sig/transcoder/utils/inflater.rbs +0 -12
  130. data/sig/transcoder/xml.rbs +0 -22
@@ -0,0 +1,51 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module ContentDigest
4
+ class Error < HTTPX::Error
5
+ end
6
+ class ValidationError < Error
7
+ attr_reader response: Response
8
+
9
+ def initialize: (String message, Response response) -> void
10
+ end
11
+ class MissingContentDigestError < ValidationError
12
+ end
13
+ class InvalidContentDigestError < ValidationError
14
+ end
15
+
16
+ SUPPORTED_ALGORITHMS: Hash[String, singleton(OpenSSL::Digest)]
17
+
18
+ interface _ContentDigestOptions
19
+ def digest_algorithm: () -> String
20
+ def encode_content_digest: () -> (bool | ^(Request) -> boolish)
21
+ def validate_content_digest: () -> (bool | ^(contentDigestResponse) -> boolish)
22
+ end
23
+
24
+ # def self.extra_options: (Options) -> contentDigestOptions
25
+
26
+ module InstanceMethods
27
+ private
28
+
29
+ def validate_content_digest: (Response response) -> void
30
+
31
+ def extract_content_digests: (String) -> Hash[String, String]
32
+
33
+ def base64digest: (Request::Body | contentDigestResponseBody body) -> String
34
+ end
35
+
36
+ module ResponseMethods
37
+ attr_reader body: contentDigestResponseBody
38
+ end
39
+
40
+ module ResponseBodyMethods
41
+ attr_reader content_digest_buffer: Response::Buffer?
42
+ end
43
+
44
+ type contentDigestOptions = Options & _ContentDigestOptions
45
+ type contentDigestResponse = Response & ResponseMethods
46
+ type contentDigestResponseBody = Response::Body & ResponseBodyMethods
47
+ end
48
+
49
+ type sessionContentDigest = Session & ContentDigest::InstanceMethods
50
+ end
51
+ end
@@ -17,6 +17,10 @@ module HTTPX
17
17
 
18
18
  attr_reader created_at: Time
19
19
 
20
+ @for_domain: bool
21
+
22
+ @domain_name: DomainName
23
+
20
24
  def path=: (string) -> void
21
25
 
22
26
  def domain=: (string) -> void
@@ -43,6 +47,11 @@ module HTTPX
43
47
  | (_ToS, _ToS, ?cookie_attributes) -> untyped
44
48
 
45
49
  def acceptable_from_uri?: (uri) -> bool
50
+
51
+ module Scanner
52
+ RE_BAD_CHAR: Regexp
53
+ def self?.quote: (String s) -> String
54
+ end
46
55
  end
47
56
  end
48
57
  end
@@ -24,7 +24,7 @@ module HTTPX
24
24
  module InstanceMethods
25
25
  def max_redirects: (_ToI) -> instance
26
26
 
27
- def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
27
+ def handle_after_redirect_request: (http_uri original_uri, http_uri redirect_uri, Request request, Options & _FollowRedirectsOptions options) -> void
28
28
 
29
29
  def __get_location_from_response: (Response) -> http_uri
30
30
  end
@@ -4,6 +4,10 @@ module HTTPX
4
4
  class Call
5
5
  attr_writer decoder: _Callable
6
6
 
7
+ @response: Response | StreamResponse
8
+ @consumed: bool
9
+ @grpc_response: Enumerator[String] | String
10
+
7
11
  def metadata: () -> headers
8
12
 
9
13
  def trailing_metadata: () -> headers?
@@ -4,8 +4,11 @@ module HTTPX
4
4
  def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
6
  def self.extra_options: (Options) -> (Options)
7
+
8
+ module InstanceMethods
9
+ end
7
10
  end
8
11
 
9
- type sessionPersistent = sessionFollowRedirects
12
+ type sessionPersistent = Session & Persistent::InstanceMethods
10
13
  end
11
14
  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
 
@@ -6,6 +6,14 @@ module HTTPX
6
6
  module Proxy
7
7
  module Socks5
8
8
  VERSION: Integer
9
+ NOAUTH: Integer
10
+ PASSWD: Integer
11
+ NONE: Integer
12
+ CONNECT: Integer
13
+ IPV4: Integer
14
+ DOMAIN: Integer
15
+ IPV6: Integer
16
+ SUCCESS: Integer
9
17
 
10
18
  module ConnectionMethods
11
19
  def __socks5_proxy_connect: () -> void
@@ -31,9 +39,9 @@ module HTTPX
31
39
  end
32
40
 
33
41
  module Packet
34
- def self?.negotiate: (Parameters) -> String
35
- def self?.authenticate: (Parameters) -> String
36
- def self?.connect: (uri) -> String
42
+ def self?.negotiate: (Parameters parameters) -> String
43
+ def self?.authenticate: (Parameters parameters) -> String
44
+ def self?.connect: (uri uri) -> String
37
45
  end
38
46
  end
39
47
  end
@@ -6,15 +6,25 @@ module HTTPX
6
6
  end
7
7
 
8
8
  module Plugins
9
+ interface _Authenticator
10
+ def authenticate: (Request request, String authenticate) -> String
11
+ end
12
+
9
13
  module Proxy
10
14
  Error: singleton(HTTPProxyError)
11
15
  PROXY_ERRORS: Array[singleton(StandardError)]
12
16
 
13
17
  class Parameters
14
- attr_reader uri: URI::Generic
18
+ attr_reader uri: URI::Generic?
15
19
  attr_reader username: String?
16
20
  attr_reader password: String?
17
21
  attr_reader scheme: String?
22
+ attr_reader no_proxy: Array[String]?
23
+
24
+ @uris: Array[URI::Generic | String]
25
+ @authenticator: _Authenticator
26
+
27
+ def shift: () -> void
18
28
 
19
29
  def can_authenticate?: (*untyped) -> boolish
20
30
 
@@ -24,15 +34,17 @@ module HTTPX
24
34
 
25
35
  private
26
36
 
27
- def initialize: (uri: generic_uri, ?scheme: String, ?username: String, ?password: String, **untyped) -> untyped
37
+ def initialize: (?uri: generic_uri | Array[generic_uri], ?scheme: String, ?username: String, ?password: String, ?no_proxy: Array[generic_uri] | generic_uri, **untyped) -> void
38
+
39
+ def infer_default_auth_scheme: (URI::Generic uri) -> String?
40
+
41
+ def load_authenticator: (String scheme, String username, String password, **untyped) -> _Authenticator
28
42
  end
29
43
 
30
44
  def self.configure: (singleton(Session)) -> void
31
45
 
32
- type proxyParam = Parameters | Hash[Symbol, untyped]
33
-
34
46
  interface _ProxyOptions
35
- def proxy: () -> proxyParam?
47
+ def proxy: () -> Parameters?
36
48
  end
37
49
 
38
50
  def self.extra_options: (Options) -> (Options & _ProxyOptions)
@@ -42,10 +54,7 @@ module HTTPX
42
54
 
43
55
  private
44
56
 
45
- def proxy_error?: (Request request, response) -> bool
46
- end
47
-
48
- module ConnectionMethods
57
+ def proxy_error?: (Request request, response, Options options) -> bool
49
58
  end
50
59
  end
51
60
 
@@ -2,16 +2,19 @@ module HTTPX
2
2
  module Plugins
3
3
  module PushPromise
4
4
  module ResponseMethods
5
+ @__pushed: bool?
6
+
5
7
  def pushed?: () -> boolish
6
8
  def mark_as_pushed!: () -> void
7
9
  end
8
10
 
9
11
  module InstanceMethods
12
+ @promise_headers: Hash[::HTTP2::Stream, Request]?
10
13
  private
11
14
 
12
- def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
13
- def __on_promise_request: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
14
- def __on_promise_response: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
15
+ def promise_headers: () -> Hash[::HTTP2::Stream, Request]
16
+ def __on_promise_request: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
17
+ def __on_promise_response: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
15
18
  end
16
19
  end
17
20
 
@@ -1,6 +1,8 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module RateLimiter
4
+ RATE_LIMIT_CODES: Array[Integer]
5
+
4
6
  def self.load_dependencies: (singleton(Session)) -> void
5
7
 
6
8
  def self.retry_on_rate_limited_response: (_Response) -> bool
@@ -29,7 +29,7 @@ module HTTPX
29
29
 
30
30
  private
31
31
 
32
- def fetch_response: (retriesRequest request, Array[Connection] connections, retriesOptions options) -> (retriesResponse | ErrorResponse)?
32
+ def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> (retriesResponse | ErrorResponse)?
33
33
 
34
34
  def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
35
35
 
@@ -0,0 +1,26 @@
1
+ module HTTPX
2
+ class ServerSideRequestForgeryError < Error
3
+ end
4
+
5
+ module Plugins
6
+ module SsrfFilter
7
+ IPV4_BLACKLIST: Array[IPAddr]
8
+
9
+ IPV6_BLACKLIST: Array[[IPAddr, IPAddr]]
10
+
11
+ def self?.unsafe_ip_address?: (IPAddr) -> bool
12
+
13
+ interface _Options
14
+ def allowed_schemes: () -> Array[String]
15
+ end
16
+
17
+ module InstanceMethods
18
+ end
19
+
20
+ module ConnectionMethods
21
+ end
22
+ end
23
+
24
+ type sessionSsrf = Session & SsrfFilter::InstanceMethods
25
+ end
26
+ end
@@ -27,7 +27,10 @@ module HTTPX
27
27
  type streamRequest = Request & Plugins::Stream::RequestMethods
28
28
 
29
29
  @request: streamRequest
30
+ @options: Options
30
31
  @session: Plugins::sessionStream
32
+ @response_enum: Enumerator[String]?
33
+ @buffered_chunks: Array[String]
31
34
  @on_chunk: ^(String) -> void | nil
32
35
 
33
36
  def each: () { (String) -> void } -> void
@@ -0,0 +1,23 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module WebDav
4
+ module InstanceMethods
5
+ def copy: (String src, String dst) -> (Response | ErrorResponse)
6
+
7
+ def move: (String src, String dst) -> (Response | ErrorResponse)
8
+
9
+ def lock: (String path, ?timeout: Numeric) ?{ (Response response) -> void } -> (Response | ErrorResponse)
10
+
11
+ def unlock: (String path, String? lock_token) -> (Response | ErrorResponse)
12
+
13
+ def mkcol: (String dir) -> Response
14
+
15
+ def propfind: (String path, ?(:acl | String) xml) -> Response
16
+
17
+ def proppatch: (String path, String xml) -> Response
18
+ end
19
+ end
20
+
21
+ type sessionWebDav = Session & WebDav::InstanceMethods
22
+ end
23
+ end
@@ -0,0 +1,37 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module XML
4
+ MIME_TYPES: Regexp
5
+
6
+ module Transcoder
7
+ def self?.encode: (Nokogiri::XML::Node | String xml) -> Encoder
8
+ def self?.decode: (HTTPX::Response response) -> HTTPX::Transcoder::_Decoder
9
+
10
+ class Encoder
11
+ @raw: Nokogiri::XML::Node | String # can be nokogiri object
12
+
13
+ def content_type: () -> String
14
+
15
+ def bytesize: () -> (Integer | Float)
16
+
17
+ def to_s: () -> String
18
+
19
+ private
20
+
21
+ def initialize: (Nokogiri::XML::Node | String xml) -> void
22
+ end
23
+ end
24
+
25
+ module InstanceMethods
26
+ end
27
+
28
+ module ResponseMethods
29
+ def xml: () -> Nokogiri::XML::Node
30
+ end
31
+
32
+ module RequestBodyClassMethods
33
+ end
34
+ end
35
+ type sessionXML = Session & XML::InstanceMethods
36
+ end
37
+ end
data/sig/pool.rbs CHANGED
@@ -1,52 +1,46 @@
1
1
  module HTTPX
2
+ type pool_options = {
3
+ max_connections_per_origin: Integer?,
4
+ pool_timeout: Numeric?
5
+ }
6
+
2
7
  class Pool
8
+ POOL_TIMEOUT: Integer
9
+
3
10
  type resolver_manager = Resolver::Multi | Resolver::System
4
11
 
5
- @resolvers: Hash[Class, resolver_manager]
6
- @timers: Timers
7
- @selector: Selector
8
- @connections: Array[Connection]
12
+ @max_connections_per_origin: Integer
13
+ @pool_timeout: Numeric
14
+ @options: Options
15
+ @resolvers: Hash[Class, Array[resolver_manager]]
16
+ @resolver_mtx: Thread::Mutex
17
+ @connections: Hash[String, Array[Connection]]
18
+ @connection_mtx: Thread::Mutex
19
+ @origin_counters: Hash[String, Integer]
20
+ @origin_conds: Hash[String, ConditionVariable]
9
21
 
10
- def wrap: () { (instance) -> void } -> void
22
+ def pop_connection: () -> Connection?
11
23
 
12
- def empty?: () -> void
24
+ def checkout_connection: (http_uri uri, Options options) -> Connection
13
25
 
14
- def next_tick: () -> void
26
+ def checkin_connection: (Connection connection) -> void
15
27
 
16
- def close: (?Array[Connection] connections) -> void
28
+ def checkout_mergeable_connection: (Connection connection) -> Connection?
17
29
 
18
- def init_connection: (Connection connection, Options options) -> void
30
+ def reset_resolvers: () -> void
19
31
 
20
- def find_connection: (URI::Generic uri, Options options) -> Connection?
32
+ def checkout_resolver: (Options options) -> resolver_manager
21
33
 
22
- def deactivate: (*Array[Connection]) -> void
34
+ def checkin_resolver: (Resolver::Resolver resolver) -> void
23
35
 
24
36
  private
25
37
 
26
- def initialize: () -> void
27
-
28
- def try_clone_connection: (Connection connection, Integer? family) -> Connection
29
-
30
- def resolve_connection: (Connection) -> void
31
-
32
- def on_resolver_connection: (Connection) -> void
33
-
34
- def on_resolver_error: (Connection, StandardError) -> void
35
-
36
- def on_resolver_close: (Resolver::Resolver) -> void
37
-
38
- def register_connection: (Connection) -> void
39
-
40
- def unregister_connection: (Connection, ?bool cleanup) -> void
41
-
42
- def select_connection: (Selector::selectable) -> void
43
-
44
- def deselect_connection: (Selector::selectable) -> Selector::selectable?
38
+ def initialize: (pool_options options) -> void
45
39
 
46
- def coalesce_connections: (Connection coalescable, Connection coalescing) -> void
40
+ def acquire_connection: (http_uri uri, Options options) -> Connection?
47
41
 
48
- def next_timeout: () -> Numeric?
42
+ def checkout_new_connection: (http_uri uri, Options options) -> Connection
49
43
 
50
- def find_resolver_for: (Connection) { (Resolver::Resolver resolver) -> void } -> resolver_manager
44
+ def checkout_new_resolver: (Class resolver_type, Options options) -> resolver_manager
51
45
  end
52
46
  end
data/sig/request/body.rbs CHANGED
@@ -1,10 +1,12 @@
1
1
  module HTTPX
2
2
  class Request::Body
3
+ attr_reader options: Options
4
+
3
5
  @headers: Headers
4
6
  @body: body_encoder?
5
7
  @unbounded_body: bool
6
8
 
7
- def initialize: (Headers headers, Options options) -> void
9
+ def initialize: (Headers h, Options options, **untyped) -> void
8
10
 
9
11
  def each: () { (String) -> void } -> void
10
12
  | () -> Enumerable[String]
@@ -25,16 +27,8 @@ module HTTPX
25
27
 
26
28
  private
27
29
 
28
- def initialize_body: (Options options) -> void
30
+ def self.initialize_body: (Hash[Symbol, untyped] params) -> body_encoder?
29
31
 
30
32
  def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
31
33
  end
32
-
33
- class ProcIO
34
- @block: ^(String) -> void
35
-
36
- def initialize: (^(String) -> void) -> untyped
37
-
38
- def write: (String data) -> Integer
39
- end
40
34
  end
data/sig/request.rbs CHANGED
@@ -14,17 +14,28 @@ module HTTPX
14
14
  attr_reader options: Options
15
15
  attr_reader response: response?
16
16
  attr_reader drain_error: StandardError?
17
+ attr_reader active_timeouts: Array[Symbol]
17
18
 
18
19
  attr_accessor peer_address: ipaddr?
19
20
 
20
21
  attr_writer persistent: bool
21
22
 
23
+ @ping: bool
24
+ @query_params: Hash[interned, untyped]?
22
25
  @trailers: Headers?
23
26
  @informational_status: Integer?
24
27
  @query: String?
25
28
  @drainer: Enumerator[String, void]?
26
29
 
27
- def initialize: (Symbol | String, generic_uri, ?options) -> untyped
30
+ def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
31
+
32
+ def ping?: () -> bool
33
+
34
+ def ping!: () -> void
35
+
36
+ def empty?: () -> bool
37
+
38
+ def close: () -> void
28
39
 
29
40
  def interests: () -> (:r | :w)
30
41
 
@@ -62,6 +73,8 @@ module HTTPX
62
73
 
63
74
  def request_timeout: () -> Numeric?
64
75
 
76
+ def set_timeout_callback: (Symbol event) { (*untyped) -> void } -> void
77
+
65
78
  private
66
79
 
67
80
  def initialize_body: (Options options) -> Transcoder::_Encoder?
@@ -1,7 +1,32 @@
1
1
  module HTTPX
2
2
  module Resolver
3
3
  class Multi
4
- def early_resolve: (Connection connection, ?hostname: String) -> void
4
+ attr_reader resolvers: Array[Native | HTTPS]
5
+
6
+ attr_reader options: Options
7
+
8
+ @current_selector: Selector?
9
+ @current_session: Session?
10
+ @resolver_options: Hash[Symbol, untyped]
11
+ # @errors: Hash[Symbol, untyped]
12
+
13
+ def current_selector=: (Selector s) -> void
14
+
15
+ def current_session=: (Session s) -> void
16
+
17
+ def closed?: () -> bool
18
+
19
+ def empty?: () -> bool
20
+
21
+ def timeout: () -> Numeric?
22
+
23
+ def close: () -> void
24
+
25
+ def connections: () -> Array[Connection]
26
+
27
+ def early_resolve: (Connection connection) -> bool
28
+
29
+ def lazy_resolve: (Connection connection) -> void
5
30
  end
6
31
  end
7
32
  end
@@ -7,8 +7,6 @@ module HTTPX
7
7
  DEFAULTS: Hash[Symbol, untyped]
8
8
  DNS_PORT: Integer
9
9
 
10
- attr_reader family: ip_family
11
-
12
10
  @options: Options
13
11
  @ns_index: Integer
14
12
  @nameserver: Array[String]
@@ -23,6 +21,7 @@ module HTTPX
23
21
  @write_buffer: Buffer
24
22
  @large_packet: Buffer?
25
23
  @io: UDP | TCP
24
+ @name: String?
26
25
 
27
26
  attr_reader state: Symbol
28
27
 
@@ -44,7 +43,9 @@ module HTTPX
44
43
 
45
44
  def consume: () -> void
46
45
 
47
- def do_retry: (?Numeric? loop_time) -> void
46
+ def schedule_retry: () -> void
47
+
48
+ def do_retry: (String host, Connection connection, Numeric interval) -> void
48
49
 
49
50
  def dread: (Integer) -> void
50
51
  | () -> void
@@ -66,6 +67,8 @@ module HTTPX
66
67
  def handle_error: (NativeResolveError | StandardError) -> void
67
68
 
68
69
  def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
70
+
71
+ def close_or_resolve: () -> void
69
72
  end
70
73
  end
71
74
  end
@@ -6,8 +6,17 @@ module HTTPX
6
6
 
7
7
  RECORD_TYPES: Hash[Integer, singleton(Resolv::DNS::Resource)]
8
8
 
9
+ attr_reader family: ip_family
10
+
11
+ attr_reader options: Options
12
+
13
+ attr_writer current_selector: Selector?
14
+
15
+ attr_writer current_session: Session?
16
+
17
+ attr_accessor multi: Multi?
18
+
9
19
  @record_type: singleton(Resolv::DNS::Resource)
10
- @options: Options
11
20
  @resolver_options: Hash[Symbol, untyped]
12
21
  @queries: Hash[String, Connection]
13
22
  @system_resolver: Resolv::Hosts
@@ -20,15 +29,25 @@ module HTTPX
20
29
 
21
30
  def empty?: () -> bool
22
31
 
32
+ def each_connection: () { (Connection connection) -> void } -> void
33
+
23
34
  def emit_addresses: (Connection connection, ip_family family, Array[IPAddr], ?bool early_resolve) -> void
24
35
 
25
36
  private
26
37
 
27
38
  def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
28
39
 
29
- def initialize: (ip_family? family, options options) -> void
40
+ def initialize: (ip_family? family, Options options) -> void
41
+
42
+ def early_resolve: (Connection connection, ?hostname: String) -> bool
43
+
44
+ def set_resolver_callbacks: () -> void
45
+
46
+ def resolve_connection: (Connection connection) -> void
47
+
48
+ def emit_connection_error: (Connection connection, StandardError error) -> void
30
49
 
31
- def early_resolve: (Connection connection, ?hostname: String) -> void
50
+ def close_resolver: (Resolver resolver) -> void
32
51
 
33
52
  def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
34
53
 
data/sig/resolver.rbs CHANGED
@@ -28,12 +28,16 @@ module HTTPX
28
28
 
29
29
  def self?.cached_lookup_set: (String hostname, ip_family family, Array[dns_result] addresses) -> void
30
30
 
31
- def self?.lookup: (String hostname, Numeric ttl) -> Array[IPAddr]?
31
+ def self?.lookup: (String hostname, Hash[String, Array[dns_result]] lookups, Numeric ttl) -> Array[IPAddr]?
32
32
 
33
33
  def self?.generate_id: () -> Integer
34
34
 
35
35
  def self?.encode_dns_query: (String hostname, ?type: dns_resource, ?message_id: Integer) -> String
36
36
 
37
37
  def self?.decode_dns_answer: (String) -> dns_decoding_response
38
+
39
+ def self?.lookup_synchronize: [U] () { (Hash[String, Array[dns_result]] lookups) -> U } -> U
40
+
41
+ def self?.id_synchronize: () { () -> void } -> void
38
42
  end
39
43
  end
@@ -4,8 +4,8 @@ module HTTPX
4
4
  include _ToS
5
5
  include _ToStr
6
6
 
7
- attr_reader encoding: Encoding | String
8
- attr_reader encodings: Array[Encoding | String]
7
+ attr_reader encoding: Encoding
8
+ attr_reader encodings: Array[String]
9
9
 
10
10
  @response: Response
11
11
  @headers: Headers
@@ -5,11 +5,11 @@ module HTTPX
5
5
  @encoding: Encoding
6
6
  @buffer: StringIO | Tempfile
7
7
 
8
- def initialize: (threshold_size: Integer, ?bytesize: Integer, ?encoding: Encoding | String) -> void
8
+ def initialize: (threshold_size: Integer, ?bytesize: Integer, ?encoding: Encoding) -> void
9
9
 
10
10
  def size: () -> Integer
11
11
 
12
- def write: (String) -> void
12
+ def write: (String chunk) -> Integer
13
13
 
14
14
  def to_s: () -> String
15
15