httpx 1.6.2 → 1.7.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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_11_0.md +3 -3
  3. data/doc/release_notes/1_6_3.md +47 -0
  4. data/doc/release_notes/1_7_0.md +149 -0
  5. data/lib/httpx/adapters/datadog.rb +1 -1
  6. data/lib/httpx/adapters/faraday.rb +1 -1
  7. data/lib/httpx/adapters/sentry.rb +1 -1
  8. data/lib/httpx/altsvc.rb +3 -1
  9. data/lib/httpx/connection/http1.rb +14 -15
  10. data/lib/httpx/connection/http2.rb +16 -15
  11. data/lib/httpx/connection.rb +118 -110
  12. data/lib/httpx/domain_name.rb +1 -1
  13. data/lib/httpx/extensions.rb +0 -14
  14. data/lib/httpx/headers.rb +2 -2
  15. data/lib/httpx/io/ssl.rb +1 -1
  16. data/lib/httpx/loggable.rb +14 -2
  17. data/lib/httpx/options.rb +60 -17
  18. data/lib/httpx/plugins/auth/digest.rb +44 -4
  19. data/lib/httpx/plugins/auth.rb +87 -4
  20. data/lib/httpx/plugins/aws_sdk_authentication.rb +0 -1
  21. data/lib/httpx/plugins/callbacks.rb +15 -1
  22. data/lib/httpx/plugins/cookies/cookie.rb +1 -0
  23. data/lib/httpx/plugins/digest_auth.rb +4 -5
  24. data/lib/httpx/plugins/fiber_concurrency.rb +16 -1
  25. data/lib/httpx/plugins/grpc/grpc_encoding.rb +1 -1
  26. data/lib/httpx/plugins/grpc.rb +2 -2
  27. data/lib/httpx/plugins/internal_telemetry.rb +1 -1
  28. data/lib/httpx/plugins/ntlm_auth.rb +5 -3
  29. data/lib/httpx/plugins/oauth.rb +162 -56
  30. data/lib/httpx/plugins/proxy/http.rb +37 -9
  31. data/lib/httpx/plugins/rate_limiter.rb +2 -2
  32. data/lib/httpx/plugins/response_cache/file_store.rb +1 -0
  33. data/lib/httpx/plugins/response_cache.rb +16 -9
  34. data/lib/httpx/plugins/retries.rb +55 -16
  35. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  36. data/lib/httpx/plugins/stream.rb +59 -8
  37. data/lib/httpx/plugins/stream_bidi.rb +87 -22
  38. data/lib/httpx/pool.rb +65 -21
  39. data/lib/httpx/request.rb +13 -14
  40. data/lib/httpx/resolver/https.rb +100 -34
  41. data/lib/httpx/resolver/multi.rb +12 -27
  42. data/lib/httpx/resolver/native.rb +68 -38
  43. data/lib/httpx/resolver/resolver.rb +46 -29
  44. data/lib/httpx/resolver/system.rb +63 -39
  45. data/lib/httpx/resolver.rb +97 -29
  46. data/lib/httpx/response/body.rb +2 -0
  47. data/lib/httpx/response.rb +22 -6
  48. data/lib/httpx/selector.rb +44 -20
  49. data/lib/httpx/session.rb +23 -33
  50. data/lib/httpx/transcoder/body.rb +1 -1
  51. data/lib/httpx/transcoder/deflate.rb +13 -8
  52. data/lib/httpx/transcoder/json.rb +1 -1
  53. data/lib/httpx/transcoder/multipart/decoder.rb +4 -4
  54. data/lib/httpx/transcoder/multipart/encoder.rb +1 -1
  55. data/lib/httpx/transcoder/multipart.rb +16 -8
  56. data/lib/httpx/transcoder/utils/body_reader.rb +1 -2
  57. data/lib/httpx/transcoder/utils/deflater.rb +1 -2
  58. data/lib/httpx/transcoder.rb +4 -6
  59. data/lib/httpx/version.rb +1 -1
  60. data/sig/altsvc.rbs +3 -0
  61. data/sig/chainable.rbs +3 -3
  62. data/sig/connection.rbs +13 -6
  63. data/sig/loggable.rbs +5 -1
  64. data/sig/options.rbs +6 -2
  65. data/sig/plugins/auth/digest.rbs +6 -0
  66. data/sig/plugins/auth.rbs +28 -4
  67. data/sig/plugins/basic_auth.rbs +3 -3
  68. data/sig/plugins/callbacks.rbs +3 -0
  69. data/sig/plugins/digest_auth.rbs +2 -4
  70. data/sig/plugins/fiber_concurrency.rbs +6 -0
  71. data/sig/plugins/ntlm_auth.rbs +2 -2
  72. data/sig/plugins/oauth.rbs +46 -15
  73. data/sig/plugins/rate_limiter.rbs +1 -1
  74. data/sig/plugins/response_cache/file_store.rbs +2 -0
  75. data/sig/plugins/response_cache.rbs +4 -0
  76. data/sig/plugins/retries.rbs +8 -2
  77. data/sig/plugins/stream.rbs +13 -3
  78. data/sig/plugins/stream_bidi.rbs +5 -7
  79. data/sig/pool.rbs +1 -1
  80. data/sig/resolver/https.rbs +7 -0
  81. data/sig/resolver/multi.rbs +2 -9
  82. data/sig/resolver/native.rbs +1 -1
  83. data/sig/resolver/resolver.rbs +9 -8
  84. data/sig/resolver/system.rbs +4 -2
  85. data/sig/resolver.rbs +12 -3
  86. data/sig/response.rbs +3 -0
  87. data/sig/selector.rbs +2 -0
  88. data/sig/session.rbs +8 -8
  89. data/sig/transcoder/multipart.rbs +4 -2
  90. data/sig/transcoder.rbs +5 -1
  91. metadata +5 -1
