httpx 1.8.0 → 1.8.2

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_7_1.md +1 -2
  3. data/doc/release_notes/1_8_1.md +27 -0
  4. data/doc/release_notes/1_8_2.md +30 -0
  5. data/lib/httpx/adapters/datadog.rb +9 -0
  6. data/lib/httpx/adapters/faraday.rb +2 -2
  7. data/lib/httpx/adapters/webmock.rb +8 -1
  8. data/lib/httpx/buffer.rb +5 -0
  9. data/lib/httpx/connection/http1.rb +6 -12
  10. data/lib/httpx/connection/http2.rb +38 -10
  11. data/lib/httpx/connection.rb +86 -27
  12. data/lib/httpx/errors.rb +3 -0
  13. data/lib/httpx/headers.rb +2 -2
  14. data/lib/httpx/io/ssl.rb +26 -17
  15. data/lib/httpx/io/tcp.rb +11 -4
  16. data/lib/httpx/io/unix.rb +2 -2
  17. data/lib/httpx/loggable.rb +11 -4
  18. data/lib/httpx/options.rb +6 -2
  19. data/lib/httpx/plugins/auth/digest.rb +1 -1
  20. data/lib/httpx/plugins/auth.rb +17 -7
  21. data/lib/httpx/plugins/callbacks.rb +12 -0
  22. data/lib/httpx/plugins/digest_auth.rb +4 -0
  23. data/lib/httpx/plugins/fiber_concurrency.rb +25 -1
  24. data/lib/httpx/plugins/follow_redirects.rb +21 -9
  25. data/lib/httpx/plugins/oauth.rb +4 -2
  26. data/lib/httpx/plugins/persistent.rb +33 -2
  27. data/lib/httpx/plugins/proxy.rb +9 -3
  28. data/lib/httpx/plugins/push_promise.rb +2 -2
  29. data/lib/httpx/plugins/retries.rb +15 -8
  30. data/lib/httpx/plugins/server_sent_events.rb +1 -1
  31. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  32. data/lib/httpx/plugins/stream.rb +2 -2
  33. data/lib/httpx/plugins/stream_bidi.rb +2 -0
  34. data/lib/httpx/plugins/tracing.rb +17 -4
  35. data/lib/httpx/pool.rb +2 -2
  36. data/lib/httpx/request/body.rb +10 -7
  37. data/lib/httpx/request.rb +27 -12
  38. data/lib/httpx/resolver/cache/base.rb +1 -8
  39. data/lib/httpx/resolver/https.rb +20 -20
  40. data/lib/httpx/resolver/native.rb +11 -0
  41. data/lib/httpx/resolver/resolver.rb +4 -0
  42. data/lib/httpx/resolver/system.rb +5 -2
  43. data/lib/httpx/response/body.rb +2 -2
  44. data/lib/httpx/response.rb +6 -7
  45. data/lib/httpx/selector.rb +6 -1
  46. data/lib/httpx/session.rb +11 -3
  47. data/lib/httpx/session_extensions.rb +2 -2
  48. data/lib/httpx/timers.rb +3 -0
  49. data/lib/httpx/transcoder/json.rb +1 -2
  50. data/lib/httpx/transcoder/utils/deflater.rb +1 -2
  51. data/lib/httpx/version.rb +1 -1
  52. data/sig/connection/http2.rbs +3 -0
  53. data/sig/connection.rbs +8 -3
  54. data/sig/errors.rbs +2 -2
  55. data/sig/io/ssl.rbs +5 -0
  56. data/sig/loggable.rbs +4 -0
  57. data/sig/plugins/auth.rbs +7 -3
  58. data/sig/plugins/persistent.rbs +7 -0
  59. data/sig/plugins/retries.rbs +4 -2
  60. data/sig/plugins/tracing.rbs +1 -1
  61. data/sig/request.rbs +2 -3
  62. data/sig/resolver/system.rbs +3 -0
  63. data/sig/selector.rbs +2 -0
  64. data/sig/timers.rbs +2 -0
  65. metadata +6 -2
@@ -108,11 +108,13 @@ module HTTPX::Plugins
108
108
  def initialize(*)
