httpx 1.8.3 → 1.9.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_8_4.md +13 -0
  3. data/doc/release_notes/1_9_0.md +75 -0
  4. data/lib/httpx/adapters/webmock.rb +1 -1
  5. data/lib/httpx/altsvc.rb +29 -15
  6. data/lib/httpx/callbacks.rb +2 -2
  7. data/lib/httpx/chainable.rb +6 -3
  8. data/lib/httpx/connection/http1.rb +11 -19
  9. data/lib/httpx/connection/http2.rb +112 -27
  10. data/lib/httpx/connection.rb +184 -46
  11. data/lib/httpx/headers.rb +2 -2
  12. data/lib/httpx/io/tcp.rb +18 -14
  13. data/lib/httpx/options.rb +86 -35
  14. data/lib/httpx/parser/http1.rb +3 -6
  15. data/lib/httpx/plugins/auth/digest.rb +1 -2
  16. data/lib/httpx/plugins/auth.rb +11 -2
  17. data/lib/httpx/plugins/aws_sdk_authentication.rb +7 -3
  18. data/lib/httpx/plugins/aws_sigv4.rb +1 -0
  19. data/lib/httpx/plugins/basic_auth.rb +2 -0
  20. data/lib/httpx/plugins/callbacks.rb +7 -6
  21. data/lib/httpx/plugins/circuit_breaker.rb +1 -0
  22. data/lib/httpx/plugins/cookies/cookie.rb +1 -1
  23. data/lib/httpx/plugins/cookies.rb +2 -2
  24. data/lib/httpx/plugins/digest_auth.rb +2 -0
  25. data/lib/httpx/plugins/expect.rb +2 -0
  26. data/lib/httpx/plugins/fiber_concurrency.rb +6 -0
  27. data/lib/httpx/plugins/follow_redirects.rb +8 -6
  28. data/lib/httpx/plugins/grpc/call.rb +4 -4
  29. data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -2
  30. data/lib/httpx/plugins/grpc.rb +21 -0
  31. data/lib/httpx/plugins/hedging.rb +284 -0
  32. data/lib/httpx/plugins/ntlm_auth.rb +1 -0
  33. data/lib/httpx/plugins/ntlm_v2_auth.rb +1 -0
  34. data/lib/httpx/plugins/oauth.rb +1 -1
  35. data/lib/httpx/plugins/proxy/http.rb +71 -16
  36. data/lib/httpx/plugins/proxy/ssh.rb +30 -11
  37. data/lib/httpx/plugins/proxy.rb +66 -45
  38. data/lib/httpx/plugins/push_promise.rb +4 -2
  39. data/lib/httpx/plugins/retries.rb +13 -3
  40. data/lib/httpx/plugins/server_sent_events.rb +2 -1
  41. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  42. data/lib/httpx/plugins/stream.rb +2 -2
  43. data/lib/httpx/plugins/tracing.rb +61 -14
  44. data/lib/httpx/plugins/upgrade/h2.rb +1 -1
  45. data/lib/httpx/plugins/upgrade.rb +2 -0
  46. data/lib/httpx/plugins/webdav.rb +8 -0
  47. data/lib/httpx/request/body.rb +2 -1
  48. data/lib/httpx/request.rb +10 -7
  49. data/lib/httpx/resolver/multi.rb +2 -2
  50. data/lib/httpx/resolver/resolver.rb +2 -2
  51. data/lib/httpx/resolver.rb +5 -1
  52. data/lib/httpx/response/body.rb +2 -2
  53. data/lib/httpx/response.rb +19 -11
  54. data/lib/httpx/selector.rb +3 -3
  55. data/lib/httpx/session.rb +38 -11
  56. data/lib/httpx/transcoder/chunker.rb +2 -2
  57. data/lib/httpx/transcoder/json.rb +7 -7
  58. data/lib/httpx/version.rb +1 -1
  59. data/sig/altsvc.rbs +3 -3
  60. data/sig/callbacks.rbs +1 -0
  61. data/sig/chainable.rbs +1 -0
  62. data/sig/connection/http1.rbs +1 -1
  63. data/sig/connection/http2.rbs +30 -16
  64. data/sig/connection.rbs +19 -1
  65. data/sig/headers.rbs +1 -1
  66. data/sig/httpx.rbs +2 -0
  67. data/sig/options.rbs +43 -12
  68. data/sig/parser/http1.rbs +1 -1
  69. data/sig/plugins/auth/digest.rbs +0 -1
  70. data/sig/plugins/auth.rbs +12 -5
  71. data/sig/plugins/hedging.rbs +44 -0
  72. data/sig/plugins/proxy/http.rbs +8 -1
  73. data/sig/plugins/proxy.rbs +3 -2
  74. data/sig/plugins/retries.rbs +2 -2
  75. data/sig/plugins/tracing.rbs +14 -5
  76. data/sig/request/body.rbs +1 -1
  77. data/sig/request.rbs +2 -1
  78. data/sig/resolver/entry.rbs +2 -2
  79. data/sig/response.rbs +1 -2
  80. data/sig/selector.rbs +2 -2
  81. data/sig/session.rbs +7 -5
  82. metadata +7 -1
