httpx 1.7.1 → 1.7.3

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/doc/release_notes/1_7_2.md +6 -0
  4. data/doc/release_notes/1_7_3.md +29 -0
  5. data/lib/httpx/adapters/webmock.rb +3 -4
  6. data/lib/httpx/connection/http1.rb +0 -1
  7. data/lib/httpx/connection/http2.rb +41 -30
  8. data/lib/httpx/connection.rb +18 -4
  9. data/lib/httpx/plugins/auth/digest.rb +2 -1
  10. data/lib/httpx/plugins/auth.rb +21 -2
  11. data/lib/httpx/plugins/cookies/cookie.rb +34 -11
  12. data/lib/httpx/plugins/cookies/jar.rb +93 -18
  13. data/lib/httpx/plugins/cookies.rb +7 -3
  14. data/lib/httpx/plugins/expect.rb +26 -2
  15. data/lib/httpx/plugins/fiber_concurrency.rb +2 -4
  16. data/lib/httpx/plugins/follow_redirects.rb +3 -1
  17. data/lib/httpx/plugins/ntlm_auth.rb +1 -1
  18. data/lib/httpx/plugins/rate_limiter.rb +19 -19
  19. data/lib/httpx/plugins/retries.rb +11 -7
  20. data/lib/httpx/plugins/ssrf_filter.rb +1 -0
  21. data/lib/httpx/plugins/stream_bidi.rb +17 -1
  22. data/lib/httpx/request.rb +1 -1
  23. data/lib/httpx/resolver/resolver.rb +5 -0
  24. data/lib/httpx/selector.rb +4 -4
  25. data/lib/httpx/session.rb +6 -5
  26. data/lib/httpx/version.rb +1 -1
  27. data/sig/chainable.rbs +1 -1
  28. data/sig/connection/http2.rbs +8 -4
  29. data/sig/connection.rbs +3 -0
  30. data/sig/plugins/auth.rbs +6 -0
  31. data/sig/plugins/cookies/cookie.rbs +3 -2
  32. data/sig/plugins/cookies/jar.rbs +11 -0
  33. data/sig/plugins/cookies.rbs +2 -0
  34. data/sig/plugins/expect.rbs +17 -2
  35. data/sig/plugins/proxy/socks4.rbs +4 -0
  36. data/sig/plugins/rate_limiter.rbs +2 -2
  37. data/sig/plugins/response_cache.rbs +3 -3
  38. data/sig/plugins/retries.rbs +17 -13
  39. data/sig/plugins/stream_bidi.rbs +3 -0
  40. data/sig/request.rbs +1 -0
  41. data/sig/resolver/native.rbs +2 -0
  42. data/sig/resolver/resolver.rbs +2 -2
  43. data/sig/selector.rbs +4 -0
  44. metadata +7 -3
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- InsecureRedirectError = Class.new(Error)
4
+ class InsecureRedirectError < Error
5
+ end
6
+
5
7
  module Plugins
6
8
  #
7
9
  # This plugin adds support for automatically following redirect (status 30X) responses.
@@ -46,7 +46,7 @@ module HTTPX
46
46
 
47
47
  if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"])
48
48
  request.transition(:idle)
49
- request.headers.get("authorization").pop
49
+ request.unauthorize!
50
50
  request.authorize(ntlm.authenticate(request, probe_response.headers["www-authenticate"]).encode("utf-8"))
51
51
  super(request)
52
52
  else
@@ -16,25 +16,7 @@ module HTTPX
16
16
 
17
17
  class << self
18
18
  def load_dependencies(klass)
19
- klass.plugin(:retries, retry_after: method(:retry_after_rate_limit))
20
- end
21
-
22
- # Servers send the "Retry-After" header field to indicate how long the
23
- # user agent ought to wait before making a follow-up request. When
24
- # sent with a 503 (Service Unavailable) response, Retry-After indicates
25
- # how long the service is expected to be unavailable to the client.
26
- # When sent with any 3xx (Redirection) response, Retry-After indicates
27
- # the minimum time that the user agent is asked to wait before issuing
28
- # the redirected request.
29
- #
30
- def retry_after_rate_limit(_, response)
31
- return unless response.is_a?(Response)
32
-
33
- retry_after = response.headers["retry-after"]
34
-
35
- return unless retry_after
36
-
37
- Utils.parse_retry_after(retry_after)
19
+ klass.plugin(:retries)
38
20
  end
39
21
  end
40
22
 
