httpx 1.9.0 → 1.9.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.
- checksums.yaml +4 -4
- data/doc/release_notes/1_8_1.md +1 -1
- data/doc/release_notes/1_8_2.md +4 -4
- data/doc/release_notes/1_8_3.md +3 -5
- data/doc/release_notes/1_8_4.md +1 -1
- data/doc/release_notes/1_9_0.md +7 -7
- data/doc/release_notes/1_9_1.md +32 -0
- data/doc/release_notes/1_9_2.md +19 -0
- data/lib/httpx/adapters/faraday.rb +1 -1
- data/lib/httpx/adapters/webmock.rb +15 -2
- data/lib/httpx/connection/http1.rb +24 -17
- data/lib/httpx/connection/http2.rb +110 -30
- data/lib/httpx/connection.rb +164 -167
- data/lib/httpx/io/tcp.rb +24 -7
- data/lib/httpx/options.rb +23 -20
- data/lib/httpx/plugins/aws_sigv4.rb +0 -1
- data/lib/httpx/plugins/cache.rb +1 -1
- data/lib/httpx/plugins/callbacks.rb +81 -19
- data/lib/httpx/plugins/content_digest.rb +3 -5
- data/lib/httpx/plugins/expect.rb +8 -1
- data/lib/httpx/plugins/fiber_concurrency.rb +56 -19
- data/lib/httpx/plugins/h2c.rb +12 -11
- data/lib/httpx/plugins/hedging.rb +2 -2
- data/lib/httpx/plugins/ntlm_auth.rb +4 -3
- data/lib/httpx/plugins/ntlm_v2_auth.rb +4 -3
- data/lib/httpx/plugins/oauth.rb +1 -1
- data/lib/httpx/plugins/persistent.rb +9 -1
- data/lib/httpx/plugins/proxy/http.rb +24 -16
- data/lib/httpx/plugins/proxy/socks5.rb +4 -4
- data/lib/httpx/plugins/proxy.rb +9 -16
- data/lib/httpx/plugins/query.rb +1 -0
- data/lib/httpx/plugins/stream.rb +12 -10
- data/lib/httpx/plugins/stream_bidi.rb +4 -0
- data/lib/httpx/plugins/tracing.rb +60 -21
- data/lib/httpx/plugins/upgrade/h2.rb +2 -2
- data/lib/httpx/request.rb +1 -1
- data/lib/httpx/resolver/https.rb +3 -2
- data/lib/httpx/resolver/native.rb +19 -9
- data/lib/httpx/resolver/resolver.rb +2 -2
- data/lib/httpx/resolver/system.rb +4 -0
- data/lib/httpx/resolver.rb +5 -5
- data/lib/httpx/response.rb +5 -1
- data/lib/httpx/selector.rb +108 -7
- data/lib/httpx/session.rb +20 -24
- data/lib/httpx/timers.rb +3 -5
- data/lib/httpx/transcoder/json.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +1 -0
- data/sig/chainable.rbs +2 -1
- data/sig/connection/http1.rbs +4 -2
- data/sig/connection/http2.rbs +8 -2
- data/sig/connection.rbs +13 -8
- data/sig/io/tcp.rbs +5 -0
- data/sig/options.rbs +9 -0
- data/sig/plugins/callbacks.rbs +21 -1
- data/sig/plugins/expect.rbs +6 -0
- data/sig/plugins/fiber_concurrency.rbs +10 -1
- data/sig/plugins/proxy/http.rbs +3 -1
- data/sig/plugins/proxy.rbs +4 -0
- data/sig/plugins/stream_bidi.rbs +0 -2
- data/sig/plugins/tracing.rbs +10 -2
- data/sig/resolver/https.rbs +2 -0
- data/sig/resolver/native.rbs +3 -0
- data/sig/resolver/resolver.rbs +1 -1
- data/sig/resolver/system.rbs +2 -0
- data/sig/resolver.rbs +1 -1
- data/sig/selector.rbs +15 -1
- data/sig/session.rbs +2 -4
- metadata +5 -1
data/lib/httpx/selector.rb
CHANGED
|
@@ -21,11 +21,17 @@ module HTTPX
|
|
|
21
21
|
class Selector
|
|
22
22
|
extend Forwardable
|
|
23
23
|
|
|
24
|
+
HAS_FIBER_SCHEDULER = Fiber.respond_to?(:scheduler)
|
|
25
|
+
|
|
24
26
|
READABLE = %i[rw r].freeze
|
|
25
27
|
WRITABLE = %i[rw w].freeze
|
|
26
28
|
|
|
29
|
+
# max number of consecutive ticks allowed to neither wait on IO nor call a ready selectable.
|
|
30
|
+
MAX_BUSY_ITERATIONS = 1000
|
|
31
|
+
|
|
27
32
|
private_constant :READABLE
|
|
28
33
|
private_constant :WRITABLE
|
|
34
|
+
private_constant :MAX_BUSY_ITERATIONS
|
|
29
35
|
|
|
30
36
|
def_delegator :@timers, :after
|
|
31
37
|
|
|
@@ -35,6 +41,8 @@ module HTTPX
|
|
|
35
41
|
@timers = Timers.new
|
|
36
42
|
@selectables = []
|
|
37
43
|
@is_timer_interval = false
|
|
44
|
+
@busy_iterations = 0
|
|
45
|
+
@last_select_registered = nil
|
|
38
46
|
end
|
|
39
47
|
|
|
40
48
|
def empty?
|
|
@@ -51,11 +59,16 @@ module HTTPX
|
|
|
51
59
|
timeout = next_timeout
|
|
52
60
|
if timeout && timeout.negative?
|
|
53
61
|
@timers.fire
|
|
62
|
+
busy_loop_check(timeout)
|
|
54
63
|
throw(:jump_tick)
|
|
55
64
|
end
|
|
56
65
|
|
|
57
66
|
begin
|
|
67
|
+
selected = false
|
|
68
|
+
|
|
58
69
|
select(timeout) do |c|
|
|
70
|
+
selected = true
|
|
71
|
+
|
|
59
72
|
c.log(level: 2) { "[#{c.state}] selected from selector##{object_id}#{" after #{timeout} secs" unless timeout.nil?}..." }
|
|
60
73
|
|
|
61
74
|
c.call
|
|
@@ -64,6 +77,19 @@ module HTTPX
|
|
|
64
77
|
@timers.fire
|
|
65
78
|
rescue TimeoutError => e
|
|
66
79
|
@timers.fire(e)
|
|
80
|
+
|
|
81
|
+
@busy_iterations = 0
|
|
82
|
+
else
|
|
83
|
+
# a tick is healthy if it either called a ready selectable, or actually blocked waiting for one.
|
|
84
|
+
# without a timeout, #select only blocks when something registered interests; with one,
|
|
85
|
+
# it always sleeps or selects, but a zero timeout just polls.
|
|
86
|
+
waited = timeout.nil? ? @last_select_registered.to_i.positive? : timeout.positive?
|
|
87
|
+
|
|
88
|
+
if selected || waited
|
|
89
|
+
@busy_iterations = 0
|
|
90
|
+
else
|
|
91
|
+
busy_loop_check(timeout)
|
|
92
|
+
end
|
|
67
93
|
end
|
|
68
94
|
end
|
|
69
95
|
end
|
|
@@ -74,7 +100,9 @@ module HTTPX
|
|
|
74
100
|
|
|
75
101
|
selectables.delete_if do |sel|
|
|
76
102
|
sel.terminate
|
|
77
|
-
|
|
103
|
+
# TODO: this check is racy: connections check in to the pool on termination, and may check out and
|
|
104
|
+
# change state immediately after. find a more idempotent way of doing this.
|
|
105
|
+
sel.current_selector != self
|
|
78
106
|
end
|
|
79
107
|
|
|
80
108
|
until selectables.empty?
|
|
@@ -133,6 +161,8 @@ module HTTPX
|
|
|
133
161
|
private
|
|
134
162
|
|
|
135
163
|
def select(interval, &block)
|
|
164
|
+
@last_select_registered = nil
|
|
165
|
+
|
|
136
166
|
# do not cause an infinite loop here.
|
|
137
167
|
#
|
|
138
168
|
# this may happen if timeout calculation actually triggered an error which causes
|
|
@@ -153,10 +183,12 @@ module HTTPX
|
|
|
153
183
|
# @type var w: (selectable | Array[selectable])?
|
|
154
184
|
r, w = nil
|
|
155
185
|
|
|
186
|
+
registered = 0
|
|
187
|
+
|
|
156
188
|
@selectables.delete_if do |io|
|
|
157
189
|
interests = io.interests
|
|
158
190
|
|
|
159
|
-
is_closed = io.
|
|
191
|
+
is_closed = io.closed_for_select?
|
|
160
192
|
|
|
161
193
|
if is_closed
|
|
162
194
|
# the process by which io was closed may have already triggered the on_close callback,
|
|
@@ -166,6 +198,8 @@ module HTTPX
|
|
|
166
198
|
end
|
|
167
199
|
|
|
168
200
|
if interests
|
|
201
|
+
registered += 1
|
|
202
|
+
|
|
169
203
|
io.log(level: 2) do
|
|
170
204
|
"[#{io.state}] registering in selector##{object_id} for select (#{interests})#{" for #{interval} seconds" unless interval.nil?}"
|
|
171
205
|
end
|
|
@@ -182,6 +216,8 @@ module HTTPX
|
|
|
182
216
|
is_closed
|
|
183
217
|
end
|
|
184
218
|
|
|
219
|
+
@last_select_registered = registered
|
|
220
|
+
|
|
185
221
|
case r
|
|
186
222
|
when Array
|
|
187
223
|
w = Array(w) unless w.nil?
|
|
@@ -192,7 +228,14 @@ module HTTPX
|
|
|
192
228
|
when Array
|
|
193
229
|
select_many(r, w, interval, &block)
|
|
194
230
|
when nil
|
|
195
|
-
|
|
231
|
+
unless interval && @selectables.any?
|
|
232
|
+
# @fiber-switch-guard
|
|
233
|
+
# may mean that another fiber is moving a selectable forward (i.e. closing its
|
|
234
|
+
# socket), so let the scheduler resume it.
|
|
235
|
+
sleep(0) if HAS_FIBER_SCHEDULER && Fiber.scheduler
|
|
236
|
+
|
|
237
|
+
return
|
|
238
|
+
end
|
|
196
239
|
|
|
197
240
|
# no selectables
|
|
198
241
|
# TODO: replace with sleep?
|
|
@@ -221,18 +264,19 @@ module HTTPX
|
|
|
221
264
|
begin
|
|
222
265
|
readers, writers = ::IO.select(r, w, nil, interval)
|
|
223
266
|
rescue IOError => e
|
|
224
|
-
(
|
|
225
|
-
# TODO: is there a way to cheaply find the IO associated with the error?
|
|
267
|
+
selectables_with_closed_ios(r, w).each do |sel|
|
|
226
268
|
sel.on_io_error(e)
|
|
227
269
|
end
|
|
270
|
+
|
|
271
|
+
return
|
|
228
272
|
rescue StandardError => e
|
|
229
|
-
(
|
|
273
|
+
selectables_with_closed_ios(r, w).each do |sel|
|
|
230
274
|
sel.on_error(e)
|
|
231
275
|
end
|
|
232
276
|
|
|
233
277
|
return
|
|
234
278
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
235
|
-
|
|
279
|
+
Set[*Array(r), *Array(w)].each do |sel|
|
|
236
280
|
sel.force_close(true)
|
|
237
281
|
end
|
|
238
282
|
|
|
@@ -258,6 +302,16 @@ module HTTPX
|
|
|
258
302
|
end
|
|
259
303
|
end
|
|
260
304
|
|
|
305
|
+
# returns the selectables whose IOs were closed.
|
|
306
|
+
def selectables_with_closed_ios(r, w)
|
|
307
|
+
selectables = Set[*Array(r), *Array(w)]
|
|
308
|
+
|
|
309
|
+
closed = selectables.select { |sel| sel.to_io.closed? }
|
|
310
|
+
|
|
311
|
+
# When none of them was closed, the error can't be attributed to any of them, so all are returned.
|
|
312
|
+
closed.empty? ? selectables : closed
|
|
313
|
+
end
|
|
314
|
+
|
|
261
315
|
def select_one(io, interests, interval)
|
|
262
316
|
begin
|
|
263
317
|
result =
|
|
@@ -306,6 +360,53 @@ module HTTPX
|
|
|
306
360
|
connection_interval
|
|
307
361
|
end
|
|
308
362
|
|
|
363
|
+
def busy_loop_check(timeout)
|
|
364
|
+
@busy_iterations += 1
|
|
365
|
+
|
|
366
|
+
return if @busy_iterations < MAX_BUSY_ITERATIONS
|
|
367
|
+
|
|
368
|
+
# this selector is reused by subsequent requests in the same thread/fiber.
|
|
369
|
+
@busy_iterations = 0
|
|
370
|
+
|
|
371
|
+
raise Error, busy_loop_error_message(timeout)
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def busy_loop_error_message(timeout)
|
|
375
|
+
selectables_state = @selectables.map do |sel|
|
|
376
|
+
state = +"#{sel.class}:#{sel.object_id}[state:#{sel.state},inflight?:#{sel.inflight?}"
|
|
377
|
+
|
|
378
|
+
case sel
|
|
379
|
+
when Connection
|
|
380
|
+
state << ",origin:#{sel.origin},pending:#{sel.pending.size}," \
|
|
381
|
+
"io-state:#{sel.io&.state.inspect},io-interests:#{sel.io&.interests.inspect}," \
|
|
382
|
+
"in-session:#{!sel.current_session.nil?}"
|
|
383
|
+
when Resolver::Resolver
|
|
384
|
+
num_connections = 0
|
|
385
|
+
sel.each_connection { num_connections += 1 }
|
|
386
|
+
state << ",connections:#{num_connections}"
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
state << "]"
|
|
390
|
+
end.join(",")
|
|
391
|
+
|
|
392
|
+
timers_state = @timers.instance_variable_get(:@intervals).map do |interval|
|
|
393
|
+
"#{interval.interval}s(callbacks:#{interval.instance_variable_get(:@callbacks).size})"
|
|
394
|
+
end.join(",")
|
|
395
|
+
|
|
396
|
+
"selector corrupted, aborted after looping #{MAX_BUSY_ITERATIONS} times " \
|
|
397
|
+
"without waiting on IO nor calling a ready selectable, " \
|
|
398
|
+
"please report this https://gitlab.com/os85/httpx/-/work_items " \
|
|
399
|
+
"along with debug logs\n(" \
|
|
400
|
+
"next-timeout:#{timeout.inspect}," \
|
|
401
|
+
"is-timer-interval:#{@is_timer_interval}," \
|
|
402
|
+
"timers:[#{timers_state}]," \
|
|
403
|
+
"next-interval-at:#{@timers.instance_variable_get(:@next_interval_at).inspect}," \
|
|
404
|
+
"last-select-registered:#{@last_select_registered.inspect}," \
|
|
405
|
+
"num-selectables:#{@selectables.size}," \
|
|
406
|
+
"selectables:[#{selectables_state}]" \
|
|
407
|
+
")"
|
|
408
|
+
end
|
|
409
|
+
|
|
309
410
|
if RUBY_ENGINE == "jruby"
|
|
310
411
|
def rw_wait(io, interval)
|
|
311
412
|
io.to_io.wait(interval, :read_write)
|
data/lib/httpx/session.rb
CHANGED
|
@@ -343,8 +343,6 @@ module HTTPX
|
|
|
343
343
|
pending_idxs = [] #: Array[Integer]
|
|
344
344
|
pending = 0
|
|
345
345
|
|
|
346
|
-
waiting = false
|
|
347
|
-
|
|
348
346
|
requests.each do |request|
|
|
349
347
|
send_request(request, selector)
|
|
350
348
|
end
|
|
@@ -357,7 +355,7 @@ module HTTPX
|
|
|
357
355
|
if response.nil?
|
|
358
356
|
pending += 1
|
|
359
357
|
request.on_response_arrived = lambda do
|
|
360
|
-
pending_idxs << idx
|
|
358
|
+
pending_idxs << idx
|
|
361
359
|
end
|
|
362
360
|
end
|
|
363
361
|
end
|
|
@@ -365,13 +363,10 @@ module HTTPX
|
|
|
365
363
|
|
|
366
364
|
log(level: 2) { "waiting to receive #{pending} pending requests..." }
|
|
367
365
|
|
|
368
|
-
|
|
369
|
-
# loop on selector until at least one response has been received.
|
|
370
|
-
waiting = true
|
|
371
|
-
catch(:coalesced) { selector.next_tick }
|
|
372
|
-
waiting = false
|
|
373
|
-
|
|
366
|
+
loop do
|
|
374
367
|
while (idx = pending_idxs.shift)
|
|
368
|
+
next if responses[idx]
|
|
369
|
+
|
|
375
370
|
request = requests[idx]
|
|
376
371
|
|
|
377
372
|
response = fetch_response(request, selector, request.options)
|
|
@@ -387,6 +382,11 @@ module HTTPX
|
|
|
387
382
|
request.on_response_arrived = nil
|
|
388
383
|
pending -= 1
|
|
389
384
|
end
|
|
385
|
+
|
|
386
|
+
break if pending.zero? || selector.empty?
|
|
387
|
+
|
|
388
|
+
# loop on selector until at least one response has been received.
|
|
389
|
+
catch(:coalesced) { selector.next_tick }
|
|
390
390
|
end
|
|
391
391
|
|
|
392
392
|
raise Error, "something went wrong, #{pending} responses not found " \
|
|
@@ -409,11 +409,20 @@ module HTTPX
|
|
|
409
409
|
return
|
|
410
410
|
end
|
|
411
411
|
|
|
412
|
-
|
|
412
|
+
from_pool = false
|
|
413
|
+
if (resolver = selector.find_resolver(connection.options))
|
|
414
|
+
resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in selector##{selector.object_id}" }
|
|
415
|
+
else
|
|
416
|
+
resolver = @pool.checkout_resolver(connection.options)
|
|
417
|
+
resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in pool##{@pool.object_id}" }
|
|
418
|
+
pin(resolver, selector)
|
|
419
|
+
from_pool = true
|
|
420
|
+
end
|
|
413
421
|
|
|
414
422
|
pin(connection, selector)
|
|
423
|
+
|
|
415
424
|
if early_resolve(resolver, connection)
|
|
416
|
-
@pool.checkin_resolver(resolver)
|
|
425
|
+
@pool.checkin_resolver(resolver) if from_pool
|
|
417
426
|
else
|
|
418
427
|
resolver.lazy_resolve(connection)
|
|
419
428
|
end
|
|
@@ -443,19 +452,6 @@ module HTTPX
|
|
|
443
452
|
coalesce_connections(found_connection, connection, selector, from_pool)
|
|
444
453
|
end
|
|
445
454
|
|
|
446
|
-
def find_resolver_for(connection, selector)
|
|
447
|
-
if (resolver = selector.find_resolver(connection.options))
|
|
448
|
-
resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in selector##{selector.object_id}" }
|
|
449
|
-
return resolver
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
resolver = @pool.checkout_resolver(connection.options)
|
|
453
|
-
resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in pool##{@pool.object_id}" }
|
|
454
|
-
pin(resolver, selector)
|
|
455
|
-
|
|
456
|
-
resolver
|
|
457
|
-
end
|
|
458
|
-
|
|
459
455
|
# coalesces +conn2+ into +conn1+. if +conn1+ was loaded from the connection pool
|
|
460
456
|
# (it is known via +from_pool+), then it adds its to the +selector+.
|
|
461
457
|
def coalesce_connections(conn1, conn2, selector, from_pool)
|
data/lib/httpx/timers.rb
CHANGED
|
@@ -33,15 +33,13 @@ module HTTPX
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def wait_interval
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
first_interval = @intervals.first
|
|
36
|
+
drop_elapsed!(0) if @intervals.first&.elapsed?(0)
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
return if @intervals.empty?
|
|
41
39
|
|
|
42
40
|
@next_interval_at = Utils.now
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
@intervals.first.interval
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def fire(error = nil)
|
|
@@ -56,7 +56,7 @@ module HTTPX::Transcoder
|
|
|
56
56
|
def json_load(...); MultiJson.load(...); end
|
|
57
57
|
def json_dump(...); MultiJson.dump(...); end
|
|
58
58
|
elsif defined?(Oj)
|
|
59
|
-
def json_load(response,
|
|
59
|
+
def json_load(response, options = {}); Oj.load(response.to_s, { mode: :strict }.merge(options)); end
|
|
60
60
|
def json_dump(obj, options = {}); Oj.dump(obj, { mode: :compat }.merge(options)); end
|
|
61
61
|
elsif defined?(Yajl)
|
|
62
62
|
def json_load(response, ...); Yajl::Parser.new(...).parse(response.to_s); end
|
data/lib/httpx/version.rb
CHANGED
data/lib/httpx.rb
CHANGED
data/sig/chainable.rbs
CHANGED
|
@@ -2,7 +2,8 @@ module HTTPX
|
|
|
2
2
|
module Chainable
|
|
3
3
|
def request: (Request, **untyped) -> response
|
|
4
4
|
| (*Request, **untyped) -> Array[response]
|
|
5
|
-
| (verb, uri
|
|
5
|
+
| (verb, uri, **untyped) -> response
|
|
6
|
+
| (verb, [uri], **untyped) -> response
|
|
6
7
|
| (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
|
|
7
8
|
| (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
|
|
8
9
|
|
data/sig/connection/http1.rbs
CHANGED
|
@@ -36,7 +36,7 @@ module HTTPX
|
|
|
36
36
|
|
|
37
37
|
def <<: (string) -> void
|
|
38
38
|
|
|
39
|
-
def send: (Request request, ?bool head) ->
|
|
39
|
+
def send: (Request request, ?bool head) -> bool
|
|
40
40
|
|
|
41
41
|
def consume: () -> void
|
|
42
42
|
|
|
@@ -60,9 +60,11 @@ module HTTPX
|
|
|
60
60
|
|
|
61
61
|
def timeout: () -> interval?
|
|
62
62
|
|
|
63
|
+
def no_more_requests?: () -> bool
|
|
64
|
+
|
|
63
65
|
private
|
|
64
66
|
|
|
65
|
-
def initialize: (Buffer buffer, Options options) -> untyped
|
|
67
|
+
def initialize: (Buffer buffer, Array[Request] pending, Options options) -> untyped
|
|
66
68
|
|
|
67
69
|
def manage_connection: (Request request, Response response) -> void
|
|
68
70
|
|
data/sig/connection/http2.rbs
CHANGED
|
@@ -20,6 +20,7 @@ module HTTPX
|
|
|
20
20
|
@buffer: Buffer
|
|
21
21
|
@handshake_completed: bool
|
|
22
22
|
@wait_for_handshake: bool
|
|
23
|
+
@last_error: GoawayError?
|
|
23
24
|
|
|
24
25
|
def interests: () -> io_interests?
|
|
25
26
|
|
|
@@ -47,11 +48,15 @@ module HTTPX
|
|
|
47
48
|
|
|
48
49
|
def reset_requests: () -> void
|
|
49
50
|
|
|
51
|
+
def no_more_requests?: () -> bool
|
|
52
|
+
|
|
50
53
|
private
|
|
51
54
|
|
|
52
|
-
def initialize: (Buffer buffer, Options options) -> untyped
|
|
55
|
+
def initialize: (Buffer buffer, Array[Request] pending, Options options) -> untyped
|
|
56
|
+
|
|
57
|
+
def waiting_for_peer?: () -> bool
|
|
53
58
|
|
|
54
|
-
def
|
|
59
|
+
def can_buffer_pending_requests?: () -> bool
|
|
55
60
|
|
|
56
61
|
def send_pending: () -> void
|
|
57
62
|
|
|
@@ -119,6 +124,7 @@ module HTTPX
|
|
|
119
124
|
UNRECOVERABLE_ERRORS: Array[Symbol]
|
|
120
125
|
|
|
121
126
|
@code: Symbol
|
|
127
|
+
@last_stream_id: Integer
|
|
122
128
|
|
|
123
129
|
def initialize: (Symbol code, Integer last_stream_id) -> void
|
|
124
130
|
|
data/sig/connection.rbs
CHANGED
|
@@ -37,7 +37,6 @@ module HTTPX
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
@window_size: Integer
|
|
40
|
-
@inflight: Integer
|
|
41
40
|
@max_concurrent_requests: Integer?
|
|
42
41
|
@keep_alive_timeout: interval?
|
|
43
42
|
@timeout: interval?
|
|
@@ -83,7 +82,7 @@ module HTTPX
|
|
|
83
82
|
|
|
84
83
|
def purge_pending: () { (Request request) -> void } -> void
|
|
85
84
|
|
|
86
|
-
def connecting?: () -> bool
|
|
85
|
+
def connecting?: (?Symbol state) -> bool
|
|
87
86
|
|
|
88
87
|
def current_context?: () -> bool
|
|
89
88
|
|
|
@@ -91,6 +90,8 @@ module HTTPX
|
|
|
91
90
|
|
|
92
91
|
def inflight?: () -> boolish
|
|
93
92
|
|
|
93
|
+
def closed_for_select?: () -> bool
|
|
94
|
+
|
|
94
95
|
def interests: () -> io_interests?
|
|
95
96
|
|
|
96
97
|
def to_io: () -> IO
|
|
@@ -125,7 +126,7 @@ module HTTPX
|
|
|
125
126
|
|
|
126
127
|
def handle_connect_error: (StandardError error) -> void
|
|
127
128
|
|
|
128
|
-
def disconnect: () ->
|
|
129
|
+
def disconnect: () -> bool
|
|
129
130
|
|
|
130
131
|
def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
|
|
131
132
|
|
|
@@ -139,6 +140,10 @@ module HTTPX
|
|
|
139
140
|
|
|
140
141
|
def initialize_type: (http_uri uri, Options options) -> io_type
|
|
141
142
|
|
|
143
|
+
def connect_attempt_time_left: () -> interval?
|
|
144
|
+
|
|
145
|
+
def connect_next: (StandardError error) -> void
|
|
146
|
+
|
|
142
147
|
def try_connect: () -> void
|
|
143
148
|
|
|
144
149
|
def connect: () -> void
|
|
@@ -151,12 +156,12 @@ module HTTPX
|
|
|
151
156
|
|
|
152
157
|
def parser: () -> (Object & _Parser)
|
|
153
158
|
|
|
154
|
-
def send_request_to_parser: (Request request) ->
|
|
155
|
-
|
|
156
|
-
def enqueue_pending_requests_from_parser: (HTTP1 | HTTP2 parser) -> void
|
|
159
|
+
def send_request_to_parser: (Request request, ?bool head) -> bool
|
|
157
160
|
|
|
158
161
|
def build_parser: (?String protocol) -> (Object & _Parser)
|
|
159
162
|
|
|
163
|
+
def on_parser_error: (Request request, Exception | Symbol error) -> void
|
|
164
|
+
|
|
160
165
|
def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
|
|
161
166
|
|
|
162
167
|
def transition: (Symbol nextstate) -> void
|
|
@@ -173,9 +178,9 @@ module HTTPX
|
|
|
173
178
|
|
|
174
179
|
def no_more_selector_check: () -> void
|
|
175
180
|
|
|
176
|
-
def
|
|
181
|
+
def clear_pending_requests: () -> void
|
|
177
182
|
|
|
178
|
-
def no_more_requests?: () ->
|
|
183
|
+
def no_more_requests?: () -> boolish
|
|
179
184
|
|
|
180
185
|
def handle_error: (StandardError error, ?Request? request) -> void
|
|
181
186
|
|
data/sig/io/tcp.rbs
CHANGED
|
@@ -25,6 +25,7 @@ module HTTPX
|
|
|
25
25
|
@keep_open: bool
|
|
26
26
|
|
|
27
27
|
@ip_index: Integer
|
|
28
|
+
@attempt_started_at: Float?
|
|
28
29
|
|
|
29
30
|
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
|
30
31
|
def initialize: (URI::Generic origin, Array[Resolver::Entry]? addresses, Options options) ?{ (instance) -> void } -> void
|
|
@@ -33,6 +34,10 @@ module HTTPX
|
|
|
33
34
|
|
|
34
35
|
def addresses?: () -> bool
|
|
35
36
|
|
|
37
|
+
def connect_attempt_time_left: () -> Float?
|
|
38
|
+
|
|
39
|
+
def next_address!: (StandardError e) -> void
|
|
40
|
+
|
|
36
41
|
def to_io: () -> IO
|
|
37
42
|
|
|
38
43
|
def protocol: () -> String
|
data/sig/options.rbs
CHANGED
|
@@ -166,6 +166,15 @@ module HTTPX
|
|
|
166
166
|
|
|
167
167
|
private
|
|
168
168
|
|
|
169
|
+
module OptionMethodsCache
|
|
170
|
+
# RBS test does not support the method cache pattern
|
|
171
|
+
# def option_integer: (int value) -> maybe_unbounded
|
|
172
|
+
|
|
173
|
+
# def option_hash: (_ToHash[Symbol, untyped] value) -> Hash[Symbol, untyped]
|
|
174
|
+
|
|
175
|
+
# def option_itself: [T] (T value) -> T
|
|
176
|
+
end
|
|
177
|
+
|
|
169
178
|
def initialize: (?options options) -> void
|
|
170
179
|
|
|
171
180
|
def do_initialize: () -> void
|
data/sig/plugins/callbacks.rbs
CHANGED
|
@@ -29,11 +29,31 @@ module HTTPX
|
|
|
29
29
|
|
|
30
30
|
private
|
|
31
31
|
|
|
32
|
-
def emit_or_callback_error: (*untyped) -> void
|
|
32
|
+
def emit_or_callback_error: (*untyped, **untyped) -> void
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
module RequestMethods
|
|
36
|
+
attr_reader connection: callbackConnection?
|
|
37
|
+
|
|
38
|
+
attr_reader last_connection: callbackConnection?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module ResponseMethods
|
|
33
42
|
end
|
|
34
43
|
|
|
35
44
|
module ConnectionMethods
|
|
45
|
+
@last_error: StandardError?
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def with_current_connection: [T] (callbackRequest? request) { () -> T } -> T
|
|
50
|
+
|
|
51
|
+
def with_last_error: [T] (StandardError request) { () -> T } -> T
|
|
36
52
|
end
|
|
53
|
+
|
|
54
|
+
type callbackRequest = Request & RequestMethods
|
|
55
|
+
|
|
56
|
+
type callbackConnection = Connection & ConnectionMethods
|
|
37
57
|
end
|
|
38
58
|
|
|
39
59
|
type sessionCallbacks = Session & Callbacks::InstanceMethods
|
data/sig/plugins/expect.rbs
CHANGED
|
@@ -16,19 +16,28 @@ module HTTPX
|
|
|
16
16
|
|
|
17
17
|
def current_context?: () -> boolish
|
|
18
18
|
|
|
19
|
+
def closed_for_select?: () -> bool
|
|
20
|
+
|
|
19
21
|
def send: (request request) -> void
|
|
20
22
|
|
|
21
23
|
private
|
|
22
24
|
|
|
23
|
-
def backlog?: () ->
|
|
25
|
+
def backlog?: () -> boolish
|
|
26
|
+
|
|
27
|
+
def clear_pending_requests: () -> void
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
module HTTP1Methods
|
|
31
|
+
def interests: () -> io_interests?
|
|
32
|
+
|
|
33
|
+
def backlog?: () -> bool
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
module HTTP2Methods
|
|
30
37
|
@contexts: Hash[Fiber, Set[Request]]
|
|
31
38
|
|
|
39
|
+
def backlog?: () -> bool
|
|
40
|
+
|
|
32
41
|
private
|
|
33
42
|
|
|
34
43
|
def add_to_context: (request request) -> void
|
data/sig/plugins/proxy/http.rbs
CHANGED
|
@@ -3,6 +3,8 @@ module HTTPX
|
|
|
3
3
|
module Proxy
|
|
4
4
|
module HTTP
|
|
5
5
|
module OptionsMethods
|
|
6
|
+
def connect_request_class: () -> singleton(Request) # & ConnectRequestMethods)
|
|
7
|
+
|
|
6
8
|
def proxy_headers: () -> Headers?
|
|
7
9
|
|
|
8
10
|
def enable_proxy_tunnel: () -> bool?
|
|
@@ -26,7 +28,7 @@ module HTTPX
|
|
|
26
28
|
module ProxyParser
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
module ConnectRequestMethods : Request
|
|
30
32
|
def initialize: (generic_uri uri, Options options) -> void
|
|
31
33
|
end
|
|
32
34
|
end
|
data/sig/plugins/proxy.rbs
CHANGED
data/sig/plugins/stream_bidi.rbs
CHANGED
data/sig/plugins/tracing.rbs
CHANGED
|
@@ -29,6 +29,12 @@ module HTTPX
|
|
|
29
29
|
attr_accessor init_time: Time?
|
|
30
30
|
|
|
31
31
|
attr_accessor handshake_time: Float?
|
|
32
|
+
|
|
33
|
+
attr_accessor enqueue_time: Time?
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def calculate_init_time: () -> Time
|
|
32
38
|
end
|
|
33
39
|
|
|
34
40
|
module ConnectionMethods
|
|
@@ -36,10 +42,12 @@ module HTTPX
|
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
module HTTP2Methods
|
|
39
|
-
@handshake_time: Float?
|
|
40
45
|
@handshake_init_time: Time
|
|
46
|
+
@pending: Array[tracingRequest]
|
|
47
|
+
|
|
48
|
+
private
|
|
41
49
|
|
|
42
|
-
def
|
|
50
|
+
def on_settings: (*untyped) -> void
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
type tracingRequest = Request & RequestMethods
|