@@ -4,20 +4,18 @@ module HTTPX
4
4
  module Transcoder
5
5
  module_function
6
6
 
7
- def normalize_keys(key, value, cond = nil, &block)
8
- if cond && cond.call(value)
9
- block.call(key.to_s, value)
10
- elsif value.respond_to?(:to_ary)
7
+ def normalize_keys(key, value, transcoder = self, &block)
8
+ if value.respond_to?(:to_ary)
11
9
  if value.empty?
12
10
  block.call("#{key}[]")
13
11
  else
14
12
  value.to_ary.each do |element|
15
- normalize_keys("#{key}[]", element, cond, &block)
13
+ transcoder.normalize_keys("#{key}[]", element, transcoder, &block)
16
14
  end
17
15
  end
18
16
  elsif value.respond_to?(:to_hash)
19
17
  value.to_hash.each do |child_key, child_value|
20
- normalize_keys("#{key}[#{child_key}]", child_value, cond, &block)
18
+ transcoder.normalize_keys("#{key}[#{child_key}]", child_value, transcoder, &block)
21
19
  end
22
20
  else
23
21
  block.call(key.to_s, value)
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "1.6.2"
4
+ VERSION = "1.7.0"
5
5
  end
data/sig/altsvc.rbs CHANGED
@@ -1,6 +1,7 @@
1
1
  module HTTPX
2
2
  module AltSvc
3
3
  module ConnectionMixin
4
+ H2_ALTSVC_SCHEMES: Array[String]
4
5
 
5
6
  def send: (Request request) -> void
6
7
 
@@ -11,6 +12,8 @@ module HTTPX
11
12
  def match_altsvcs?: (URI::Generic uri) -> bool
12
13
 
13
14
  def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
15
+
16
+ def altsvc_match?: (uri uri, uri other_uri) -> bool
14
17
  end
15
18
 
16
19
  type altsvc_params = Hash[String, untyped]
data/sig/chainable.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Chainable
3
- def request: (*Request, **untyped) -> Array[response]
4
- | (Request, **untyped) -> response
3
+ def request: (Request, **untyped) -> response
4
+ | (*Request, **untyped) -> Array[response]
5
5
  | (verb, uri | [uri], **untyped) -> response