@@ -52,6 +34,24 @@ module HTTPX
52
34
  def rate_limit_error?(response)
53
35
  response.is_a?(Response) && RATE_LIMIT_CODES.include?(response.status)
54
36
  end
37
+
38
+ # Servers send the "Retry-After" header field to indicate how long the
39
+ # user agent ought to wait before making a follow-up request. When
40
+ # sent with a 503 (Service Unavailable) response, Retry-After indicates
41
+ # how long the service is expected to be unavailable to the client.
42
+ # When sent with any 3xx (Redirection) response, Retry-After indicates
43
+ # the minimum time that the user agent is asked to wait before issuing
44
+ # the redirected request.
45
+ #
46
+ def when_to_retry(_, response, options)
47
+ return super unless response.is_a?(Response)
48
+
49
+ retry_after = response.headers["retry-after"]
50
+
51
+ return super unless retry_after
52
+
53
+ Utils.parse_retry_after(retry_after)
54
+ end
55
55
  end
56
56
  end
57
57
 
@@ -148,10 +148,7 @@ module HTTPX
148
148
  log { "failed to get response, #{request.retries} tries to go..." }
149
149
  prepare_to_retry(request, response)
150
150
 
151
- retry_after = options.retry_after
152
- retry_after = retry_after.call(request, response) if retry_after.respond_to?(:call)
153
-
154
- if retry_after
151
+ if (retry_after = when_to_retry(request, response, options))
155
152
  # apply jitter
156
153
  if (jitter = request.options.retry_jitter)
157
154
  retry_after = jitter.call(retry_after)
@@ -201,6 +198,12 @@ module HTTPX
201
198
  request.transition(:idle)
202
199
  end
203
200
 
201
+ def when_to_retry(request, response, options)
202
+ retry_after = options.retry_after
203
+ retry_after = retry_after.call(request, response) if retry_after.respond_to?(:call)
204
+ retry_after
205
+ end
206
+
204
207
  #
205
208
  # Attempt to set the request to perform a partial range request.
206
209
  # This happens if the peer server accepts byte-range requests, and
@@ -237,14 +240,15 @@ module HTTPX
237
240
  def initialize(*args)
238
241
  super
239
242
  @retries = @options.max_retries
243
+ @partial_response = nil
240
244
  end
241
245
 
242
246
  def response=(response)
243
- if @partial_response
247
+ if (partial_response = @partial_response)
244
248
  if response.is_a?(Response) && response.status == 206
245
- response.from_partial_response(@partial_response)
249
+ response.from_partial_response(partial_response)
246
250
  else
247
- @partial_response.close
251
+ partial_response.close
248
252
  end
249
253
  @partial_response = nil
250
254
  end
@@ -106,6 +106,7 @@ module HTTPX
106
106
  error = ServerSideRequestForgeryError.new("#{request.uri} URI scheme not allowed")
107
107
  error.set_backtrace(caller)
108
108
  response = ErrorResponse.new(request, error)
109
+ request.response = response
109
110
  request.emit(:response, response)
110
111
  response
111
112
  end
@@ -61,7 +61,7 @@ module HTTPX
61
61
  def handle_stream(stream, request)
62
62
  return super unless @options.stream
63
63
 
64
- request.on(:body) do
64
+ request.flush_buffer_on_body do
65
65
  next unless request.headers_sent
66
66
 
67
67
  handle(request, stream)
@@ -189,6 +189,10 @@ module HTTPX
189
189
  !@closed
190
190
  end
191
191
 
192
+ def force_close(*)
193
+ terminate
194
+ end
195
+
192
196
  def terminate
193
197
  return if @closed
194
198
 
@@ -202,6 +206,8 @@ module HTTPX
202
206
  terminate
203
207
  end
204
208
 
209
+ alias_method :on_io_error, :on_error
210
+
205
211
  # noop (the owner connection will take of it)
206
212
  def handle_socket_timeout(interval); end
207
213
  end
@@ -254,9 +260,14 @@ module HTTPX
254
260
  super
255
261
  @headers_sent = false
256
262
  @closed = false
263
+ @flush_buffer_on_body_cb = nil
257
264
  @mutex = Thread::Mutex.new
258
265
  end
259
266
 
267
+ def flush_buffer_on_body(&cb)
268
+ @flush_buffer_on_body_cb = on(:body, &cb)
269
+ end
270
+
260
271
  def closed?
261
272
  return super unless @options.stream
262
273
 
