httpx 0.22.4 → 0.23.0

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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_22_5.md +6 -0
  3. data/doc/release_notes/0_23_0.md +42 -0
  4. data/lib/httpx/adapters/datadog.rb +12 -2
  5. data/lib/httpx/adapters/faraday.rb +1 -1
  6. data/lib/httpx/adapters/sentry.rb +15 -5
  7. data/lib/httpx/adapters/webmock.rb +2 -2
  8. data/lib/httpx/buffer.rb +4 -0
  9. data/lib/httpx/callbacks.rb +3 -3
  10. data/lib/httpx/chainable.rb +4 -4
  11. data/lib/httpx/connection/http1.rb +2 -2
  12. data/lib/httpx/connection/http2.rb +2 -3
  13. data/lib/httpx/connection.rb +31 -11
  14. data/lib/httpx/io/udp.rb +2 -0
  15. data/lib/httpx/io/unix.rb +1 -5
  16. data/lib/httpx/io.rb +0 -10
  17. data/lib/httpx/options.rb +16 -2
  18. data/lib/httpx/plugins/authentication/digest.rb +1 -1
  19. data/lib/httpx/plugins/aws_sdk_authentication.rb +1 -3
  20. data/lib/httpx/plugins/aws_sigv4.rb +1 -1
  21. data/lib/httpx/plugins/compression/brotli.rb +4 -4
  22. data/lib/httpx/plugins/compression/deflate.rb +12 -7
  23. data/lib/httpx/plugins/compression/gzip.rb +7 -5
  24. data/lib/httpx/plugins/compression.rb +9 -8
  25. data/lib/httpx/plugins/digest_authentication.rb +1 -4
  26. data/lib/httpx/plugins/follow_redirects.rb +1 -1
  27. data/lib/httpx/plugins/grpc/message.rb +3 -1
  28. data/lib/httpx/plugins/grpc.rb +3 -3
  29. data/lib/httpx/plugins/h2c.rb +5 -9
  30. data/lib/httpx/plugins/internal_telemetry.rb +16 -0
  31. data/lib/httpx/plugins/multipart.rb +14 -2
  32. data/lib/httpx/plugins/proxy/http.rb +4 -4
  33. data/lib/httpx/plugins/proxy.rb +65 -31
  34. data/lib/httpx/plugins/response_cache.rb +2 -2
  35. data/lib/httpx/plugins/retries.rb +49 -2
  36. data/lib/httpx/plugins/upgrade/h2.rb +3 -3
  37. data/lib/httpx/plugins/upgrade.rb +4 -7
  38. data/lib/httpx/plugins/webdav.rb +7 -7
  39. data/lib/httpx/pool.rb +7 -3
  40. data/lib/httpx/request.rb +23 -13
  41. data/lib/httpx/resolver/https.rb +37 -20
  42. data/lib/httpx/resolver/multi.rb +1 -6
  43. data/lib/httpx/resolver/native.rb +128 -36
  44. data/lib/httpx/resolver.rb +26 -14
  45. data/lib/httpx/response.rb +14 -16
  46. data/lib/httpx/session.rb +1 -0
  47. data/lib/httpx/transcoder/body.rb +0 -1
  48. data/lib/httpx/transcoder/chunker.rb +0 -1
  49. data/lib/httpx/transcoder/form.rb +0 -1
  50. data/lib/httpx/transcoder/json.rb +0 -1
  51. data/lib/httpx/transcoder/xml.rb +0 -1
  52. data/lib/httpx/transcoder.rb +0 -2
  53. data/lib/httpx/version.rb +1 -1
  54. data/lib/httpx.rb +0 -1
  55. data/sig/buffer.rbs +1 -0
  56. data/sig/chainable.rbs +3 -3
  57. data/sig/connection.rbs +17 -6
  58. data/sig/errors.rbs +9 -0
  59. data/sig/httpx.rbs +3 -3
  60. data/sig/io/ssl.rbs +17 -0
  61. data/sig/io/tcp.rbs +57 -0
  62. data/sig/io/udp.rbs +20 -0
  63. data/sig/io/unix.rbs +10 -0
  64. data/sig/options.rbs +5 -1
  65. data/sig/plugins/compression.rbs +6 -2
  66. data/sig/plugins/cookies/jar.rbs +2 -2
  67. data/sig/plugins/grpc.rbs +3 -3
  68. data/sig/plugins/h2c.rbs +1 -1
  69. data/sig/plugins/proxy.rbs +1 -5
  70. data/sig/plugins/response_cache.rbs +1 -1
  71. data/sig/plugins/retries.rbs +28 -8
  72. data/sig/plugins/upgrade.rbs +5 -3
  73. data/sig/request.rbs +6 -2
  74. data/sig/resolver/https.rbs +3 -1
  75. data/sig/resolver/native.rbs +7 -2
  76. data/sig/resolver/resolver.rbs +0 -2
  77. data/sig/resolver/system.rbs +2 -0
  78. data/sig/resolver.rbs +8 -4
  79. data/sig/response.rbs +6 -2
  80. data/sig/session.rbs +10 -10
  81. data/sig/transcoder/xml.rbs +1 -1
  82. data/sig/transcoder.rbs +4 -5
  83. metadata +11 -5
  84. data/lib/httpx/registry.rb +0 -85
  85. data/sig/registry.rbs +0 -13