6
6
  | (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
7
7
  | (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
@@ -12,7 +12,7 @@ module HTTPX
12
12
  def with: (options) -> Session
13
13
  | (options) { (Session) -> void } -> void
14
14
 
15
- def plugin: (:auth, ?options) -> Plugins::sessionAuthorization
15
+ def plugin: (:auth, ?options) -> Plugins::sessionAuth
16
16
  | (:basic_auth, ?options) -> Plugins::sessionBasicAuth
17
17
  | (:digest_auth, ?options) -> Plugins::sessionDigestAuth
18
18
  | (:ntlm_auth, ?options) -> Plugins::sessionNTLMAuth
data/sig/connection.rbs CHANGED
@@ -46,6 +46,7 @@ module HTTPX
46
46
  @exhausted: bool
47
47
  @cloned: bool
48
48
  @coalesced_connection: instance?
49
+ @altsvc_connection: instance?
49
50
  @sibling: instance?
50
51
  @main_sibling: bool
51
52
 
@@ -60,15 +61,15 @@ module HTTPX
60
61
 
61
62
  def addresses?: () -> boolish
62
63
 
63
- def match?: (URI::Generic uri, Options options) -> bool
64
+ def match?: (http_uri uri, Options options) -> bool
64
65
 
65
66
  def mergeable?: (Connection connection) -> bool
66
67
 
67
68
  def coalesce!: (instance connection) -> void
68
69
 
69
- def coalescable?: (Connection connection) -> bool
70
+ def coalesced?: () -> boolish
70
71
 
71
- def create_idle: (?Hash[Symbol, untyped] options) -> instance
72
+ def coalescable?: (Connection connection) -> bool
72
73
 
73
74
  def merge: (Connection connection) -> void
74
75
 
@@ -76,7 +77,9 @@ module HTTPX
76
77
 
77
78
  def connecting?: () -> bool
78
79
 
79
- def io_connected?: () -> bool
80
+ def current_context?: () -> bool
81
+
82
+ def io_connected?: () -> boolish
80
83
 
81
84
  def inflight?: () -> boolish
82
85
 
@@ -90,6 +93,8 @@ module HTTPX
90
93
 
91
94
  def close: () -> void
92
95
 
96
+ def force_close: (?bool delete_pending) -> void
97
+
93
98
  def force_reset: (?bool cloned) -> void
94
99
 
95
100
  def reset: () -> void
@@ -112,6 +117,8 @@ module HTTPX
112
117
 
113
118
  def disconnect: () -> void
114
119
 
120
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
121
+
115
122
  private
116
123
 
117
124
  def initialize: (http_uri uri, Options options) -> void
@@ -130,6 +137,8 @@ module HTTPX
130
137
 
131
138
  def send_request_to_parser: (Request request) -> void
132
139
 
140
+ def enqueue_pending_requests_from_parser: (HTTP1 | HTTP2 parser) -> void
141
+
133
142
  def build_parser: (?String protocol) -> (Object & _Parser)
134
143
 
135
144
  def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
@@ -142,8 +151,6 @@ module HTTPX
142
151
 
143
152
  def build_socket: (?Array[Resolver::Entry]? addrs) -> (TCP | SSL | UNIX)
144
153
 
145
- def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
146
-
147
154
  def handle_error: (StandardError error, ?Request? request) -> void
148
155
 
149
156
  def close_sibling: () -> void
data/sig/loggable.rbs CHANGED
@@ -12,6 +12,10 @@ module HTTPX
12
12
 
13
13
  def log_exception: (Exception error, ?level: Integer, ?color: Symbol, ?debug_level: Integer, ?debug: _IOLogger?) -> void
14
14
 
15
- def log_redact: (_ToS text, ?bool should_redact) -> String
15
+ def log_redact_headers: (_ToS text) -> String
16
+
17
+ def log_redact_body: (_ToS text) -> String
18
+
19
+ def log_redact: (_ToS text, bool should_redact) -> String
16
20
  end
17
21
  end
data/sig/options.rbs CHANGED
@@ -17,9 +17,11 @@ module HTTPX
17
17
 
18
18
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
19
19
  REQUEST_BODY_IVARS: Array[Symbol]
20
+ USER_AGENT: String
20
21
 
21
22
  type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
22
23
  type timeout = Hash[timeout_type, Numeric?]
24
+ type redact_value = :headers | :body | bool
23
25
 
24
26
  def self.new: (?options) -> instance
25
27
 
@@ -136,7 +138,7 @@ module HTTPX
136
138
 
137
139
  def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
138
140
 
139
- def merge: (_ToHash[Symbol, untyped] other) -> instance
141
+ def merge: (Object & _ToHash[Symbol, untyped] other) -> (instance | self)
140
142
 
141
143
  def to_hash: () -> Hash[Symbol, untyped]
142
144
 
@@ -146,6 +148,8 @@ module HTTPX
146
148
 
147
149
  def initialize: (?options options) -> void
148
150
 
151
+ def do_initialize: (?options options) -> void
152
+
149
153
  def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
150
154
 
151
155
  # integer
@@ -175,7 +179,7 @@ module HTTPX
175
179
  def option_io: (io_option value) -> io_option
176
180
  def option_fallback_protocol: (String value) -> String
177
181
  def option_debug: (_IOLogger value) -> _IOLogger
178
- def option_debug_redact: (bool value) -> bool
182
+ def option_debug_redact: (redact_value value) -> redact_value
179
183
  def option_compress_request_body: (bool value) -> bool
180
184
  def option_decompress_response_body: (bool value) -> bool
181
185
  def option_persistent: (bool value) -> bool
@@ -2,9 +2,13 @@ module HTTPX
2
2
  module Plugins
3
3
  module Authentication
4
4
  class Digest
5
+ Error: singleton(HTTPX::Error)
6
+
7
+
5
8
  @user: String
6
9
  @password: String
7
10
  @hashed: bool
11
+ @nonce: Integer
8
12
 
9
13
  def can_authenticate?: (String? authenticate) -> boolish
10
14
 
@@ -19,6 +23,8 @@ module HTTPX
19
23
  def make_cnonce: () -> String
20
24
 
21
25
  def next_nonce: () -> Integer
26
+
27
+ def raise_format_error: () -> void
22
28
  end
23
29
  end
24
30
  end
data/sig/plugins/auth.rbs CHANGED
@@ -1,13 +1,37 @@
1
1
  module HTTPX
2
2
  module Plugins
3
- module Authorization
3
+ module Auth
4
+ interface _AuthOptions
5
+ def auth_header_value: () -> (String | ^(Request request) -> string)?
6
+
7
+ def auth_header_type: () -> String?
8
+ end
9
+
4
10
  module InstanceMethods
5
- def authorization: (string token) -> instance
11
+ @auth_header_value: String
12
+ @skip_auth_header_value: bool
13
+
14
+ def authorization: (?string token, ?auth_header_type: string) ?{ (Request) -> string } -> instance
15
+
16
+ def bearer_auth: (?string token) ?{ (Request) -> string } -> instance
17
+
18
+ def skip_auth_header: [T] { () -> T } -> T
19
+
20
+ def reset_auth_header_value!: () -> void
21
+
22
+ private
23
+
24
+ def generate_auth_token: () -> String?
25
+ end
26
+
27
+ module RequestMethods
28
+ def authorize: (String auth_value) -> void
29
+ end
6
30
 
7
- def bearer_auth: (string token) -> instance
31
+ module AuthRetries
8
32
  end
9
33
  end
10
34
 
11
- type sessionAuthorization = Session & Authorization::InstanceMethods
35
+ type sessionAuth = Session & Auth::InstanceMethods
12
36
  end
13
37
  end
@@ -1,15 +1,15 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module BasicAuth
4
- def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session) klass) -> void
5
5
 