109
109
  super
110
110
 
111
- @init_time = ::Time.now.utc
111
+ @init_time = nil
112
112
  end
113
113
 
114
114
  def send_request_to_parser(request)
115
115
  if connecting?
116
+ @init_time ||= ::Time.now.utc
117
+
116
118
  # request span timeframe should include the time it took to connect.
117
119
  request.init_time ||= @init_time
118
120
  end
@@ -123,13 +125,24 @@ module HTTPX::Plugins
123
125
  def idling
124
126
  super
125
127
 
126
- # time of initial request(s) is accounted from the moment
127
- # the connection is back to :idle, and ready to connect again.
128
- @init_time = ::Time.now.utc
128
+ @init_time = nil
129
+ end
130
+
131
+ def terminate
132
+ super
133
+
134
+ # ensure that connections which go back to the pool reset their init time.
135
+ @init_time = nil
129
136
  end
130
137
 
131
138
  private
132
139
 
140
+ def connect
141
+ @init_time ||= ::Time.now.utc
142
+
143
+ super
144
+ end
145
+
133
146
  def ping(request)
134
147
  # if a connection is probed for liveness, the request timeframe should include
135
148
  # it too.
data/lib/httpx/pool.rb CHANGED
@@ -173,7 +173,7 @@ module HTTPX
173
173
  end
174
174
  end
175
175
 
176
- # :nocov:
176
+ # simplecov:disable
177
177
  def inspect
178
178
  "#<#{self.class}:#{object_id} " \
179
179
  "@max_connections=#{@max_connections} " \
@@ -181,7 +181,7 @@ module HTTPX
181
181
  "@pool_timeout=#{@pool_timeout} " \
182
182
  "@connections=#{@connections.size}>"
183
183
  end
184
- # :nocov:
184
+ # simplecov:enable
185
185
 
186
186
  private
187
187
 
@@ -4,14 +4,17 @@ module HTTPX
4
4
  # Implementation of the HTTP Request body as a delegator which iterates (responds to +each+) payload chunks.
5
5
  class Request::Body < SimpleDelegator
6
6
  class << self
7
- def new(_, options, body: nil, **params)
8
- if body.is_a?(self)
7
+ def new(h, options, body: nil, **params)
8
+ case body
9
+ when self
9
10
  # request derives its options from body
10
11
  body.options = options.merge(params)
11
- return body
12
+ body
13
+ when nil
14
+ super(h, options, **params)
15
+ else
16
+ super
12
17
  end
13
-
14
- super
15
18
  end
16
19
  end
17
20
 
@@ -114,12 +117,12 @@ module HTTPX
114
117
  @headers.add("transfer-encoding", "chunked")
115
118
  end
116
119
 
117
- # :nocov:
120
+ # simplecov:disable
118
121
  def inspect
119
122
  "#<#{self.class}:#{object_id} " \
120
123
  "#{unbounded_body? ? "stream" : "@bytesize=#{bytesize}"}>"
121
124
  end
122
- # :nocov:
125
+ # simplecov:enable
123
126
 
124
127
  class << self
125
128
  def initialize_body(params)
data/lib/httpx/request.rb CHANGED
@@ -105,8 +105,8 @@ module HTTPX
105
105
 
106
106
  @state = :idle
107
107
  @connection = @response =
108
- @drainer = @peer_address =
109
- @informational_status = @on_response_arrived = nil
108
+ @drainer = @peer_address = @callbacks =
109
+ @informational_status = @on_response_arrived = nil
110
110
  @ping = @started = false
111
111
  @persistent = @options.persistent
112
112
  @active_timeouts = []
@@ -115,13 +115,14 @@ module HTTPX
115
115
  # dupped initialization
116
116
  def initialize_dup(orig)
117
117
  super
118
- @uri = orig.instance_variable_get(:@uri).dup
119
118
  @headers = orig.instance_variable_get(:@headers).dup
120
119
  @body = orig.instance_variable_get(:@body).dup
120
+ @active_timeouts = orig.instance_variable_get(:@active_timeouts).dup
121
121
  end
122
122
 
123
123
  def complete!(response = @response)
124
124
  emit(:complete, response)