data/sig/connection.rbs CHANGED
@@ -17,9 +17,7 @@ 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
 
24
22
  attr_reader type: io_type
25
23
  attr_reader origin: URI::Generic
@@ -36,7 +34,13 @@ module HTTPX
36
34
  @write_buffer: Buffer
37
35
  @inflight: Integer
38
36
  @keep_alive_timeout: Numeric?
37
+ @timeout: Numeric?
38
+ @current_timeout: Numeric?
39
39
  @total_timeout: Numeric?
40
+ @io: TCP | SSL | UNIX
41
+ @parser: HTTP1 | HTTP2 | _Parser
42
+ @connected_at: Float
43
+ @response_received_at: Float
40
44
 
41
45
  def addresses: () -> Array[ipaddr]?
42
46
 
@@ -77,6 +81,8 @@ module HTTPX
77
81
 
78
82
  def deactivate: () -> void
79
83
 
84
+ def open?: () -> bool
85
+
80
86
  def raise_timeout_error: (Numeric interval) -> void
81
87
 
82
88
  private
@@ -91,17 +97,20 @@ module HTTPX
91
97
 
92
98
  def send_pending: () -> void
93
99
 
94
- def parser: () -> _Parser
100
+ def parser: () -> (HTTP1 | HTTP2 | _Parser)
95
101
 
96
102
  def send_request_to_parser: (Request request) -> void
97
103
 
98
- def build_parser: () -> _Parser
99
- | (String) -> _Parser
104
+ def build_parser: (?String protocol) -> (HTTP1 | HTTP2)
100
105
 
101
- def set_parser_callbacks: (_Parser) -> void
106
+ def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
102
107
 
103
108
  def transition: (Symbol) -> void
104
109
 
110
+ def handle_transition: (Symbol) -> void
111
+
112
+ def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
113
+
105
114
  def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
106
115
 
107
116
  def handle_error: (StandardError) -> void
@@ -113,5 +122,7 @@ module HTTPX
113
122
  def write_timeout_callback: (Request request, Numeric write_timeout) -> void
114
123
 
115
124
  def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
125
+
126
+ def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
116
127
  end
117
128
  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
 
@@ -55,4 +61,7 @@ module HTTPX
55
61
 
56
62
  def initialize: (Connection connection, String hostname, ?String message) -> untyped
57
63
  end
64
+
65
+ class MisdirectedRequestError < HTTPError
66
+ end
58
67
  end
data/sig/httpx.rbs CHANGED
@@ -8,9 +8,9 @@ module HTTPX
8
8
  type uri = URI::HTTP | URI::HTTPS | string
9
9
  type generic_uri = String | URI::Generic
10
10
 
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
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"
14
14
 
15
15
  type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
16
16
 
data/sig/io/ssl.rbs ADDED
@@ -0,0 +1,17 @@
1
+ module HTTPX
2
+ IPRegex: Regexp
3
+
4
+ class TLSError < OpenSSL::SSL::SSLError
5
+ end
6
+
7
+ class SSL < TCP
8
+ TLS_OPTIONS: Hash[Symbol, untyped]
9
+
10
+ def can_verify_peer?: () -> bool
11
+
12
+ def verify_hostname: (String host) -> bool
13
+
14
+ # :nocov:
15
+ def try_ssl_connect: () -> void
16
+ end
17
+ end
data/sig/io/tcp.rbs ADDED
@@ -0,0 +1,57 @@
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
+ def initialize: (URI::Generic origin, Array[ipaddr]? addresses, options options) -> void
18
+
19
+ def add_addresses: (Array[ipaddr] addrs) -> void
20
+
21
+ def to_io: () -> ::IO
22
+
23
+ def protocol: () -> String
24
+
25
+ def connect: () -> void
26
+
27
+ private
28
+
29
+ # :nocov:
30
+ def try_connect: () -> void
31
+
32
+ public
33
+
34
+ def read: (Integer size, ?(Buffer | String) buffer) -> (0 | nil | untyped)
35
+
36
+ def write: (Buffer buffer) -> Integer?
37
+
38
+ def close: () -> void
39
+
40
+ def connected?: () -> bool
41
+
42
+ def closed?: () -> bool
43
+
44
+ # :nocov:
45
+ def inspect: () -> ::String
46
+
47
+ private
48
+
49
+ def build_socket: () -> Socket
50
+
51
+ def transition: (Symbol nextstate) -> void
52
+
53
+ def do_transition: (Symbol nextstate) -> void
54
+
55
+ def log_transition_state: (Symbol nextstate) -> void
56
+ end
57
+ 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: (URI::HTTP | URI::HTTPS origin, Array[String]? addresses, options options) -> void
9
+ end
10
+ end
data/sig/options.rbs CHANGED
@@ -2,6 +2,7 @@ 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
@@ -38,11 +39,14 @@ module HTTPX
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?
49
+ attr_reader transport: "unix" | nil
46
50
 