6
- def self.configure: (singleton(Session)) -> void
6
+ def self.configure: (singleton(Session) klass) -> void
7
7
 
8
8
  module InstanceMethods
9
9
  def basic_auth: (string user, string password) -> instance
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuth = sessionAuthorization & BasicAuth::InstanceMethods
13
+ type sessionBasicAuth = sessionAuth & BasicAuth::InstanceMethods
14
14
  end
15
15
  end
@@ -31,6 +31,9 @@ module HTTPX
31
31
 
32
32
  def emit_or_callback_error: (*untyped) -> void
33
33
  end
34
+
35
+ module ConnectionMethods
36
+ end
34
37
  end
35
38
 
36
39
  type sessionCallbacks = Session & Callbacks::InstanceMethods
@@ -1,21 +1,19 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module DigestAuth
4
- DigestError: singleton(Error)
5
-
6
4
  interface _DigestOptions
7
5
  def digest: () -> Authentication::Digest?
8
6
  end
9
7
 
10
8
  def self.extra_options: (Options) -> (Options & _DigestOptions)
11
9
 
12
- def self.load_dependencies: (*untyped) -> void
10
+ def self.load_dependencies: (singleton(Session) klass) -> void
13
11
 
14
12
  module InstanceMethods
15
13
  def digest_auth: (string user, string password, ?hashed: bool) -> instance