125
+ reset_timers(true)
125
126
  end
126
127
 
127
128
  # whether request has been buffered with a ping
@@ -268,21 +269,19 @@ module HTTPX
268
269
 
269
270
  # consumes and returns the next available chunk of request body that can be sent
270
271
  def drain_body
271
- return nil if @body.nil?
272
+ return if @body.nil?
272
273
 
273
274
  @drainer ||= @body.each
274
- chunk = @drainer.next.dup
275
-
276
- emit(:body_chunk, chunk)
277
- chunk
275
+ @drainer.next.dup
278
276
  rescue StopIteration
279
277
  nil
280
278
  rescue StandardError => e
279
+ # in case an error occurs while emitting body chunks
281
280
  @drain_error = e
282
281
  nil
283
282
  end
284
283
 
285
- # :nocov:
284
+ # simplecov:disable
286
285
  def inspect
287
286
  "#<#{self.class}:#{object_id} " \
288
287
  "#{@verb} " \
@@ -290,7 +289,7 @@ module HTTPX
290
289
  "@headers=#{@headers} " \
291
290
  "@body=#{@body}>"
292
291
  end
293
- # :nocov:
292
+ # simplecov:enable
294
293
 
295
294
  # moves on to the +nextstate+ of the request state machine (when all preconditions are met)
296
295
  def transition(nextstate)
@@ -299,7 +298,10 @@ module HTTPX
299
298
  @body.rewind
300
299
  @ping = false
301
300
  @response = @drainer = nil
302
- @active_timeouts.clear
301
+
302
+ # request may be sent to a different connection and will be
303
+ # reassigned a new set of timers.
304
+ reset_timers(false)
303
305
  when :headers
304
306
  return unless @state == :idle
305
307
 
@@ -326,7 +328,7 @@ module HTTPX
326
328
  return if @state == :expect
327
329
 
328
330
  end
329
- log(level: 3) { "#{@state}] -> #{nextstate}" }
331
+ log(level: 3) { "#{@state} -> #{nextstate}" }
330
332
  @state = nextstate
331
333
  emit(@state, self)
332
334
  nil
@@ -363,6 +365,19 @@ module HTTPX
363
365
 
364
366
  @on_response_arrived.call
365
367
  end
368
+
369
+ private
370
+
371
+ def reset_timers(reset_total_request_timers)
372
+ timers = @active_timeouts
373
+
374
+ until (timer = timers.shift).nil?
375
+ next if !reset_total_request_timers && timer.label == :total_request_timeout
376
+
377
+ # cancel active timers.
378
+ timer.cancel
379
+ end
380
+ end
366
381
  end
367
382
  end
368
383
 
@@ -106,14 +106,7 @@ module HTTPX
106
106
  name = entry["name"]
107
107
  next unless name != hostname
108
108
 
109
- lookups[name] ||= []
110
-
111
- case family
112
- when Socket::AF_INET6
113
- lookups[name] << entry
114
- when Socket::AF_INET
115
- lookups[name].unshift(entry)
116
- end
109
+ _set(name, family, [entry], lookups, hostnames)
117
110
  end
118
111
  end
119
112
 
@@ -126,27 +126,27 @@ module HTTPX
126
126
  end
127
127
 
128
128
  def on_response(request, response)
129
- response.raise_for_status
130
- rescue StandardError => e
131
- hostname = @requests.delete(request)
132
- connection = reset_hostname(hostname)
133
- emit_resolve_error(connection, connection.peer.host, e)
134
- close_or_resolve
135
- else
136
- # @type var response: HTTPX::Response
137
- if response.status.between?(300, 399) && response.headers.key?("location")
138
- hostname = @requests[request]
139
- connection = @queries[hostname]
140
- location_uri = URI(response.headers["location"])
141
- location_uri = response.uri.merge(location_uri) if location_uri.relative?
142
-
143
- # we assume that the DNS server URI changed permanently and move on
144
- @uri = location_uri
145
- send_request(hostname, connection)
146
- return
147
- end
129
+ if (e = response.error)
130
+ hostname = @requests.delete(request)
131
+ connection = reset_hostname(hostname)
132
+ emit_resolve_error(connection, connection.peer.host, e)
133
+ close_or_resolve
134
+ else
135
+ # @type var response: HTTPX::Response
136
+ if response.status.between?(300, 399) && response.headers.key?("location")
137
+ hostname = @requests[request]
138
+ connection = @queries[hostname]
139
+ location_uri = URI(response.headers["location"])
140
+ location_uri = response.uri.merge(location_uri) if location_uri.relative?
148
141
 