@@ -280,6 +291,11 @@ module HTTPX
280
291
  case nextstate
281
292
  when :idle
282
293
  headers_sent = false
294
+
295
+ if @flush_buffer_on_body_cb
296
+ callbacks(:body).delete(@flush_buffer_on_body_cb)
297
+ @flush_buffer_on_body_cb = nil
298
+ end
283
299
  when :waiting_for_chunk
284
300
  return unless @state == :body
285
301
  when :body
data/lib/httpx/request.rb CHANGED
@@ -91,7 +91,7 @@ module HTTPX
91
91
  raise UnsupportedSchemeError, "#{@uri}: #{@uri.scheme}: unsupported URI scheme" unless ALLOWED_URI_SCHEMES.include?(@uri.scheme)
92
92
 
93
93
  @state = :idle
94
- @response = @peer_address = @informational_status = nil
94
+ @response = @drainer = @peer_address = @informational_status = nil
95
95
  @ping = false
96
96
  @persistent = @options.persistent
97
97
  @active_timeouts = []
@@ -119,6 +119,11 @@ module HTTPX
119
119
  end
120
120
  end
121
121
 
122
+ def on_io_error(e)
123
+ on_error(e)
124
+ force_close(true)
125
+ end
126
+
122
127
  def on_error(error)
123
128
  handle_error(error)
124
129
  disconnect
@@ -204,8 +204,7 @@ module HTTPX
204
204
  rescue IOError => e
205
205
  (Array(r) + Array(w)).each do |sel|
206
206
  # TODO: is there a way to cheaply find the IO associated with the error?
207
- sel.on_error(e)
208
- sel.force_close(true)
207
+ sel.on_io_error(e)
209
208
  end
210
209
  rescue StandardError => e
211
210
  (Array(r) + Array(w)).each do |sel|
@@ -249,8 +248,9 @@ module HTTPX
249
248
  when :rw then rw_wait(io, interval)
250
249
  end
251
250
  rescue IOError => e
252
- io.on_error(e)
253
- io.force_close(true)
251
+ io.on_io_error(e)
252
+
253
+ return
254
254
  rescue StandardError => e
255
255
  io.on_error(e)
256
256
 
data/lib/httpx/session.rb CHANGED
@@ -140,9 +140,10 @@ module HTTPX
140
140
  end
141
141
  selector.deregister(connection)
142
142
 
143
+ # do not check-in connections only created for Happy Eyeballs
143
144
  return if cloned
144
145
 
145
- return if @closing && connection.state == :closed
146
+ return if @closing && connection.state == :closed && !connection.used?
146
147
 