16
14
  end
17
15
  end
18
16
 
19
- type sessionDigestAuth = sessionAuthorization & DigestAuth::InstanceMethods
17
+ type sessionDigestAuth = sessionAuth & DigestAuth::InstanceMethods
20
18
  end
21
19
  end
@@ -43,6 +43,12 @@ module HTTPX
43
43
  end
44
44
  end
45
45
 
46
+ module FiberConcurrencyStream
47
+ module StreamResponseMethods
48
+ def close: () -> void
49
+ end
50
+ end
51
+
46
52
  type request = Request & RequestMethods
47
53
  end
48
54
 
@@ -8,7 +8,7 @@ module HTTPX
8
8
 
9
9
  def self.extra_options: (Options) -> (Options & _NTLMOptions)
10
10
 
11
- def self.load_dependencies: (*untyped) -> void
11
+ def self.load_dependencies: (singleton(Session) klass) -> void
12
12
 
13
13
  module InstanceMethods
14
14
  def ntlm_auth: (string user, string password, ?string? domain) -> instance
@@ -16,6 +16,6 @@ module HTTPX
16
16
 
17
17
  end
18
18
 
19
- type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
19
+ type sessionNTLMAuth = sessionAuth & NTLMAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -15,19 +15,18 @@ module HTTPX
15
15
  SUPPORTED_AUTH_METHODS: ::Array[token_auth_method]
16
16
 
17
17
  class OAuthSession
18
- attr_reader grant_type: grant_type
19
-
20
- attr_reader client_id: String
21
-
22
- attr_reader client_secret: String
23
-
24
18
  attr_reader access_token: String?
25
19
 
26
20
  attr_reader refresh_token: String?
27
21
 
28
- attr_reader scope: Array[String]?
29
-
30
- attr_reader audience: String?
22
+ @issuer: http_uri
23
+ @grant_type: grant_type
24
+ @client_id: String
25
+ @client_secret: String
26
+ @token_endpoint: http_uri?
27
+ @scope: Array[String]?
28
+ @audience: String?
29
+ @token_endpoint_auth_method: String?
31
30
 
32
31
  def initialize: (
33
32
  issuer: uri,
@@ -37,32 +36,64 @@ module HTTPX
37
36
  ?refresh_token: String?,
38
37
  ?scope: (Array[String] | String)?,
39
38
  ?token_endpoint: String?,
40
- ?response_type: String?,
41
39
  ?grant_type: String?,
42
40
  ?token_endpoint_auth_method: ::String,
43
41
  ?audience: ::String
44
42
  ) -> void
45
43
 
46
- def token_endpoint: () -> String
44
+ def token_endpoint: () -> uri
45
+
46
+ def token_endpoint_auth_method: () -> String
47
47
 
48
- def token_endpoint_auth_method: () -> token_auth_method
48
+ def reset!: () -> void
49
49
 
50
- def load: (Session http) -> void
50
+ def fetch_access_token: (sessionOAuth http) -> String
51
51
 
52
52
  def merge: (instance | Hash[untyped, untyped] other) -> instance
53
+
54
+ private
55
+
56
+
57
+ def load: (sessionOAuth http) -> void
53
58
  end
54
59
 
55
- interface _AwsSdkOptions
60
+ interface _OAuthOptions
56
61
  def oauth_session: () -> OAuthSession?
62
+
63
+ def oauth_options: () -> {
64
+ issuer: uri,
65
+ client_id: String,
66
+ client_secret: String,
67
+ ?access_token: String?,
68
+ ?refresh_token: String?,
69
+ ?scope: (Array[String] | String)?,
70
+ ?token_endpoint: String?,
71
+ ?response_type: String?,
72
+ ?grant_type: String?,
73
+ ?token_endpoint_auth_method: ::String,
74
+ ?audience: ::String
75
+ }?
57
76
  end
58
77
 
59
78
  module InstanceMethods
79
+ attr_reader oauth_session: OAuthSession
80
+ @options: Options & _OAuthOptions
81
+
60
82
  def oauth_auth: (**untyped args) -> instance
61
83
 
62
84
  def with_access_token: () -> instance
85
+
86
+ def refresh_oauth_tokens!: () -> void
87
+ end
88
+
89
+ module OAuthRetries
90
+ def self?.response_oauth_error?: (response res) -> bool
91
+
92
+ module InstanceMethods
93
+ end
63
94
  end