149
- parse(request, response)
142
+ # we assume that the DNS server URI changed permanently and move on
143
+ @uri = location_uri
144
+ send_request(hostname, connection)
145
+ return
146
+ end
147
+
148
+ parse(request, response)
149
+ end
150
150
  ensure
151
151
  @requests.delete(request)
152
152
  end
@@ -75,6 +75,13 @@ module HTTPX
75
75
 
76
76
  def call
77
77
  case @state
78
+ when :idle, :closed
79
+ return if @connections.empty?
80
+
81
+ transition(:idle) if @state == :closed
82
+ transition(:open)
83
+
84
+ consume if @state == :open
78
85
  when :open
79
86
  consume
80
87
  end
@@ -532,6 +539,10 @@ module HTTPX
532
539
  return unless @io.connected?
533
540
 
534
541
  resolve if @queries.empty? && !@connections.empty?
542
+
543
+ # #resolve may have closed the resolver already as part of error handling.
544
+ # @fiber-switch-guard
545
+ return unless @io
535
546
  when :closed
536
547
  return if @state == :closed
537
548
 
@@ -52,6 +52,10 @@ module HTTPX
52
52
 
53
53
  alias_method :terminate, :close
54
54
 
55
+ def initial_call
56
+ call
57
+ end
58
+
55
59
  def force_close(*args)
56
60
  while (connection = @connections.shift)
57
61
  connection.force_close(*args)
@@ -23,6 +23,9 @@ module HTTPX
23
23
  DONE = 1
24
24
  ERROR = 2
25
25
 
26
+ class AddrinfoTimeoutError < StandardError
27
+ end
28
+
26
29
  class << self
27
30
  def multi?
28
31
  false
@@ -227,7 +230,7 @@ module HTTPX
227
230
  begin
228
231
  addrs = if resolve_timeout
229
232
 
230
- Timeout.timeout(resolve_timeout) do
233
+ Timeout.timeout(resolve_timeout, AddrinfoTimeoutError) do
231
234
  __addrinfo_resolve(hostname, scheme)
232
235
  end
233
236
  else
@@ -246,7 +249,7 @@ module HTTPX
246
249
  end
247
250
  end
248
251
  rescue StandardError => e
249
- if e.is_a?(Timeout::Error)
252
+ if e.is_a?(AddrinfoTimeoutError)
250
253
  timeouts.shift
251
254
  retry unless timeouts.empty?
252
255
  e = ResolveTimeoutError.new(resolve_timeout, e.message)
@@ -161,13 +161,13 @@ module HTTPX
161
161
  end
162
162
  end
163
163
 
164
- # :nocov:
164
+ # simplecov:disable
165
165
  def inspect
166
166
  "#<#{self.class}:#{object_id} " \
167
167
  "@state=#{@state} " \
168
168
  "@length=#{@length}>"
169
169
  end
170
- # :nocov:
170
+ # simplecov:enable
171
171
 
172
172
  # rewinds the response payload buffer.
173
173
  def rewind
@@ -36,10 +36,10 @@ module HTTPX
36
36
  # * HTTPX::Response::Body#read
37
37
  # * HTTPX::Response::Body#copy_to
38
38
  # * HTTPX::Response::Body#close
39
- attr_reader :body
39
+ attr_reader :body
40
40
 
41
41
  # The HTTP protocol version used to fetch the response.
42
- attr_reader :version
42
+ attr_reader :version
43
43
 
44
44
  # returns the response body buffered in a string.
45
45
  def_delegator :@body, :to_s
@@ -68,7 +68,7 @@ module HTTPX
68
68
  @headers = @options.headers_class.new(headers)
69
69
  @body = @options.response_body_class.new(self, @options)