47
51
  # transport_options
48
52
  attr_reader transport_options: Hash[untyped, untyped]?
@@ -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,17 @@ 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
26
  def compression_threshold_size: () -> Integer?
23
27
 
24
- def encodings: () -> encodings_registry?
28
+ def encodings: () -> Hash[String, _Compressor]
25
29
  end
26
30
 
27
31
  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
 
data/sig/plugins/grpc.rbs CHANGED
@@ -39,8 +39,8 @@ module HTTPX
39
39
 
40
40
  def self?.encode: (String bytes, ?deflater: Compression::_Deflater?) -> String
41
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
42
+ def self?.decode: (String message, encodings: Array[String], encoders: Hash[String, Compression::_Compressor]) -> String
43
+ | (String message, encodings: Array[String], encoders: Hash[String, Compression::_Compressor]) { (String) -> void } -> void
44
44
 
45
45
  def self?.cancel: (Request) -> void
46
46
 
@@ -65,7 +65,7 @@ module HTTPX
65
65
  module ResponseMethods
66
66
  def merge_headers: (headers_input trailers) -> void
67
67
 
68
- def encoders: () -> Compression::encodings_registry
68
+ def encoders: () -> Hash[String, Compression::_Compressor]
69
69
  end
70
70
 
71
71
  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
@@ -35,11 +35,7 @@ module HTTPX
35
35
  def self.extra_options: (Options) -> (Options & _ProxyOptions)
36
36
 
37
37
  module InstanceMethods
38
- private
39
-
40
- def proxy_uris: (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri, username: String, password: String }
41
- | (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri }
42
- | (generic_uri, Options & _ProxyOptions) -> nil
38
+ @__proxy_uris: Array[generic_uri]
43
39
  end
44
40
  end
45
41
 
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module ResponseCache
4
- CACHEABLE_VERBS: Array[Symbol]
4
+ CACHEABLE_VERBS: Array[verb]
5
5
 
6
6
  def self?.cacheable_request?: (Request request) -> bool
7
7
  def self?.cacheable_response?: (response response) -> bool
@@ -2,40 +2,60 @@ module HTTPX
2
2
  module Plugins
3
3
  module Retries
4
4
  MAX_RETRIES: Integer
5
- IDEMPOTENT_METHODS: Array[verb]
5
+ IDEMPOTENT_METHODS: Array[String]
6
6
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
7
7
  DEFAULT_JITTER: ^(Numeric) -> Numeric
8
8
 
9
9
  interface _RetryCallback
10
- def call: (response) -> bool?
10
+ def call: (response response) -> bool?
11
11
  end
12
12
 
13
13
  interface _RetriesOptions
14
14
  def retry_after: () -> Numeric?
15
15
 
16
- def retry_jitter: () -> ^(Numeric) -> Numeric
16
+ def retry_jitter: () -> ^(Numeric jitter) -> Numeric
17
17
 
18
- def max_retries: () -> Integer?
18
+ def max_retries: () -> Integer
19
19
 
20
20
  def retry_change_requests: () -> boolish
21
21
 
22
22
  def retry_on: () -> _RetryCallback?
23
23
  end
24
24
 
25
- def self.extra_options: (Options) -> (Options & _RetriesOptions)
25
+ def self.extra_options: (Options options) -> retriesOptions
26
26
 
27
27
  module InstanceMethods
28
28
  def max_retries: (int) -> instance
29
29
 
30
30
  private
31
31
 
32
- def __repeatable_request?: (Request, Options) -> boolish
33
- def __retryable_error?: (_Exception) -> bool
32
+ def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
33
+
34
+ def __retryable_error?: (_Exception error) -> bool
35
+
36
+ def __try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
37
+
34
38
  end