64
95
  end
65
96
 
66
- type sessionOAuth = Session & OAuth::InstanceMethods
97
+ type sessionOAuth = Session & Auth::InstanceMethods & OAuth::InstanceMethods
67
98
  end
68
99
  end
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.load_dependencies: (singleton(Session)) -> void
7
7
 
8
- def self.retry_on_rate_limited_response: (_Response) -> bool
8
+ def self.retry_on_rate_limited_response?: (_Response) -> bool
9
9
 
10
10
  def self.retry_after_rate_limit: (untyped, response) -> Numeric?
11
11
  end
@@ -2,6 +2,8 @@ module HTTPX
2
2
  module Plugins
3
3
  module ResponseCache
4
4
  class FileStore
5
+ CRLF: String
6
+
5
7
  @dir: Pathname
6
8
 
7
9
  include _ResponseCacheStore
@@ -39,6 +39,7 @@ module HTTPX
39
39
 
40
40
  module RequestMethods
41
41
  attr_accessor cached_response: cacheResponse?
42
+ attr_reader options: cacheOptions
42
43
 
43
44
  @response_cache_key: String
44
45
 
@@ -51,6 +52,9 @@ module HTTPX
51
52
  attr_writer original_request: cacheRequest
52
53
 
53
54
  @cache: bool
55
+ @cache_control: Array[String]?
56
+ @vary: Array[String]?
57
+ @date: Time?
54
58
 
55
59
  def original_request: () -> cacheRequest?
56
60
 
@@ -6,13 +6,18 @@ module HTTPX
6
6
  RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
7
7
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
8
8
  DEFAULT_JITTER: ^(Numeric) -> Numeric
9
+ BACKOFF_ALGORITHMS: Array[Symbol]
10
+
11
+ def self?.retry_after_polynomial_backoff: (retriesRequest request, response response) -> Numeric
12
+
13
+ def self?.retry_after_exponential_backoff: (retriesRequest request, response response) -> Numeric
9
14
 
10
15
  interface _RetryCallback
11
16
  def call: (response response) -> bool?
12
17
  end
13
18
 
14
19
  interface _RetriesOptions
15
- def retry_after: () -> Numeric?
20
+ def retry_after: () -> (^(retriesRequest request, response response) -> Numeric | Numeric)?
16
21
 
17
22
  def retry_jitter: () -> ^(Numeric jitter) -> Numeric
18
23
 
@@ -38,10 +43,11 @@ module HTTPX
38
43
 
39
44
  def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
40
45
 
46
+ def prepare_to_retry: (Request & RequestMethods request, response response) -> void
41
47
  end
42
48
 
43
49
  module RequestMethods
44
- @options: Options & _RetriesOptions
50
+ attr_reader options: retriesOptions
45
51
 
46
52
  attr_accessor retries: Integer
47
53
 
@@ -1,11 +1,21 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Stream
4
+ STREAM_REQUEST_OPTIONS: Hash[Symbol, untyped]
5
+
6
+ interface _StreamOptions
7
+ def stream: () -> boolish
8
+
9
+ def retry_stream_response_class: () -> singleton(StreamResponse)
10
+ end
11
+
4
12
  module InstanceMethods
13
+ @options: Options & _StreamOptions
14
+
5
15
  private
6
16
 
7
- def request: (*Request, ?stream: bool, **untyped?) -> (response | Array[response] | StreamResponse)
8
- | (*untyped, ?stream: bool, **untyped?) -> (response | Array[response] | StreamResponse)
17
+ def request: (*Request, **untyped?) -> (response | Array[response] | StreamResponse)
18
+ | (*untyped, **untyped?) -> (response | Array[response] | StreamResponse)
9
19
  end
10
20
 
11
21
  module RequestMethods
@@ -30,7 +40,7 @@ module HTTPX
30
40
  type streamRequest = Request & Plugins::Stream::RequestMethods
31
41
 
32
42
  attr_reader request: streamRequest
33
- @options: Options
43
+ @options: Options & _StreamOptions
34
44
 
35
45
  @session: Plugins::sessionStream
36
46
  @response_enum: Enumerator[String]?
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.extra_options: (Options) -> (Options)
7
7
 
8
- class HTTP2Bidi < Connection::HTTP2
8
+ module HTTP2Methods
9
9
  @lock: Thread::Mutex