70
70
  @finished = complete?
71
- @content_type = @content_length = nil
71
+ @callbacks = @content_type = @content_length = nil
72
72
  end
73
73
 
74
74
  # dupped initialization
@@ -141,7 +141,7 @@ module HTTPX
141
141
  bodyless? || (@request.verb == "CONNECT" && @status == 200)
142
142
  end
143
143
 
144
- # :nocov:
144
+ # simplecov:disable
145
145
  def inspect
146
146
  "#<#{self.class}:#{object_id} " \
147
147
  "HTTP/#{version} " \
@@ -149,7 +149,7 @@ module HTTPX
149
149
  "@headers=#{@headers} " \
150
150
  "@body=#{@body.bytesize}>"
151
151
  end
152
- # :nocov:
152
+ # simplecov:enable
153
153
 
154
154
  # returns an instance of HTTPX::HTTPError if the response has a 4xx or 5xx
155
155
  # status code, or nothing.
@@ -267,7 +267,6 @@ module HTTPX
267
267
  # response = HTTPX.get("https://some-domain/path") #=> response is HTTPX::Response or HTTPX::ErrorResponse
268
268
  # response.raise_for_status #=> raises if it wraps an error
269
269
  class ErrorResponse
270
- include Loggable
271
270
  extend Forwardable
272
271
 
273
272
  # the corresponding HTTPX::Request instance.
@@ -290,7 +289,7 @@ module HTTPX
290
289
  @response = request.response if request.response.is_a?(Response)
291
290
  @error = error
292
291
  @options = request.options
293
- log_exception(@error)
292
+ @request.log_exception(@error)
294
293
  finish!
295
294
  end
296
295
 
@@ -41,6 +41,11 @@ module HTTPX
41
41
  @selectables.empty? && @timers.empty?
42
42
  end
43
43
 
44
+ # first time the registered selectables are added, there's probably work to do.
45
+ def initial_call
46
+ @selectables.each(&:initial_call)
47
+ end
48
+
44
49
  def next_tick
45
50
  catch(:jump_tick) do
46
51
  timeout = next_timeout
@@ -51,7 +56,7 @@ module HTTPX
51
56
 
52
57
  begin
53
58
  select(timeout) do |c|