35
39
 
36
40
  module RequestMethods
37
- def retries: () -> Integer
41
+ @options: Options & _RetriesOptions
42
+
43
+ attr_accessor retries: Integer
44
+
45
+ attr_writer partial_response: Response?
46
+
47
+ def response=: (retriesResponse | ErrorResponse response) -> void
38
48
  end
49
+
50
+ module ResponseMethods
51
+ def from_partial_response: (Response response) -> void
52
+ end
53
+
54
+ type retriesOptions = Options & _RetriesOptions
55
+
56
+ type retriesRequest = Request & RequestMethods
57
+
58
+ type retriesResponse = Response & ResponseMethods
39
59
  end
40
60
 
41
61
  type sessionRetries = Session & Retries::InstanceMethods
@@ -1,18 +1,20 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Upgrade
4
- type handlers_registry = Registry[Symbol, Class]
4
+ interface _Upgrader
5
+ def call: (Connection connection, Request request, Response response) -> void
6
+ end
5
7
 
6
8
  def self.configure: (singleton(Session)) -> void
7
9
 
8
10
  interface _UpgradeOptions
9
- def upgrade_handlers: () -> handlers_registry?
11
+ def upgrade_handlers: () -> Hash[String, _Upgrader]
10
12
  end
11
13
 
12
14
  def self.extra_options: (Options) -> (Options & _UpgradeOptions)
13
15
 
14
16
  module ConnectionMethods
15
- attr_reader upgrade_protocol: Symbol?
17
+ attr_reader upgrade_protocol: String?
16
18
  attr_reader hijacked: boolish
17
19
 
18
20
  def hijack_io: () -> void
data/sig/request.rbs CHANGED
@@ -6,8 +6,8 @@ module HTTPX
6
6
  METHODS: Array[Symbol]
7
7
  USER_AGENT: String
8
8
 
9
- attr_reader verb: Symbol
10
- attr_reader uri: URI::Generic
9
+ attr_reader verb: verb
10
+ attr_reader uri: URI::HTTP | URI::HTTPS
11
11
  attr_reader headers: Headers
12
12
  attr_reader body: Body
13
13
  attr_reader state: Symbol
@@ -56,6 +56,10 @@ module HTTPX
56
56
 
57
57
  def request_timeout: () -> Numeric
58
58
 
59
+ private
60
+
61
+ def initialize_body: (Options options) -> Transcoder::_Encoder?
62
+
59
63
  class Body
60
64
  @headers: Headers
61
65
  @body: body_encoder?
@@ -34,7 +34,9 @@ module HTTPX
34
34
 
35
35
  def build_request: (String hostname) -> Request
36
36
 
37
- def decode_response_body: (Response) -> Array[dns_result]?
37
+ def decode_response_body: (Response) -> dns_decoding_response
38
+
39
+ def reset_hostname: (String hostname, ?reset_candidates: bool) -> Connection?
38
40
  end
39
41
  end
40
42
  end
@@ -11,7 +11,8 @@ module HTTPX
11
11
 
12
12
  @options: Options
13
13
  @ns_index: Integer
14
- @nameserver: Array[String]?
14
+ @nameserver: Array[String]
15
+ @socket_type: :udp | :tcp
15
16
  @ndots: Integer
16
17
  @start_timeout: Float?
17
18
  @search: Array[String]
@@ -20,6 +21,8 @@ module HTTPX
20
21
  @connections: Array[Connection]
21
22
  @read_buffer: String
22
23
  @write_buffer: Buffer
24
+ @large_packet: Buffer?
25
+ @io: UDP | TCP
23
26
 
24
27
  attr_reader state: Symbol
25
28
 
@@ -54,11 +57,13 @@ module HTTPX
54
57
 
55
58
  def generate_candidates: (String) -> Array[String]
56
59
 
57
- def build_socket: () -> void
60
+ def build_socket: () -> (UDP | TCP)
58
61
 
59
62
  def transition: (Symbol nextstate) -> void
60
63
 
61
64
  def handle_error: (NativeResolveError | StandardError) -> void
65
+
66
+ def reset_hostname: (String hostname, ?reset_candidates: bool) -> void
62
67
  end
63
68
  end
64
69
  end
@@ -6,8 +6,6 @@ module HTTPX
6
6
 
7
7
  RECORD_TYPES: Hash[Integer, singleton(Resolv::DNS::Resource)]
8
8
 
9
- attr_reader family: ip_family?
10
-
11
9
  @record_type: singleton(Resolv::DNS::Resource)