10
10
 
11
11
  private
@@ -16,7 +16,7 @@ module HTTPX
16
16
  end
17
17
 
18
18
  class BidiBuffer < Buffer
19
- @parent_thread: Thread
19
+ @buffer_mutex: Thread::Mutex
20
20
  @oob_mutex: Thread::Mutex
21
21
  @oob_buffer: String
22
22
 
@@ -24,6 +24,8 @@ module HTTPX
24
24
  end
25
25
 
26
26
  class Signal
27
+ attr_reader error: Exception?
28
+
27
29
  @closed: bool
28
30
  @pipe_read: IO
29
31
  @pipe_write: IO
@@ -32,7 +34,7 @@ module HTTPX
32
34
 
33
35
  def wakeup: () -> void
34
36
 
35
- def mergeable?: () -> bool
37
+ def inflight?: () -> bool
36
38
 
37
39
  def terminate: () -> void
38
40
  end
@@ -55,10 +57,6 @@ module HTTPX
55
57
 
56
58
  module ConnectionMethods
57
59
  @write_buffer: BidiBuffer
58
-
59
- private
60
-
61
- def parser_type: (String protocol) -> (singleton(Connection::HTTP1) | singleton(Connection::HTTP2) | singleton(HTTP2Bidi))
62
60
  end
63
61
 
64
62
  end
data/sig/pool.rbs CHANGED
@@ -15,7 +15,7 @@ module HTTPX
15
15
  @options: Options
16
16
  @resolvers: Hash[Class, Array[resolver_manager]]
17
17
  @resolver_mtx: Thread::Mutex
18
- @connections: Hash[String, Array[Connection]]
18
+ @connections: Array[Connection]
19
19
  @connection_mtx: Thread::Mutex
20
20
  @connections_counter: Integer
21
21
  @max_connections_cond: ConditionVariable
@@ -11,11 +11,14 @@ module HTTPX
11
11
  attr_reader family: ip_family
12
12
 
13
13
  @options: Options
14
+ @_timeouts: Array[Numeric]
15
+ @timeouts: Hash[String, Array[Numeric]]
14
16
  @queries: Hash[String, Connection]
15
17
  @requests: Hash[Request, String]
16
18
  @connections: Array[Connection]
17
19
  @uri: http_uri
18
20
  @uri_addresses: Array[String]?
21
+ @name: String?
19
22
  @resolver: Resolv::DNS
20
23
  @resolver_connection: Connection
21
24
 
@@ -29,6 +32,8 @@ module HTTPX
29
32
 
30
33
  def resolver_connection: () -> Connection
31
34
 
35
+ def send_request: (String hostname, Connection connection) -> void
36
+
32
37
  def on_response: (Request, response) -> void
33
38
 
34
39
  def parse: (Request request, Response response) -> void
@@ -40,6 +45,8 @@ module HTTPX
40
45
  def decode_response_body: (Response) -> dns_decoding_response
41
46
 
42
47
  def reset_hostname: (String hostname, ?reset_candidates: bool) -> Connection?
48
+
49
+ def close_or_resolve: (?bool should_deactivate) -> void
43
50
  end
44
51
  end
45
52
  end
@@ -8,7 +8,8 @@ module HTTPX
8
8
  @current_selector: Selector?
9
9
  @current_session: Session?
10
10
  @resolver_options: Hash[Symbol, untyped]
11
- # @errors: Hash[Symbol, untyped]
11
+
12
+ def state: () -> String
12
13
 
13
14
  def current_selector=: (Selector s) -> void
14
15
 
@@ -16,14 +17,6 @@ module HTTPX
16
17
 
17
18
  def closed?: () -> bool
18
19
 
19
- def empty?: () -> bool
20
-
21
- def timeout: () -> Numeric?
22
-
23
- def close: () -> void
24
-
25
- def connections: () -> Array[Connection]
26
-
27
20
  def early_resolve: (Connection connection) -> bool
28
21
 
29
22
  def lazy_resolve: (Connection connection) -> void
@@ -64,7 +64,7 @@ module HTTPX
64
64
 
65
65
  def transition: (Symbol nextstate) -> void
66
66
 
67
- def handle_error: (NativeResolveError | StandardError) -> void
67
+ def reset_query: () -> void
68
68
 
69
69
  def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
70
70