147
148
  connection.log(level: 2) { "check-in connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
148
149
  @pool.checkin_connection(connection)
@@ -177,16 +178,15 @@ module HTTPX
177
178
 
178
179
  # returns the HTTPX::Connection through which the +request+ should be sent through.
179
180
  def find_connection(request_uri, selector, options)
180
- log(level: 2) { "finding connection for #{request_uri}..." }
181
181
  if (connection = selector.find_connection(request_uri, options))
182
182
  connection.idling if connection.state == :closed
183
- connection.log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
183
+ log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
184
184
  return connection
185
185
  end
186
186
 
187
187
  connection = @pool.checkout_connection(request_uri, options)
188
188
 
189
- connection.log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
189
+ log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
190
190
 
191
191
  case connection.state
192
192
  when :idle
@@ -240,7 +240,7 @@ module HTTPX
240
240
 
241
241
  return unless response && response.finished?
242
242
 
243
- log(level: 2) { "response fetched" }
243
+ log(level: 2) { "response##{response.object_id} fetched" }
244
244
 
245
245
  response
246
246
  end
@@ -249,6 +249,7 @@ module HTTPX
249
249
  def send_request(request, selector, options = request.options)
250
250
  error = begin
251
251
  catch(:resolve_error) do
252
+ log(level: 2) { "finding connection for request##{request.object_id}..." }
252
253
  connection = find_connection(request.uri, selector, options)
253
254
  connection.send(request)
254
255
  end
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.7.1"
4
+ VERSION = "1.7.3"
5
5
  end
data/sig/chainable.rbs CHANGED
@@ -29,7 +29,7 @@ module HTTPX
29
29
  | (:proxy, ?options) -> (Plugins::sessionProxy & Plugins::httpProxy)
30
30
  | (:push_promise, ?options) -> Plugins::sessionPushPromise
31
31
  | (:retries, ?options) -> Plugins::sessionRetries
32
- | (:rate_limiter, ?options) -> Session
32
+ | (:rate_limiter, ?options) -> Plugins::sessionRateLimiter
33
33
  | (:stream, ?options) -> Plugins::sessionStream
34
34
  | (:stream_bidi, ?options) -> Plugins::sessionStreamBidi
35
35
  | (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
@@ -79,6 +79,8 @@ module HTTPX
79
79
 
80
80
  def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
81
81
 
82
+ def on_stream_half_close: (::HTTP2::Stream stream, Request request) -> void
83
+
82
84
  def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
83
85
 
84
86
  def on_frame: (string bytes) -> void
@@ -87,13 +89,15 @@ module HTTPX
87
89
 
88
90
  def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
89
91
 
90
- def on_frame_sent: (::HTTP2::frame) -> void
92
+ def on_frame_sent: (::HTTP2::frame frame) -> void
93
+
94
+ def frame_with_extra_info: (::HTTP2::frame frame) -> Hash[Symbol, untyped]
91
95
 
92
- def on_frame_received: (::HTTP2::frame) -> void
96
+ def on_frame_received: (::HTTP2::frame frame) -> void
93
97
 
94
- def on_altsvc: (String origin, ::HTTP2::frame) -> void
98
+ def on_altsvc: (String origin, ::HTTP2::frame frame) -> void
95
99
 
96
- def on_promise: (::HTTP2::Stream) -> void
100
+ def on_promise: (::HTTP2::Stream stream) -> void
97
101
 
98
102
  def on_origin: (String) -> void
99
103
 
data/sig/connection.rbs CHANGED
@@ -37,6 +37,7 @@ module HTTPX
37
37
  @read_buffer: Buffer
38
38
  @write_buffer: Buffer
39
39
  @inflight: Integer
40
+ @max_concurrent_requests: Integer?
40
41
  @keep_alive_timeout: Numeric?
41
42
  @timeout: Numeric?
42
43
  @current_timeout: Numeric?
@@ -119,6 +120,8 @@ module HTTPX
119
120
 
120
121
  def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
121
122
 
123
+ def on_io_error: (IOError error) -> void
124
+
122
125
  private
123
126
 
124
127
  def initialize: (http_uri uri, Options options) -> void
data/sig/plugins/auth.rbs CHANGED
@@ -29,6 +29,12 @@ module HTTPX
29
29
  end
30
30
 
31
31
  module RequestMethods
32
+ @auth_token_value: String?
33
+
34
+ def authorized?: () -> bool
35
+
36
+ def unauthorize!: () -> void
37
+
32
38
  def authorize: (String auth_value) -> void
33
39
  end
34
40
 
@@ -31,6 +31,8 @@ module HTTPX
31
31
  def cookie_value: () -> String
32
32
  alias to_s cookie_value
33
33
 
34
+ def match?: (String | cookie_attributes name_or_options) -> bool
35
+
34
36
  def valid_for_uri?: (http_uri uri) -> bool
35
37
 
36
38
  def self.new: (Cookie) -> instance
@@ -41,8 +43,7 @@ module HTTPX
41
43
 
42
44
  private
43
45
 
44
- def initialize: (cookie_attributes) -> untyped
45
- | (_ToS, _ToS, ?cookie_attributes) -> untyped
46
+ def initialize: (_ToS name, _ToS value, ?cookie_attributes) -> void
46
47
 
47
48
  def acceptable_from_uri?: (uri) -> bool
48
49
 
@@ -6,11 +6,20 @@ module HTTPX
6
6
  include Enumerable[Cookie]
7
7
 
8
8
  @cookies: Array[Cookie]
9
+ @mtx: Thread::Mutex
9
10
 
10
11
  def parse: (String set_cookie) -> void
11
12
 
13
+ def get: (String | cookie_attributes name_or_options) -> Cookie?
14
+
15
+ def get_all: (String | cookie_attributes name_or_options) -> Array[Cookie]
16
+
17
+ def set: (_ToS | Cookie name, ?(cookie_attributes | _ToS) value_or_options) -> void
18
+
12
19
  def add: (Cookie name, ?String path) -> void
13
20
 
21
+ def delete: (String | Cookie | cookie_attributes name_or_options) -> void
22
+
14
23
  def []: (http_uri) -> Array[Cookie]
15
24
 
16
25
  def each: (?http_uri?) { (Cookie) -> void } -> void
@@ -21,6 +30,8 @@ module HTTPX
21
30
  private
22
31
 
23
32
  def initialize: (?_Each[cookie] cookies) -> untyped
33
+
34
+ def synchronize: [T] { () -> T } -> T
24
35
  end
25
36
  end
26
37
  end
@@ -15,6 +15,8 @@ module HTTPX
15
15
 
16
16
  module InstanceMethods
17
17
  def cookies: () -> Jar
18
+
19
+ def make_jar: (*untyped) -> Jar
18
20
  end
19
21
 
20
22
  module HeadersMethods
@@ -2,14 +2,29 @@ module HTTPX
2
2
  module Plugins
3
3
  module Expect
4
4
  EXPECT_TIMEOUT: Integer
5
+ NOEXPECT_STORE_MUTEX: Thread::Mutex
6
+
7
+ self.@no_expect_store: Store
8
+ def self.no_expect_store: () -> Store
9
+
10
+ def self.extra_options: (Options) -> (Options & _ExpectOptions)
11
+
12
+ class Store
13
+ @store: Array[String]
14
+ @mutex: Thread::Mutex
15
+
16
+ def include?: (String host) -> bool
17
+
18
+ def add: (String host) -> void
19
+
20
+ def delete: (String host) -> void
21
+ end
5
22
 
6
23
  interface _ExpectOptions
7
24
  def expect_timeout: () -> Integer?
8
25
 
9
26
  def expect_threshold_size: () -> Integer?
10
27
  end
11
-
12
- def self.extra_options: (Options) -> (Options & _ExpectOptions)
13
28
  end
14
29
  end
15
30
  end
@@ -5,6 +5,10 @@ module HTTPX
5
5
  module Plugins
6
6
  module Proxy
7
7
  module Socks4
8
+ VERSION: Integer
9
+ CONNECT: Integer
10
+ GRANTED: Integer
11
+ PROTOCOLS: Array[String]
8
12
 
9
13
  module ConnectionMethods
10
14
  def __socks4_proxy_connect: () -> void
@@ -5,11 +5,11 @@ module HTTPX
5
5
 
6
6
  def self.load_dependencies: (singleton(Session)) -> void
7
7
 
8
- def self.retry_after_rate_limit: (untyped, response) -> Numeric?
9
-
10
8
  module InstanceMethods
11
9
  def rate_limit_error?: (response response) -> bool
12
10
  end
13
11
  end
12
+
13
+ type sessionRateLimiter = Session & RateLimiter::InstanceMethods
14
14
  end
15
15
  end
@@ -51,7 +51,7 @@ module HTTPX
51
51
  module ResponseMethods
52
52
  attr_writer original_request: cacheRequest
53
53
 
54
- @cache: bool
54
+ @cached: bool
55
55
  @cache_control: Array[String]?
56
56
  @vary: Array[String]?
57
57
  @date: Time?
@@ -66,9 +66,9 @@ module HTTPX
66
66
 
67
67
  def fresh?: () -> bool
68
68
 
69
- def cache_control: () -> Array[String]?
69
+ %a{pure} def cache_control: () -> Array[String]?
70
70
 
71
- def vary: () -> Array[String]?
71
+ %a{pure} def vary: () -> Array[String]?
72
72
 
73
73
  private
74
74
 
@@ -8,16 +8,16 @@ module HTTPX
8
8
  DEFAULT_JITTER: ^(Numeric) -> Numeric
9
9
  BACKOFF_ALGORITHMS: Array[Symbol]
10
10
 
11
- def self?.retry_after_polynomial_backoff: (retriesRequest request, response response) -> Numeric
11
+ def self?.retry_after_polynomial_backoff: (retriesRequest request, retriesResponse response) -> Numeric
12
12
 
13
- def self?.retry_after_exponential_backoff: (retriesRequest request, response response) -> Numeric
13
+ def self?.retry_after_exponential_backoff: (retriesRequest request, retriesResponse response) -> Numeric
14
14
 
15
15
  interface _RetryCallback
16
- def call: (response response) -> bool?
16
+ def call: (retriesResponse response) -> bool?
17
17
  end
18
18
 
19
19
  interface _RetriesOptions
20
- def retry_after: () -> (^(retriesRequest request, response response) -> Numeric | Numeric)?
20
+ def retry_after: () -> (^(retriesRequest request, retriesResponse response) -> Numeric | Numeric)?
21
21
 
22
22
  def retry_jitter: () -> ^(Numeric jitter) -> Numeric
23
23
 
@@ -35,17 +35,19 @@ module HTTPX
35
35
 
36
36
  private
37
37
 
38
- def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> (retriesResponse | ErrorResponse)?
38
+ def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> retriesResponse?
39
39
 
40
- def retryable_request?: (retriesRequest request, response response, retriesOptions options) -> boolish
40
+ def retryable_request?: (retriesRequest request, retriesResponse response, retriesOptions options) -> boolish
41
41
 
42
- def retryable_response?: (response response, retriesOptions options) -> boolish
42
+ def retryable_response?: (retriesResponse response, retriesOptions options) -> boolish
43
43
 
44
44
  def retryable_error?: (_Exception error, Options options) -> boolish
45
45
 
46
- def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
46
+ def try_partial_retry: (retriesRequest request, retriesResponse response) -> void
47
47
 
48
- def prepare_to_retry: (Request & RequestMethods request, response response) -> void
48
+ def prepare_to_retry: (Request & RequestMethods request, retriesResponse response) -> void
49
+
50
+ def when_to_retry: (Request & RequestMethods request, retriesResponse response, retriesOptions options) -> void
49
51
  end
50
52
 
51
53
  module RequestMethods
@@ -53,20 +55,22 @@ module HTTPX
53
55
 
54
56
  attr_accessor retries: Integer
55
57
 
56
- attr_writer partial_response: Response?
58
+ attr_writer partial_response: retriesResponse?
57
59
 
58
- def response=: (retriesResponse | ErrorResponse response) -> void
60
+ def response=: (retriesResponse response) -> void
59
61
  end
60
62
 
61
63
  module ResponseMethods
62
- def from_partial_response: (Response response) -> void
64
+ def from_partial_response: (retriesHTTPResponse response) -> void
63
65
  end
64
66
 
65
67
  type retriesOptions = Options & _RetriesOptions
66
68
 
67
69
  type retriesRequest = Request & RequestMethods
68
70
 
69
- type retriesResponse = Response & ResponseMethods
71
+ type retriesHTTPResponse = Response & ResponseMethods
72
+
73
+ type retriesResponse = retriesHTTPResponse | ErrorResponse
70
74
  end
71
75
 
72
76
  type sessionRetries = Session & Retries::InstanceMethods
@@ -47,8 +47,11 @@ module HTTPX
47
47
  attr_accessor headers_sent: bool
48
48
 
49
49
  @closed: bool
50
+ @flush_buffer_on_body_cb: ^() -> void | nil
50
51
  @mutex: Thread::Mutex
51
52
 
53
+ def flush_buffer_on_body: { () -> void } -> void
54
+
52
55
  def closed?: () -> bool
53
56
  end
54
57
 
data/sig/request.rbs CHANGED
@@ -6,6 +6,7 @@ module HTTPX
6
6
 
7
7
  METHODS: Array[Symbol]
8
8
  USER_AGENT: String
9
+ ALLOWED_URI_SCHEMES: Array[String]
9
10
 
10
11
  attr_reader verb: verb
11
12
  attr_reader uri: http_uri
@@ -37,6 +37,8 @@ module HTTPX
37
37
 
38
38
  def handle_socket_timeout: (Numeric interval) -> void
39
39
 
40
+ def on_io_error: (IOError error) -> void
41
+
40
42
  private
41
43
 
42
44
  def initialize: (ip_family family, options options) -> void
@@ -27,8 +27,6 @@ module HTTPX
27
27
 
28
28
  def terminate: () -> void
29
29
 
30
- def force_close: (*untyped args) -> void
31
-
32
30
  def closed?: () -> bool
33
31
 
34
32
  def empty?: () -> bool
@@ -60,6 +58,8 @@ module HTTPX
60
58
  def resolve_error: (String hostname, ?StandardError?) -> (ResolveError | ResolveTimeoutError)
61
59
 
62
60
  def close_or_resolve: () -> void
61
+
62
+ def disconnect: () -> void
63
63
  end
64
64
  end
65
65
  end
data/sig/selector.rbs CHANGED
@@ -13,6 +13,10 @@ module HTTPX
13
13
  def handle_socket_timeout: (Numeric interval) -> void
14
14
 
15
15
  def on_error: (StandardError) -> void
16
+
17
+ def on_io_error: (IOError error) -> void
18
+
19
+ def force_close: (?bool delete_pending) -> void
16
20
  end
17
21
 
18
22
  class Selector