12
10
  @options: Options
13
11
  @resolver_options: Hash[Symbol, untyped]
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  @resolver: Resolv::DNS
7
7
 
8
+ attr_reader family: nil
9
+
8
10
  def <<: (Connection) -> void
9
11
 
10
12
  private
data/sig/resolver.rbs CHANGED
@@ -2,8 +2,6 @@ module HTTPX
2
2
  type ipaddr = IPAddr | String
3
3
 
4
4
  module Resolver
5
- extend Registry[Symbol, Class]
6
-
7
5
  RESOLVE_TIMEOUT: Integer | Float
8
6
 
9
7
  @lookup_mutex: Thread::Mutex
@@ -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
data/sig/response.rbs CHANGED
@@ -41,14 +41,14 @@ module HTTPX
41
41
  def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
42
42
  def no_data?: () -> bool
43
43
 
44
- def decode:(String format, ?untyped options) -> untyped
44
+ def decode:(Transcoder::_Decode transcoder, ?untyped options) -> untyped
45
45
 
46
46
  class Body
47
47
  include _Reader
48
48
  include _ToS
49
49
  include _ToStr
50
50
 
51
- attr_reader encoding: String
51
+ attr_reader encoding: Encoding | String
52
52
 
53
53
  @response: Response
54
54
  @headers: Headers
@@ -108,10 +108,14 @@ module HTTPX
108
108
 
109
109
  attr_reader request: Request
110
110
 
111
+ attr_reader response: Response?
112
+
111
113
  def status: () -> (Integer | _ToS)
112
114
 
113
115
  def uri: () -> URI::Generic
114
116
 
117
+ def close: () -> void
118
+
115
119
  private
116
120
 
117
121
  def initialize: (Request, Exception, options) -> untyped
data/sig/session.rbs CHANGED
@@ -11,13 +11,11 @@ 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, generic_uri, ?options) -> Request
21
19
 
22
20
  private
23
21
 
@@ -27,7 +25,7 @@ module HTTPX
27
25
  def pool: -> Pool
28
26
  def on_response: (Request, response) -> void
29
27
  def on_promise: (untyped, untyped) -> void
30
- def fetch_response: (Request request, untyped, untyped) -> response?
28
+ def fetch_response: (Request request, Array[Connection] connections, untyped options) -> response?
31
29
 
32
30
  def find_connection: (Request, Array[Connection] connections, Options options) -> Connection
33
31
 
@@ -35,18 +33,20 @@ module HTTPX
35
33
 
36
34
  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
35
 
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]
36
+ def build_requests: (verb, uri, options) -> Array[Request]
37
+ | (Array[[verb, uri, options]], options) -> Array[Request]
38
+ | (Array[[verb, uri]], options) -> Array[Request]
39
+ | (verb, _Each[[uri, options]], Options) -> Array[Request]
40
+ | (verb, _Each[uri], options) -> Array[Request]
43
41
 
44
- def build_connection: (URI::Generic, Options) -> Connection
42
+ def build_connection: (URI::HTTP | URI::HTTPS uri, Options options) -> Connection
45
43
 
46
44
  def send_requests: (*Request) -> Array[response]
47
45
 
48
46
  def _send_requests: (Array[Request]) -> Array[Connection]
49
47
 
50
48
  def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
49
+
50
+ attr_reader self.default_options: Options
51
51
  end
52
52
  end
@@ -1,5 +1,5 @@
1
1
  module HTTPX::Transcoder
2
- module XML
2
+ module Xml
3
3
 
4
4
  def self?.encode: (untyped xml) -> Encoder
5
5
  def self?.decode: (HTTPX::Response response) -> _Decoder
data/sig/transcoder.rbs CHANGED
@@ -4,11 +4,6 @@ module HTTPX
4
4
  type body_encoder = Transcoder::_Encoder | _Each[String]
5
5
 
6
6
  module Transcoder
7
- def self?.registry: (String tag) -> _Encode
8
- | () -> Hash[String, _Encode]
9
-
10
- def self?.register: (String tag, _Encode handler) -> void
11
-
12
7
  def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?(^(untyped value) -> bool | nil) cond) { (String, ?untyped) -> U } -> U
13
8
 
14
9
  def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth) -> void
@@ -17,6 +12,10 @@ module HTTPX
17
12
  def encode: (untyped payload) -> body_encoder
18
13
  end
19
14
 
15
+ interface _Decode
16
+ def decode: (HTTPX::Response response) -> _Decoder
17
+ end
18
+
20
19
  interface _Encoder
21
20
  def bytesize: () -> (Integer | Float)
22
21
  end