54
- c.log(level: 2) { "[#{c.state}] selected from selector##{object_id} #{" after #{timeout} secs" unless timeout.nil?}..." }
59
+ c.log(level: 2) { "[#{c.state}] selected from selector##{object_id}#{" after #{timeout} secs" unless timeout.nil?}..." }
55
60
 
56
61
  c.call
57
62
  end
data/lib/httpx/session.rb CHANGED
@@ -237,7 +237,7 @@ module HTTPX
237
237
 
238
238
  return unless response && response.finished?
239
239
 
240
- log(level: 2) { "response##{response.object_id} fetched" }
240
+ request.log(level: 2) { "response##{response.object_id} fetched" }
241
241
 
242
242
  response
243
243
  end
@@ -319,9 +319,14 @@ module HTTPX
319
319
 
320
320
  waiting = false
321
321
 
322
- responses = requests.each_with_index.map do |request, idx|
322
+ requests.each do |request|
323
323
  send_request(request, selector)
324
+ end
325
+
326
+ # do work first
327
+ selector.initial_call
324
328
 
329
+ responses = requests.each_with_index.map do |request, idx|
325
330
  fetch_response(request, selector, request.options).tap do |response|
326
331
  if response.nil?
327
332
  pending += 1
@@ -332,6 +337,8 @@ module HTTPX
332
337
  end
333
338
  end
334
339
 
340
+ log(level: 2) { "waiting to receive #{pending} pending requests..." }
341
+
335
342
  until pending.zero? || selector.empty?
336
343
  # loop on selector until at least one response has been received.
337
344
  waiting = true
@@ -355,7 +362,8 @@ module HTTPX
355
362
  end
356
363
  end
357
364
 
358
- raise Error, "something went wrong, responses not found and requests not resent" unless pending.zero?
365
+ raise Error, "something went wrong, #{pending} responses not found " \
366
+ "and requests not resent" unless pending.zero?
359
367
 
360
368
  responses
361
369
  end
@@ -20,11 +20,11 @@ module HTTPX
20
20
  $VERBOSE = original_verbosity
21
21
  end
22
22
 
23
- # :nocov:
23
+ # simplecov:disable
24
24
  if Session.default_options.debug_level > 2
25
25
  proxy_session = plugin(:internal_telemetry)
26
26
  remove_const(:Session)
27
27
  const_set(:Session, proxy_session.class)
28
28
  end
29
- # :nocov:
29
+ # simplecov:enable
30
30
  end
data/lib/httpx/timers.rb CHANGED
@@ -62,6 +62,9 @@ module HTTPX
62
62
  end
63
63
 
64
64
  class Timer
65
+ # simpler helper which allows classification
66
+ attr_accessor :label
67
+
65
68
  def initialize(interval, callback)
66
69
  @interval = interval
67
70
  @callback = callback
@@ -51,7 +51,7 @@ module HTTPX::Transcoder
51
51
  method(:json_load)
52
52
  end
53
53
 
54
- # rubocop:disable Style/SingleLineMethods
54
+ # rubocop:disable-next Style/SingleLineMethods
55
55
  if defined?(MultiJson)
56
56
  def json_load(*args); MultiJson.load(*args); end
57
57
  def json_dump(*args); MultiJson.dump(*args); end
@@ -66,6 +66,5 @@ module HTTPX::Transcoder
66
66
  def json_load(*args); ::JSON.parse(*args); end
67
67
  def json_dump(*args); ::JSON.generate(*args); end
68
68
  end
69
- # rubocop:enable Style/SingleLineMethods
70
69
  end
71
70
  end
@@ -55,7 +55,7 @@ module HTTPX
55
55
 
56
56
  private
57
57
 
58
- # rubocop:disable Naming/MemoizedInstanceVariableName
58
+ # rubocop:disable-next Naming/MemoizedInstanceVariableName
59
59
  def buffer_deflate!
60
60
  return @buffer if defined?(@buffer)
61
61
 
@@ -68,7 +68,6 @@ module HTTPX
68
68
 
69
69
  @buffer = buffer
70
70
  end
71
- # rubocop:enable Naming/MemoizedInstanceVariableName
72
71
  end
73
72
  end
74
73
  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.8.0"
4
+ VERSION = "1.8.2"
5
5
  end
@@ -16,6 +16,7 @@ module HTTPX
16
16
  @max_requests: Integer
17
17
  @drains: Hash[Request, String]
18
18
  @pings: Array[String]
19
+ @streams_to_close_after_receive: Array[[HTTP2::Stream, Request, HTTPX::Error]]
19
20
  @buffer: Buffer
20
21
  @handshake_completed: bool
21
22
  @wait_for_handshake: bool
@@ -106,6 +107,8 @@ module HTTPX
106
107
 
107
108
  def on_pong: (string ping) -> void
108
109
 
110
+ def emit_stream_error: (HTTP2::Stream stream, Request request, StandardError error) -> void
111
+
109
112
  def teardown: (?Request? request) -> void
110
113
 
111
114
  class Error < ::HTTPX::Error
data/sig/connection.rbs CHANGED
@@ -32,10 +32,11 @@ module HTTPX
32
32
  attr_accessor current_session: Session?
33
33
  attr_accessor family: Integer?
34
34
 
35
+ attr_reader read_buffer: Buffer
36
+ attr_reader write_buffer: Buffer
37
+
35
38
 
36
39
  @window_size: Integer
37
- @read_buffer: Buffer
38
- @write_buffer: Buffer
39
40
  @inflight: Integer
40
41
  @max_concurrent_requests: Integer?
41
42
  @keep_alive_timeout: interval?
@@ -92,6 +93,8 @@ module HTTPX
92
93
 
93
94
  def call: () -> void
94
95
 
96
+ def initial_call: () -> void
97
+
95
98
  def terminate: () -> void
96
99
 
97
100
  def close: () -> void
@@ -122,7 +125,7 @@ module HTTPX
122
125
 
123
126
  def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
124
127
 
125
- def on_io_error: (IOError error) -> void
128
+ def on_io_error: (SocketError | IOError | TLSError error) -> void
126
129
 
127
130
  def on_connect_error: (Exception error) -> void
128
131
 
@@ -164,6 +167,8 @@ module HTTPX
164
167
 
165
168
  def no_more_requests_loop_check: () -> void
166
169
 
170
+ def no_more_requests?: () -> bool
171
+
167
172
  def handle_error: (StandardError error, ?Request? request) -> void
168
173
 
169
174
  def force_purge: () -> void
data/sig/errors.rbs CHANGED
@@ -31,9 +31,9 @@ module HTTPX
31
31
 
32
32
  class RequestTimeoutError < TimeoutError
33
33
  attr_reader request: Request
34
- attr_reader response: response?
34
+ attr_reader response: untyped
35
35
 
36
- def initialize: (Request request, response? response, interval timeout) -> void
36
+ def initialize: (Request request, untyped response, interval timeout) -> void
37
37
  end
38
38
 
39
39
  class ReadTimeoutError < RequestTimeoutError
data/sig/io/ssl.rbs CHANGED
@@ -9,6 +9,7 @@ module HTTPX
9
9
  @ctx: OpenSSL::SSL::SSLContext
10
10
  @verify_hostname: bool
11
11
  @sni_hostname: String
12
+ @session_new_cb: (^(OpenSSL::SSL::Session sess) -> void)?
12
13
 
13
14
  attr_writer ssl_session: OpenSSL::SSL::Session?
14
15
 
@@ -24,5 +25,9 @@ module HTTPX
24
25
 
25
26
  # :nocov:
26
27
  def try_ssl_connect: () -> void
28
+
29
+ private
30
+
31
+ def init_session_new_cb: () -> void
27
32
  end
28
33
  end
data/sig/loggable.rbs CHANGED
@@ -12,10 +12,14 @@ module HTTPX
12
12
 
13
13
  COLORS: Hash[Symbol, Integer]
14
14
 
15
+ def self.log_identifiers: () -> String
16
+
15
17
  def log: (?level: Integer?, ?color: Symbol?, ?debug_level: Integer, ?debug: _IOLogger?) { () -> String } -> void
16
18
 
17
19
  def log_exception: (Exception error, ?level: Integer, ?color: Symbol, ?debug_level: Integer, ?debug: _IOLogger?) -> void
18
20
 
21
+ private
22
+
19
23
  def log_redact_headers: (_ToS text) -> String
20
24
 
21
25
  def log_redact_body: (_ToS text) -> String
data/sig/plugins/auth.rbs CHANGED
@@ -1,12 +1,16 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Auth
4
- type auth_header_value_type = String | ^(Request request) -> string
4
+ type auth_header_value_type = String | ^(?Request request, ?bool should_regenerate) -> string
5
5
 
6
6
  interface _AuthOptions
7
7
  def auth_header_value: () -> auth_header_value_type?
8
8
 
9
9
  def auth_header_type: () -> String?
10
+
11
+ def auth_header_expires_at: () -> (^(Request request) -> _ToF?)?
12
+
13
+ def auth_header_expires_in: () -> Float?
10
14
  end
11
15
 
12
16
  module InstanceMethods
@@ -14,7 +18,7 @@ module HTTPX
14
18
  @auth_header_value_mtx: Thread::Mutex
15
19
  @skip_auth_header_value: bool
16
20
 
17
- def authorization: (?string token, ?auth_header_type: string) ?{ (Request) -> string } -> instance
21
+ def authorization: (?string token, ?auth_header_type: string) ?{ (?Request, ?bool) -> string } -> instance
18
22
 
19
23
  def bearer_auth: (?string token) ?{ (Request) -> string } -> instance
20
24
 
@@ -24,7 +28,7 @@ module HTTPX
24
28
 
25
29
  private
26
30
 
27
- def generate_auth_token: () -> String?
31
+ def generate_auth_token: (Request & RequestMethods request, bool should_regenerate) -> String?
28
32
 
29
33
  def dynamic_auth_token?: (auth_header_value_type auth_header_value) -> boolish
30
34
  end