@@ -119,7 +119,6 @@ module HTTPX
119
119
  # marks the response as finished, freezes the headers.
120
120
  def finish!
121
121
  @finished = true
122
- @headers.freeze
123
122
  @request.connection = nil
124
123
  end
125
124
 
@@ -176,8 +175,8 @@ module HTTPX
176
175
  #
177
176
  # response.json #≈> { "foo" => "bar" } for "{\"foo\":\"bar\"}" payload
178
177
  # response.json(symbolize_names: true) #≈> { foo: "bar" } for "{\"foo\":\"bar\"}" payload
179
- def json(*args)
180
- decode(Transcoder::JSON, *args)
178
+ def json(...)
179
+ decode(Transcoder::JSON, ...)
181
180
  end
182
181
 
183
182
  # decodes the response payload into a ruby object **if** the payload is valid
@@ -200,7 +199,7 @@ module HTTPX
200
199
  #
201
200
  # +transcoder+ must implement the internal transcoder API, i.e. respond to <tt>decode(HTTPX::Response response)</tt>,
202
201
  # which returns a decoder which responds to <tt>call(HTTPX::Response response, **kwargs)</tt>
203
- def decode(transcoder, *args)
202
+ def decode(transcoder, ...)
204
203
  # TODO: check if content-type is a valid format, i.e. "application/json" for json parsing
205
204
 
206
205
  decoder = transcoder.decode(self)
@@ -209,14 +208,13 @@ module HTTPX
209
208
 
210
209
  @body.rewind
211
210
 
212
- decoder.call(self, *args)
211
+ decoder.call(self, ...)
213
212
  end
214
213
  end
215
214
 
216
215
  # Helper class which decodes the HTTP "content-type" header.
217
216
  class ContentType
218
- MIME_TYPE_RE = %r{^([^/]+/[^;]+)(?:$|;)}.freeze
219
- CHARSET_RE = /;\s*charset=([^;]+)/i.freeze
217
+ SPLIT_PATTERN = /[;,]/.freeze
220
218
 
221
219
  def initialize(header_value)
222
220
  @header_value = header_value
@@ -250,11 +248,21 @@ module HTTPX
250
248
  private
251
249
 
252
250
  def load
253
- m = @header_value.to_s[MIME_TYPE_RE, 1]
254
- m && @mime_type = m.strip.downcase
251
+ if @header_value && !@header_value.empty?
252
+ m, c = @header_value.split(SPLIT_PATTERN, 2)
255
253
 
256
- c = @header_value.to_s[CHARSET_RE, 1]
257
- c && @charset = c.strip.delete('"')
254
+ if m
255
+ @mime_type = m.strip
256
+ @mime_type.downcase
257
+ end
258
+
259
+ if c
260
+ c.strip!
261
+ c.delete_prefix!("charset=")
262
+ c = c[1..-2] if c.start_with?('"') && c.end_with?('"')
263
+ @charset = c
264
+ end
265
+ end
258
266
 
259
267
  @initialized = true
260
268
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "io/wait"
3
+ require "io/wait" if RUBY_VERSION < "3.2.0"
4
4
 
5
5
  module HTTPX
6
6
  #
@@ -68,9 +68,9 @@ module HTTPX
68
68
  end
69
69
  end
70
70
 
71
- def terminate
71
+ def terminate(selectables = nil)
72
72
  # array may change during iteration
73
- selectables = @selectables.reject(&:inflight?)
73
+ selectables ||= @selectables.reject(&:inflight?)
74
74
 
75
75
  selectables.delete_if do |sel|
76
76
  sel.terminate
data/lib/httpx/session.rb CHANGED
@@ -46,7 +46,7 @@ module HTTPX
46
46
  ensure
47
47
  unless prev_wrapped
48
48
  if @persistent
49
- deactivate(current_selector)
49
+ deactivate(current_selector, $ERROR_INFO)
50
50
  else
51
51
  close(current_selector)
52
52
  end
@@ -143,7 +143,7 @@ module HTTPX
143
143
  # do not check-in connections only created for Happy Eyeballs
144
144
  return if cloned
145
145
 
146
- return if @closing && connection.state == :closed && !connection.used?
146
+ return unless can_checkin?(connection)
147
147
 
148
148
  connection.log(level: 2) { "check-in connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
149
149
  @pool.checkin_connection(connection)
@@ -211,18 +211,33 @@ module HTTPX
211
211
 
212
212
  private
213
213
 
214
- def selector_close(selector)
214
+ def can_checkin?(connection)
215
+ !@closing || connection.state != :closed || connection.used?
216
+ end
217
+
218
+ def selector_close(selector, ...)
215
219
  begin
216
220
  @closing = true
217
- selector.terminate
221
+ selector.terminate(...)
218
222
  ensure
219
223
  @closing = false
220
224
  end
221
225
  end
222
226
 
223
227
  # tries deactivating connections in the +selector+, deregistering the ones that have been deactivated.
224
- def deactivate(selector)
225
- selector.each_connection.to_a.each(&:deactivate)
228
+ def deactivate(selector, error = nil)
229
+ selector.each_connection.to_a.each do |connection|
230
+ if (pending_count = connection.pending_count).positive?
231
+ warn "connection deactivated with pending requests, " \
232
+ "please report this https://gitlab.com/os85/httpx/-/work_items " \
233
+ "along with debug logs\n(" \
234
+ "state:#{connection.state},pending:#{pending_count}," \
235
+ "connection-pending:#{connection.pending.size}," \
236
+ "deactivate-on-error:#{error&.detailed_message}," \
237
+ ")"
238
+ end
239
+ connection.deactivate
240
+ end
226
241
  end
227
242
 
228
243
  # callback executed when an HTTP/2 promise frame has been received.
@@ -242,13 +257,18 @@ module HTTPX
242
257
  response
243
258
  end
244
259
 
245
- # sends the +request+ to the corresponding HTTPX::Connection
246
- def send_request(request, selector, options = request.options)
260
+ # sends the +request+ to a suitable HTTPX::Connection, which gets yielded if a block is passed.
261
+ def send_request(request, selector, options = request.options, &blk)
247
262
  error = begin
248
263
  catch(:resolve_error) do
249
264
  log(level: 2) { "finding connection for request##{request.object_id}..." }
250
265
  connection = find_connection(request.uri, selector, options)
251
- connection.send(request)
266
+ yield(connection) if blk
267
+ do_request(
268
+ request,
269
+ connection,
270
+ selector
271
+ )
252
272
  end
253
273
  rescue StandardError => e
254
274
  e
@@ -262,6 +282,10 @@ module HTTPX
262
282
  request.emit_response(response)
263
283
  end
264
284
 
285
+ def do_request(request, connection, _)
286
+ connection.send(request)
287
+ end
288
+
265
289
  # returns a set of HTTPX::Request objects built from the given +args+ and +options+.
266
290
  def build_requests(*args, params)
267
291
  requests = if args.size == 1
@@ -269,6 +293,7 @@ module HTTPX
269
293
  reqs.map do |verb, uri, ps = EMPTY_HASH|
270
294
  request_params = params
271
295
  request_params = request_params.merge(ps) unless ps.empty?
296
+ request_params = request_params.dup unless request_params.empty? && reqs.size == 1
272
297
  build_request(verb, uri, request_params)
273
298
  end
274
299
  else
@@ -277,6 +302,7 @@ module HTTPX
277
302
  uris.enum_for(:each).map do |uri, ps = EMPTY_HASH|
278
303
  request_params = params
279
304
  request_params = request_params.merge(ps) unless ps.empty?
305
+ request_params = request_params.dup unless request_params.empty? && uris.size == 1
280
306
  build_request(verb, uri, request_params)
281
307
  end
282
308
  else
@@ -304,7 +330,7 @@ module HTTPX
304
330
  ensure
305
331
  unless @wrapped
306
332
  if @persistent
307
- deactivate(selector)
333
+ deactivate(selector, $ERROR_INFO)
308
334
  else
309
335
  close(selector)
310
336
  end
@@ -355,7 +381,8 @@ module HTTPX
355
381
  # making the next loop cheaper (because we're dropping).
356
382
  next unless response
357
383
 
358
- request.complete!(response)
384
+ next unless request.complete!(response)
385
+
359
386
  responses[idx] = response
360
387
  request.on_response_arrived = nil
361
388
  pending -= 1
@@ -24,8 +24,8 @@ module HTTPX::Transcoder
24
24
  yield "0#{CRLF}"
25
25
  end
26
26
 
27
- def respond_to_missing?(meth, *args)
28
- @raw.respond_to?(meth, *args) || super
27
+ def respond_to_missing?(...)
28
+ @raw.respond_to?(...) || super
29
29
  end
30
30
  end
31
31
 
@@ -53,18 +53,18 @@ module HTTPX::Transcoder
53
53
 
54
54
  # rubocop:disable-next Style/SingleLineMethods
55
55
  if defined?(MultiJson)
56
- def json_load(*args); MultiJson.load(*args); end
57
- def json_dump(*args); MultiJson.dump(*args); end
56
+ def json_load(...); MultiJson.load(...); end
57
+ def json_dump(...); MultiJson.dump(...); end
58
58
  elsif defined?(Oj)
59
- def json_load(response, *args); Oj.load(response.to_s, *args); end
59
+ def json_load(response, ...); Oj.load(response.to_s, ...); end
60
60
  def json_dump(obj, options = {}); Oj.dump(obj, { mode: :compat }.merge(options)); end
61
61
  elsif defined?(Yajl)
62
- def json_load(response, *args); Yajl::Parser.new(*args).parse(response.to_s); end
63
- def json_dump(*args); Yajl::Encoder.encode(*args); end
62
+ def json_load(response, ...); Yajl::Parser.new(...).parse(response.to_s); end
63
+ def json_dump(...); Yajl::Encoder.encode(...); end
64
64
  else
65
65
  require "json"
66
- def json_load(*args); ::JSON.parse(*args); end
67
- def json_dump(*args); ::JSON.generate(*args); end
66
+ def json_load(...); ::JSON.parse(...); end
67
+ def json_dump(...); ::JSON.generate(...); end
68
68
  end
69
69
  end
70
70
  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.3"
4
+ VERSION = "1.9.0"
5
5
  end
data/sig/altsvc.rbs CHANGED
@@ -31,11 +31,11 @@ module HTTPX
31
31
 
32
32
  def self?.emit: (Request request, response response) { (http_uri alt_origin, String origin, altsvc_params alt_params) -> void } -> void
33
33
 
34
- def self?.parse: (String altsvc) { (http_uri alt_origin, altsvc_params alt_params) -> void } -> void
35
- | (String altsvc) -> Enumerable[[http_uri, altsvc_params]]
34
+ def self?.parse: (String altsvc, ?host: String?) { (http_uri alt_origin, altsvc_params alt_params) -> void } -> void
35
+ | (String altsvc, ?host: String?) -> Enumerable[[http_uri, altsvc_params]]
36
36
 
37
37
  def self?.parse_altsvc_scheme: (String alt_proto) -> String?
38
38
 
39
- def self.parse_altsvc_origin: (string alt_proto, String alt_origin) -> http_uri?
39
+ def self.parse_altsvc_origin: (string alt_proto, String alt_origin, ?host: String?) -> http_uri?
40
40
  end
41
41
  end
data/sig/callbacks.rbs CHANGED
@@ -4,6 +4,7 @@ module HTTPX
4
4
  end
5
5
 
6
6
  module Callbacks
7
+ @callbacks: Hash[Symbol, Array[_Callable]]?
7
8
  def on: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
8
9
  def once: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
9
10
  def emit: (Symbol, *untyped) -> void
data/sig/chainable.rbs CHANGED
@@ -47,6 +47,7 @@ module HTTPX
47
47
  | (:xml, ?options) -> Plugins::sessionXML
48
48
  | (:query, ?options) -> Plugins::sessionQuery
49
49
  | (:tracing, ?options) -> Plugins::sessionTracing
50
+ | (:hedging, ?options) -> Plugins::sessionHedging
50
51
  | (Symbol | Module, ?options) { (Class) -> void } -> Session
51
52
  | (Symbol | Module, ?options) -> Session
52
53
 
@@ -36,7 +36,7 @@ module HTTPX
36
36
 
37
37
  def <<: (string) -> void
38
38
 
39
- def send: (Request) -> void
39
+ def send: (Request request, ?bool head) -> void
40
40
 
41
41
  def consume: () -> void
42
42
 
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  MAX_CONCURRENT_REQUESTS: Integer
7
7
 
8
- attr_reader streams: Hash[Request, ::HTTP2::Stream]
8
+ attr_reader streams: Hash[Request, HTTP2::Stream]
9
9
 
10
10
  attr_reader pending: Array[Request]
11
11
 
@@ -14,7 +14,7 @@ module HTTPX
14
14
  @settings: Hash[Symbol, Integer | bool]
15
15
  @max_concurrent_requests: Integer
16
16
  @max_requests: Integer
17
- @drains: Hash[Request, String]
17
+ @drains: Hash[HTTP2::Stream, String]
18
18
  @pings: Array[String]
19
19
  @streams_to_close_after_receive: Array[[HTTP2::Stream, Request, HTTPX::Error]]
20
20
  @buffer: Buffer
@@ -57,35 +57,35 @@ module HTTPX
57
57
 
58
58
  def set_protocol_headers: (Request) -> _Each[[String, String]]
59
59
 
60
- def handle: (Request request, ::HTTP2::Stream stream) -> void
60
+ def handle: (Request request, HTTP2::Stream stream) -> void
61
61
 
62
62
  def init_connection: () -> void
63
63
 
64
- def handle_stream: (::HTTP2::Stream stream, Request request) -> void
64
+ def handle_stream: (HTTP2::Stream stream, Request request) -> void
65
65
 
66
66
  def join_headline: (Request request) -> String
67
67
 
68
- def join_headers: (::HTTP2::Stream stream, Request request) -> void
68
+ def join_headers: (HTTP2::Stream stream, Request request) -> void
69
69
 
70
- def join_trailers: (::HTTP2::Stream stream, Request request) -> void
70
+ def join_trailers: (HTTP2::Stream stream, Request request) -> void
71
71
 
72
- def join_body: (::HTTP2::Stream stream, Request request) -> void
72
+ def join_body: (HTTP2::Stream stream, Request request) -> void
73
73
 
74
- def send_chunk: (Request request, ::HTTP2::Stream stream, String chunk, String? next_chunk) -> void
74
+ def send_chunk: (Request request, HTTP2::Stream stream, String chunk, String? next_chunk) -> void
75
75
 
76
76
  def end_stream?: (Request request, String? next_chunk) -> void
77
77
 
78
- def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
78
+ def on_stream_headers: (HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
79
79
 
80
- def on_stream_trailers: (::HTTP2::Stream stream, Request request, Response response, Array[[String, String]] headers) -> void
80
+ def on_stream_trailers: (HTTP2::Stream stream, Request request, Response response, Array[[String, String]] headers) -> void
81
81
 
82
- def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
82
+ def on_stream_data: (HTTP2::Stream stream, Request request, String data) -> void
83
83
 
84
- def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
84
+ def on_stream_refuse: (HTTP2::Stream stream, Request request, StandardError error) -> void
85
85
 
86
- def on_stream_half_close: (::HTTP2::Stream stream, Request request) -> void
86
+ def on_stream_half_close: (HTTP2::Stream stream, Request request) -> void
87
87
 
88
- def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
88
+ def on_stream_close: (HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
89
89
 
90
90
  def on_frame: (string bytes) -> void
91
91
 
@@ -101,7 +101,7 @@ module HTTPX
101
101
 
102
102
  def on_altsvc: (String origin, ::HTTP2::frame frame) -> void
103
103
 
104
- def on_promise: (::HTTP2::Stream stream) -> void
104
+ def on_promise: (HTTP2::Stream stream) -> void
105
105
 
106
106
  def on_origin: (String) -> void
107
107
 
@@ -116,11 +116,25 @@ module HTTPX
116
116
  end
117
117
 
118
118
  class GoawayError < Error
119
- def initialize: (?Symbol code) -> void
119
+ UNRECOVERABLE_ERRORS: Array[Symbol]
120
+
121
+ @code: Symbol
122
+
123
+ def initialize: (Symbol code, Integer last_stream_id) -> void
124
+
125
+ def last_stream_id: () -> Numeric
126
+
127
+ def unrecoverable?: () -> bool
120
128
  end
121
129
 
122
130
  class PingError < Error
123
131
  def initialize: () -> void
124
132
  end
133
+
134
+ class RstStreamError < Error
135
+ end
136
+
137
+ class RefusedStreamError < Error
138
+ end
125
139
  end
126
140
  end
data/sig/connection.rbs CHANGED
@@ -47,6 +47,8 @@ module HTTPX
47
47
  @response_received_at: Float
48
48
  @exhausted: bool
49
49
  @cloned: bool
50
+ @reset_timeout_on_call: bool
51
+ @previously_exhausted_with_error: bool
50
52
  @coalesced_connection: instance?
51
53
  @altsvc_connection: instance?
52
54
  @sibling: instance?
@@ -77,6 +79,8 @@ module HTTPX
77
79
 
78
80
  def merge: (Connection connection) -> void
79
81
 
82
+ def pending_count: () -> Integer
83
+
80
84
  def purge_pending: () { (Request request) -> void } -> void
81
85
 
82
86
  def connecting?: () -> bool
@@ -135,6 +139,8 @@ module HTTPX
135
139
 
136
140
  def initialize_type: (http_uri uri, Options options) -> io_type
137
141
 
142
+ def try_connect: () -> void
143
+
138
144
  def connect: () -> void
139
145
 
140
146
  def exhausted?: () -> boolish
@@ -165,6 +171,8 @@ module HTTPX
165
171
 
166
172
  def pong: () -> void
167
173
 
174
+ def no_more_selector_check: () -> void
175
+
168
176
  def no_more_requests_loop_check: () -> void
169
177
 
170
178
  def no_more_requests?: () -> bool
@@ -173,12 +181,16 @@ module HTTPX
173
181
 
174
182
  def force_purge: () -> void
175
183
 
184
+ def reset_ping_timer: () -> void
185
+
176
186
  def close_sibling: () -> void
177
187
 
178
188
  def purge_after_closed: () -> void
179
189
 
180
190
  def set_request_timeouts: (Request request) -> void
181
191
 
192
+ def set_connection_timeouts: (Request request) -> void
193
+
182
194
  def set_request_read_timeout: (Request request) -> void
183
195
 
184
196
  def set_request_write_timeout: (Request request) -> void
@@ -187,12 +199,18 @@ module HTTPX
187
199
 
188
200
  def set_request_total_request_timeout: (Request request) -> void
189
201
 
190
- def write_timeout_callback: (Request request, Numeric timeout) -> void
202
+ def write_timeout_callback: (Request request, interval timeout) -> void
191
203
 
192
204
  def read_timeout_callback: (Request request, interval timeout, ?singleton(RequestTimeoutError) error_type) -> void
193
205
 
194
206
  def set_request_timeout: (Symbol label, Request request, interval timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
195
207
 
208
+ def set_connecting_request_timeout: (Request request) -> void
209
+
210
+ def set_connecting_total_request_timeout: (Request request) -> void
211
+
212
+ def set_connection_timeout: (Symbol label, Request request, interval timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
213
+
196
214
  def parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
197
215
  end
198
216
  end
data/sig/headers.rbs CHANGED
@@ -17,7 +17,7 @@ module HTTPX
17
17
  def each: (?_Each[[String, String]]? extra_headers) { (String k, String v) -> void } -> void
18
18
  | (?_Each[[String, String]]? extra_headers) -> Enumerable[[String, String]]
19
19
 
20
- def get: (String field) -> Array[_ToS]
20
+ def get: (String downcased_key) -> Array[_ToS]
21
21
  def key?: (String downcased_key) -> bool
22
22
 
23
23
  def merge: (_Each[[String, headers_value]] other) -> Headers
data/sig/httpx.rbs CHANGED
@@ -18,6 +18,8 @@ module HTTPX
18
18
 
19
19
  type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
20
20
 
21
+ type resolver = Resolver::Multi | Resolver::Resolver
22
+
21
23
  module Plugins
22
24
  self.@plugins: Hash[Symbol, Module]
23
25
  self.@plugins_mutex: Thread::Mutex
data/sig/options.rbs CHANGED
@@ -10,9 +10,6 @@ module HTTPX
10
10
  CONNECT_TIMEOUT: Integer
11
11
  READ_TIMEOUT: Integer
12
12
  WRITE_TIMEOUT: Integer
13
- REQUEST_TIMEOUT: Integer
14
- TOTAL_REQUEST_TIMEOUT: Integer
15
- OPERATION_TIMEOUT: Integer
16
13
  KEEP_ALIVE_TIMEOUT: Integer
17
14
  PING_TIMEOUT: Integer
18
15
  SETTINGS_TIMEOUT: Integer
@@ -26,22 +23,21 @@ module HTTPX
26
23
  USER_AGENT: String
27
24
 
28
25
  type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :total_request_timeout | :request_timeout | :ping_timeout
29
- type timeout = Hash[timeout_type, interval?]
30
26
  type redact_value = :headers | :body | bool
31
27
  type resolver_cache_option = :memory | :file | (Object & Resolver::_Cache)
32
28
 
33
29
  def self.new: (?options) -> instance
34
30
 
35
- attr_reader self.options_names: Array[Symbol]
31
+ attr_reader self.options_names: Set[Symbol]
36
32
 
37
33
  # headers
38
34
  attr_reader uri: URI?
39
35
 
40
36
  # headers
41
- attr_reader headers: headers?
37
+ attr_reader headers: headers
42
38
 
43
39
  # timeout
44
- attr_reader timeout: timeout
40
+ attr_reader timeout: Timeouts
45
41
 
46
42
  # http2_settings
47
43
  attr_reader http2_settings: Hash[Symbol, Integer | bool]
@@ -74,7 +70,7 @@ module HTTPX
74
70
  attr_reader transport: io_type | nil
75
71
 
76
72
  # addresses
77
- attr_reader addresses: Array[Resolver::Entry]?
73
+ attr_reader addresses: (Hash[String, Array[Resolver::Entry]] | Array[Resolver::Entry])?
78
74
 
79
75
  # supported_compression_formats
80
76
  attr_reader supported_compression_formats: Array[String]
@@ -174,8 +170,6 @@ module HTTPX
174
170
 
175
171
  def do_initialize: () -> void
176
172
 
177
- def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
178
-
179
173
  # integer
180
174
  def option_max_concurrent_requests: (int value) -> maybe_unbounded
181
175
  def option_max_requests: (int value) -> maybe_unbounded
@@ -217,15 +211,52 @@ module HTTPX
217
211
 
218
212
  def option_headers: (headers_input | Headers value) -> Headers
219
213
 
220
- def option_timeout: (_ToHash[timeout_type, interval?]) -> timeout
214
+ def option_timeout: (Timeouts | _ToHash[timeout_type, interval?]) -> Timeouts
221
215
 
222
216
  def option_supported_compression_formats: (_ToS | _ToAry[_ToS] value) -> Array[String]
223
217
 
224
218
  def option_transport: (_ToS value) -> String
225
219
 
226
- def option_addresses: (ipaddr | _ToAry[ipaddr] value) -> Array[ipaddr]
220
+ def option_addresses: (ipaddr | _ToAry[ipaddr] value) -> Array[Resolver::Entry]
221
+ | (Hash[String, _ToAry[ipaddr]] value) -> Hash[String, Array[Resolver::Entry]]
227
222
 
228
223
  def option_ip_families: (ip_family | _ToAry[ip_family] value) -> Array[ip_family]
224
+
225
+ class Timeouts
226
+ attr_reader connect_timeout: interval?
227
+ attr_reader settings_timeout: interval?
228
+ attr_reader read_timeout: interval?
229
+ attr_reader write_timeout: interval?
230
+ attr_reader request_timeout: interval?
231
+ attr_reader total_request_timeout: interval?
232
+ attr_reader operation_timeout: interval?
233
+ attr_reader close_handshake_timeout: interval
234
+ attr_reader keep_alive_timeout: interval
235
+ attr_reader ping_timeout: interval
236
+
237
+ def initialize: (
238
+ ?connect_timeout: interval?,
239
+ ?settings_timeout: interval?,
240
+ ?read_timeout: interval?,
241
+ ?write_timeout: interval?,
242
+ ?request_timeout: interval?,
243
+ ?total_request_timeout: interval?,
244
+ ?operation_timeout: interval?,
245
+ ?close_handshake_timeout: interval?,
246
+ ?keep_alive_timeout: interval?,
247
+ ?ping_timeout: interval?
248
+ ) -> void
249
+
250
+ def merge: (Timeouts | Hash[Symbol, interval?]) -> Timeouts
251
+
252
+ def []: (Symbol) -> interval?
253
+
254
+ def to_h: () -> Hash[Symbol, interval?]
255
+
256
+ private
257
+
258
+ def deadline_timeouts?: () -> boolish
259
+ end
229
260
  end
230
261
 
231
262
  type options = Options | Hash[Symbol, untyped]
data/sig/parser/http1.rbs CHANGED
@@ -18,7 +18,7 @@ module HTTPX
18
18
  VERSIONS: Array[String]
19
19
 
20
20
  attr_reader status_code: Integer
21
- attr_reader http_version: [Integer, Integer]
21
+ attr_reader http_version: String
22
22
  attr_reader headers: parsed_headers
23
23
 
24
24
  @observer: _HTTP1Events
@@ -8,7 +8,6 @@ module HTTPX
8
8
  @user: String
9
9
  @password: String
10
10
  @hashed: bool
11
- @nonce: Integer
12
11
 
13
12
  def can_authenticate?: (String? authenticate) -> boolish
14
13
 
data/sig/plugins/auth.rbs CHANGED
@@ -1,14 +1,14 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Auth
4
- type auth_header_value_type = String | ^(?Request request, ?bool should_regenerate) -> string
4
+ type auth_header_value_type = String | ^(?requestAuth 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
10
 
11
- def auth_header_expires_at: () -> (^(Request request) -> _ToF?)?
11
+ def auth_header_expires_at: () -> (^(requestAuth request) -> _ToF?)?
12
12
 
13
13
  def auth_header_expires_in: () -> Float?
14
14
  end
@@ -17,10 +17,11 @@ module HTTPX
17
17
  @auth_header_value: String?
18
18
  @auth_header_value_mtx: Thread::Mutex
19
19
  @skip_auth_header_value: bool
20
+ @auth_header_expires_at: interval?
20
21
 
21
- def authorization: (?string token, ?auth_header_type: string) ?{ (?Request, ?bool) -> string } -> instance
22
+ def authorization: (?string token, ?auth_header_type: string) ?{ (?requestAuth, ?bool) -> string } -> instance
22
23
 
23
- def bearer_auth: (?string token) ?{ (Request) -> string } -> instance
24
+ def bearer_auth: (?string token) ?{ (requestAuth) -> string } -> instance
24
25
 
25
26
  def skip_auth_header: [T] { () -> T } -> T
26
27
 
@@ -28,7 +29,11 @@ module HTTPX
28
29
 
29
30
  private
30
31
 
31
- def generate_auth_token: (Request & RequestMethods request, bool should_regenerate) -> String?
32
+ def generate_auth_token: (requestAuth request, bool should_regenerate) -> String?
33
+
34
+ def try_invalidate_auth_header_value: () -> void
35
+
36
+ def set_auth_header_expires_at: (requestAuth request) -> void
32
37
 
33
38
  def dynamic_auth_token?: (auth_header_value_type auth_header_value) -> boolish
34
39
  end
@@ -52,6 +57,8 @@ module HTTPX
52
57
  def auth_error?: (response response, Options options) -> boolish
53
58
  end
54
59
  end
60
+
61
+ type requestAuth = Request & RequestMethods
55
62
  end
56
63
 
57
64
  type sessionAuth = Session & Auth::InstanceMethods