httpx 1.9.1 → 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_9_1.md +1 -1
- data/doc/release_notes/1_9_2.md +19 -0
- data/lib/httpx/adapters/webmock.rb +1 -1
- data/lib/httpx/connection/http2.rb +2 -1
- data/lib/httpx/connection.rb +6 -5
- data/lib/httpx/options.rb +23 -20
- data/lib/httpx/plugins/cache.rb +1 -1
- data/lib/httpx/plugins/callbacks.rb +80 -19
- data/lib/httpx/plugins/persistent.rb +9 -1
- data/lib/httpx/plugins/proxy/http.rb +1 -0
- data/lib/httpx/plugins/proxy/socks5.rb +2 -2
- data/lib/httpx/plugins/proxy.rb +4 -4
- data/lib/httpx/plugins/tracing.rb +5 -7
- data/lib/httpx/session.rb +20 -24
- data/lib/httpx/timers.rb +3 -5
- data/lib/httpx/version.rb +1 -1
- data/sig/connection.rbs +2 -2
- data/sig/options.rbs +9 -0
- data/sig/plugins/callbacks.rbs +21 -1
- data/sig/plugins/proxy.rbs +4 -0
- data/sig/session.rbs +1 -3
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 705bf82ecea8d9d211f13b62439ac009553f60f931c9ec1be928a80a3eddb289
|
|
4
|
+
data.tar.gz: 915d45b1649daff3c8e7144ee0867e04629e68e4f81d71da5c691f02e7144c0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bea9d06dc322fc22bbda19db9fd269d5932e176518282895b0b3cba8610763ff64afe542c1b1c6b9d456d31a56709a0e608763434d31dbecd841176eae0df1c
|
|
7
|
+
data.tar.gz: eb0b02d8e3ffe17740e6695452e04d92e7e317f8e3ee4c4cc578f5c4c626a94432606544e37ff2279d6cafa65119742354026a3ca3448eb7ab68dadd7931af8e
|
data/doc/release_notes/1_9_1.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 1.9.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Improvements
|
|
4
4
|
|
|
5
5
|
* `:connect_timeout` will be split across the IP addresses available for the hostname. The connection phase will then loop on the list, and on each connect timeout, the next IP will tried; the connect timeout error will then only be raised if no healthy connections could be established to any of the IPs. This is the same heuristic used by curl v7.
|
|
6
6
|
* Connections and parsers share the same pending requests queue: before, each had their own, and requests could fly across them depending on the several edge cases, thereby making it needlessly complex and wasteful. Also, when moving requests is necessary, they can short-circuit more efficiently.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 1.9.2
|
|
2
|
+
|
|
3
|
+
## Improvements
|
|
4
|
+
|
|
5
|
+
* options: define option setters using cache module unbound methods optimization.
|
|
6
|
+
* `:callbacks` plugin: emit an error param in the block for the `:connection_closed` callback (ex: `session.on_connection_closed { |origin, error| } `).
|
|
7
|
+
* `:callbacks` plugin: expose the connection object in all the callbacks (`session.on_connection_opened {|_, _, connection: | }`, `session.on_request_started {|request, connection: | }`), allows inspecting connection-specific data.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Bugfixes
|
|
11
|
+
|
|
12
|
+
* session: do not checkin a resolver already registered in the selector.
|
|
13
|
+
* session: fix receive requests loop handling when an error happens during #fetch_response.
|
|
14
|
+
* timers: avoid stale timer intervals delaying session cleanup
|
|
15
|
+
* http2: raise error on GOAWAY if the server never handled any streams; this fixes a regression from 1.9.1 which didn't raise an error on GOAWAY and instead allowed unfinished streams to retry transparently; it was also doing that for cases where the peer server would send a GOAWAY without ever processing streams, creating a potential loop. This fix closes the loop if the GOAWAY has a last_stream_id = 0.
|
|
16
|
+
* `:cache` plugin: fix regression where error responses weren't being preserved.
|
|
17
|
+
* `:callbacks` plugin: only call `:connection_closed` when the connection actually closes (the previous impl didn't guarantee that)
|
|
18
|
+
* To do that, `Connection#disconnect` will return a boolean telling whether it actually disconnected, which simplifies overrides
|
|
19
|
+
* `proxy`: implement request accepted callback for the connect proxy parser, so that the connect request sets its request timeouts.
|
|
@@ -144,9 +144,9 @@ module WebMock
|
|
|
144
144
|
request.transition(:body)
|
|
145
145
|
request.transition(:trailers)
|
|
146
146
|
request.transition(:done)
|
|
147
|
-
response.finish!
|
|
148
147
|
request.response = response
|
|
149
148
|
response << mock_response.body.dup unless response.is_a?(HTTPX::ErrorResponse)
|
|
149
|
+
response.finish!
|
|
150
150
|
request.emit_response(response)
|
|
151
151
|
request_signature.headers = request.headers.to_h
|
|
152
152
|
|
|
@@ -38,7 +38,7 @@ module HTTPX
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def unrecoverable?
|
|
41
|
-
UNRECOVERABLE_ERRORS.include?(@code)
|
|
41
|
+
@last_stream_id.zero? || UNRECOVERABLE_ERRORS.include?(@code)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -228,6 +228,7 @@ module HTTPX
|
|
|
228
228
|
|
|
229
229
|
def handle_error(ex, request = nil)
|
|
230
230
|
last_stream_id = Float::INFINITY
|
|
231
|
+
|
|
231
232
|
case ex
|
|
232
233
|
when OperationTimeoutError
|
|
233
234
|
if !@handshake_completed && @connection.state != :closed
|
data/lib/httpx/connection.rb
CHANGED
|
@@ -212,8 +212,8 @@ module HTTPX
|
|
|
212
212
|
@io && @io.state == :connected
|
|
213
213
|
end
|
|
214
214
|
|
|
215
|
-
def connecting?
|
|
216
|
-
|
|
215
|
+
def connecting?(state = @state)
|
|
216
|
+
state == :idle
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
# whether the connection can be removed from the selector.
|
|
@@ -487,10 +487,10 @@ module HTTPX
|
|
|
487
487
|
end
|
|
488
488
|
|
|
489
489
|
# disconnects from the current session it's attached to
|
|
490
|
-
def disconnect
|
|
491
|
-
return if @exhausted # it'll reset
|
|
490
|
+
def disconnect # rubocop:disable Naming/PredicateMethod
|
|
491
|
+
return false if @exhausted # it'll reset
|
|
492
492
|
|
|
493
|
-
return unless (current_session = @current_session) && (current_selector = @current_selector)
|
|
493
|
+
return false unless (current_session = @current_session) && (current_selector = @current_selector)
|
|
494
494
|
|
|
495
495
|
@current_session = @current_selector = nil
|
|
496
496
|
|
|
@@ -498,6 +498,7 @@ module HTTPX
|
|
|
498
498
|
# the connection is checked back into the pool, and may be checked out by
|
|
499
499
|
# another thread before the next statement.
|
|
500
500
|
current_session.deselect_connection(self, current_selector, @cloned)
|
|
501
|
+
true
|
|
501
502
|
end
|
|
502
503
|
|
|
503
504
|
def on_connect_error(e)
|
data/lib/httpx/options.rb
CHANGED
|
@@ -397,33 +397,39 @@ module HTTPX
|
|
|
397
397
|
|
|
398
398
|
private
|
|
399
399
|
|
|
400
|
+
module OptionMethodsCache
|
|
401
|
+
def option_integer(value)
|
|
402
|
+
value = Integer(value) unless value.respond_to?(:infinite?) && value.infinite?
|
|
403
|
+
raise TypeError, "`:#{__method__.to_s.delete_prefix("option_")}` must be positive" unless value.positive?
|
|
404
|
+
|
|
405
|
+
value
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def option_hash(value)
|
|
409
|
+
Hash[value]
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
def option_itself(value)
|
|
413
|
+
value
|
|
414
|
+
end
|
|
415
|
+
end.freeze
|
|
416
|
+
|
|
400
417
|
# number options
|
|
401
418
|
%i[
|
|
402
419
|
max_concurrent_requests max_requests window_size buffer_size
|
|
403
420
|
max_response_body_size max_response_headers max_response_header_value_size
|
|
404
421
|
body_threshold_size debug_level
|
|
405
422
|
].each do |option|
|
|
406
|
-
|
|
407
|
-
# converts +v+ into an Integer before setting the +#{option}+ option.
|
|
408
|
-
private def option_#{option}(value) # private def option_max_requests(v)
|
|
409
|
-
value = Integer(value) unless value.respond_to?(:infinite?) && value.infinite?
|
|
410
|
-
raise TypeError, "`:#{option}` must be positive" unless value.positive? # raise TypeError, ":max_requests must be positive" unless value.positive?
|
|
411
|
-
|
|
412
|
-
value
|
|
413
|
-
end
|
|
414
|
-
OUT
|
|
423
|
+
define_method(:"option_#{option}", OptionMethodsCache.instance_method(:option_integer))
|
|
415
424
|
end
|
|
416
425
|
|
|
417
426
|
# hashable options
|
|
418
427
|
%i[ssl http2_settings resolver_options pool_options].each do |option|
|
|
419
|
-
|
|
420
|
-
# converts +v+ into an Hash before setting the +#{option}+ option.
|
|
421
|
-
private def option_#{option}(value) # def option_ssl(v)
|
|
422
|
-
Hash[value]
|
|
423
|
-
end
|
|
424
|
-
OUT
|
|
428
|
+
define_method(:"option_#{option}", OptionMethodsCache.instance_method(:option_hash))
|
|
425
429
|
end
|
|
426
430
|
|
|
431
|
+
CACHE = Module.new
|
|
432
|
+
|
|
427
433
|
%i[
|
|
428
434
|
request_class response_class headers_class request_body_class
|
|
429
435
|
response_body_class connection_class http1_class http2_class
|
|
@@ -431,11 +437,8 @@ module HTTPX
|
|
|
431
437
|
io fallback_protocol debug debug_redact
|
|
432
438
|
compress_request_body decompress_response_body
|
|
433
439
|
persistent close_on_fork
|
|
434
|
-
].each do |
|
|
435
|
-
|
|
436
|
-
# sets +v+ as the value of the +#{method_name}+ option
|
|
437
|
-
private def option_#{method_name}(v); v; end # private def option_smth(v); v; end
|
|
438
|
-
OUT
|
|
440
|
+
].each do |option|
|
|
441
|
+
define_method(:"option_#{option}", OptionMethodsCache.instance_method(:option_itself))
|
|
439
442
|
end
|
|
440
443
|
|
|
441
444
|
def option_origin(value)
|
data/lib/httpx/plugins/cache.rb
CHANGED
|
@@ -106,7 +106,7 @@ module HTTPX
|
|
|
106
106
|
def fetch_response(request, *)
|
|
107
107
|
response = super
|
|
108
108
|
|
|
109
|
-
return
|
|
109
|
+
return response unless response.is_a?(Response)
|
|
110
110
|
|
|
111
111
|
if cacheable_request?(request) && cacheable_response?(request, response) && !response.cached?
|
|
112
112
|
log { "caching response for #{request.uri}..." }
|
|
@@ -70,12 +70,12 @@ module HTTPX
|
|
|
70
70
|
connection.on(:open) do
|
|
71
71
|
next unless connection.current_session == self
|
|
72
72
|
|
|
73
|
-
emit_or_callback_error(:connection_opened, connection.origin, connection.io.socket)
|
|
73
|
+
emit_or_callback_error(:connection_opened, connection.origin, connection.io.socket, connection: connection)
|
|
74
74
|
end
|
|
75
|
-
connection.on(:callback_connection_closed) do
|
|
76
|
-
next unless
|
|
75
|
+
connection.on(:callback_connection_closed) do |previous_session, error|
|
|
76
|
+
next unless previous_session == self
|
|
77
77
|
|
|
78
|
-
emit_or_callback_error(:connection_closed, connection.origin) if connection.used?
|
|
78
|
+
emit_or_callback_error(:connection_closed, connection.origin, error, connection: connection) if connection.used?
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
connection
|
|
@@ -85,32 +85,35 @@ module HTTPX
|
|
|
85
85
|
super
|
|
86
86
|
|
|
87
87
|
request.on(:headers) do
|
|
88
|
-
emit_or_callback_error(:request_started, request)
|
|
88
|
+
emit_or_callback_error(:request_started, request, connection: request.connection)
|
|
89
89
|
end
|
|
90
90
|
request.on(:body_chunk) do |chunk|
|
|
91
|
-
emit_or_callback_error(:request_body_chunk, request, chunk)
|
|
91
|
+
emit_or_callback_error(:request_body_chunk, request, chunk, connection: request.connection)
|
|
92
92
|
end
|
|
93
93
|
request.on(:done) do
|
|
94
|
-
emit_or_callback_error(:request_completed, request)
|
|
94
|
+
emit_or_callback_error(:request_completed, request, connection: request.connection)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
request.on(:response_started) do |res|
|
|
98
|
+
# .last_connection happens when an error happens before the request is prepared to be sent,
|
|
99
|
+
# i.e. when connecting fails.
|
|
100
|
+
connection = request.connection || request.last_connection
|
|
98
101
|
if res.is_a?(Response)
|
|
99
|
-
emit_or_callback_error(:response_started, request, res)
|
|
102
|
+
emit_or_callback_error(:response_started, request, res, connection: connection)
|
|
100
103
|
res.on(:chunk_received) do |chunk|
|
|
101
|
-
emit_or_callback_error(:response_body_chunk, request, res, chunk)
|
|
104
|
+
emit_or_callback_error(:response_body_chunk, request, res, chunk, connection: connection)
|
|
102
105
|
end
|
|
103
106
|
else
|
|
104
|
-
emit_or_callback_error(:request_error, request, res.error)
|
|
107
|
+
emit_or_callback_error(:request_error, request, res.error, connection: connection)
|
|
105
108
|
end
|
|
106
109
|
end
|
|
107
|
-
request.on(:
|
|
108
|
-
emit_or_callback_error(:response_completed, request, res
|
|
110
|
+
request.on(:response_completed) do |res|
|
|
111
|
+
emit_or_callback_error(:response_completed, request, res, connection: request.connection)
|
|
109
112
|
end
|
|
110
113
|
end
|
|
111
114
|
|
|
112
|
-
def emit_or_callback_error(
|
|
113
|
-
emit(
|
|
115
|
+
def emit_or_callback_error(...)
|
|
116
|
+
emit(...)
|
|
114
117
|
rescue StandardError => e
|
|
115
118
|
ex = CallbackError.new(e.message)
|
|
116
119
|
ex.set_backtrace(e.backtrace)
|
|
@@ -125,6 +128,12 @@ module HTTPX
|
|
|
125
128
|
end
|
|
126
129
|
|
|
127
130
|
module RequestMethods
|
|
131
|
+
# allows getting the connection that the request was sent over
|
|
132
|
+
attr_reader :connection
|
|
133
|
+
|
|
134
|
+
# gets the failed connection the request was supposed to be sent over
|
|
135
|
+
attr_accessor :last_connection
|
|
136
|
+
|
|
128
137
|
def drain_body
|
|
129
138
|
super.tap do |chunk|
|
|
130
139
|
emit(:body_chunk, chunk) if chunk
|
|
@@ -136,17 +145,69 @@ module HTTPX
|
|
|
136
145
|
end
|
|
137
146
|
end
|
|
138
147
|
|
|
148
|
+
module ResponseMethods
|
|
149
|
+
def finish!
|
|
150
|
+
# emit before connection is unassigned
|
|
151
|
+
@request.emit(:response_completed, self)
|
|
152
|
+
|
|
153
|
+
super
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
139
157
|
module ConnectionMethods
|
|
158
|
+
def initialize(*)
|
|
159
|
+
super
|
|
160
|
+
@last_error = nil
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def on_connect_error(e)
|
|
164
|
+
with_last_error(e) do
|
|
165
|
+
super
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def on_error(e, request = nil)
|
|
170
|
+
with_current_connection(request) do
|
|
171
|
+
with_last_error(e) do
|
|
172
|
+
super
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
140
177
|
private
|
|
141
178
|
|
|
142
|
-
def
|
|
143
|
-
|
|
179
|
+
def on_parser_error(request, _)
|
|
180
|
+
with_current_connection(request) do
|
|
181
|
+
super
|
|
182
|
+
end
|
|
183
|
+
end
|
|
144
184
|
|
|
145
|
-
|
|
185
|
+
def with_current_connection(request)
|
|
186
|
+
return yield unless request
|
|
187
|
+
|
|
188
|
+
begin
|
|
189
|
+
prev_conn = request.connection
|
|
190
|
+
request.connection = self
|
|
191
|
+
request.last_connection = self
|
|
192
|
+
yield
|
|
193
|
+
ensure
|
|
194
|
+
request.connection = prev_conn if request.connection == self
|
|
195
|
+
request.last_connection = nil
|
|
196
|
+
end
|
|
197
|
+
end
|
|
146
198
|
|
|
147
|
-
|
|
199
|
+
def with_last_error(e)
|
|
200
|
+
@last_error = e
|
|
201
|
+
yield
|
|
202
|
+
ensure
|
|
203
|
+
@last_error = nil if @last_error == e
|
|
204
|
+
end
|
|
148
205
|
|
|
149
|
-
|
|
206
|
+
def disconnect
|
|
207
|
+
session = @current_session
|
|
208
|
+
super.tap do |was_closed|
|
|
209
|
+
emit(:callback_connection_closed, session, @last_error) if was_closed
|
|
210
|
+
end
|
|
150
211
|
end
|
|
151
212
|
end
|
|
152
213
|
end
|
|
@@ -67,7 +67,15 @@ module HTTPX
|
|
|
67
67
|
|
|
68
68
|
# whether the error can be safely retried without booking threshold attempts.
|
|
69
69
|
def safe_reconnectable_error?(error)
|
|
70
|
-
|
|
70
|
+
case error
|
|
71
|
+
when Connection::HTTP2::GoawayError
|
|
72
|
+
# recurring GOAWAY which never accepts streams should escalate error
|
|
73
|
+
!error.unrecoverable?
|
|
74
|
+
when *SAFE_REONNECTABLE_ERRORS
|
|
75
|
+
true
|
|
76
|
+
else
|
|
77
|
+
false
|
|
78
|
+
end
|
|
71
79
|
end
|
|
72
80
|
|
|
73
81
|
def can_reconnect?(_, response)
|
|
@@ -132,6 +132,7 @@ module HTTPX
|
|
|
132
132
|
@tunnel_parser = @parser = parser =
|
|
133
133
|
parser_type(@io.protocol).new(@write_buffer, @pending, @options.merge(max_concurrent_requests: 1))
|
|
134
134
|
parser.extend(ProxyParser)
|
|
135
|
+
parser.on(:request_accepted, &method(:set_request_timeouts))
|
|
135
136
|
parser.on(:response, &method(:__http_on_connect))
|
|
136
137
|
parser.on(:close) do
|
|
137
138
|
next unless @parser
|
|
@@ -52,8 +52,8 @@ module HTTPX
|
|
|
52
52
|
|
|
53
53
|
private
|
|
54
54
|
|
|
55
|
-
def proxy_connecting?
|
|
56
|
-
super ||
|
|
55
|
+
def proxy_connecting?(state = @state)
|
|
56
|
+
super || state == :authenticating || state == :negotiating
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def handle_transition(nextstate)
|
data/lib/httpx/plugins/proxy.rb
CHANGED
|
@@ -284,10 +284,10 @@ module HTTPX
|
|
|
284
284
|
@proxy_uri || super
|
|
285
285
|
end
|
|
286
286
|
|
|
287
|
-
def connecting?
|
|
287
|
+
def connecting?(*args)
|
|
288
288
|
return super unless @options.proxy
|
|
289
289
|
|
|
290
|
-
super || proxy_connecting?
|
|
290
|
+
super || proxy_connecting?(*args)
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
def call
|
|
@@ -317,8 +317,8 @@ module HTTPX
|
|
|
317
317
|
"tcp"
|
|
318
318
|
end
|
|
319
319
|
|
|
320
|
-
def proxy_connecting?
|
|
321
|
-
|
|
320
|
+
def proxy_connecting?(state = @state)
|
|
321
|
+
%i[connecting connected].include?(state)
|
|
322
322
|
end
|
|
323
323
|
|
|
324
324
|
def connect
|
|
@@ -171,14 +171,12 @@ module HTTPX::Plugins
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
def disconnect
|
|
174
|
-
|
|
174
|
+
prevstate = @state
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
super
|
|
176
|
+
super.tap do |was_closed|
|
|
177
|
+
# reset init time of connections abandoned while connecting.
|
|
178
|
+
@init_time = nil if was_closed && connecting?(prevstate)
|
|
179
|
+
end
|
|
182
180
|
end
|
|
183
181
|
|
|
184
182
|
private
|
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)
|
data/lib/httpx/version.rb
CHANGED
data/sig/connection.rbs
CHANGED
|
@@ -82,7 +82,7 @@ module HTTPX
|
|
|
82
82
|
|
|
83
83
|
def purge_pending: () { (Request request) -> void } -> void
|
|
84
84
|
|
|
85
|
-
def connecting?: () -> bool
|
|
85
|
+
def connecting?: (?Symbol state) -> bool
|
|
86
86
|
|
|
87
87
|
def current_context?: () -> bool
|
|
88
88
|
|
|
@@ -126,7 +126,7 @@ module HTTPX
|
|
|
126
126
|
|
|
127
127
|
def handle_connect_error: (StandardError error) -> void
|
|
128
128
|
|
|
129
|
-
def disconnect: () ->
|
|
129
|
+
def disconnect: () -> bool
|
|
130
130
|
|
|
131
131
|
def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
|
|
132
132
|
|
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/proxy.rbs
CHANGED
data/sig/session.rbs
CHANGED
|
@@ -74,8 +74,6 @@ module HTTPX
|
|
|
74
74
|
|
|
75
75
|
def on_resolver_close: (Resolver::Resolver resolver, Selector selector) -> void
|
|
76
76
|
|
|
77
|
-
def find_resolver_for: (Connection connection, Selector selector) -> resolver
|
|
78
|
-
|
|
79
77
|
def coalesce_connections: (Connection conn1, Connection conn2, Selector selector, bool from_pool) -> void
|
|
80
78
|
|
|
81
79
|
def get_current_selector: () -> Selector?
|
|
@@ -103,4 +101,4 @@ module HTTPX
|
|
|
103
101
|
end
|
|
104
102
|
|
|
105
103
|
S: singleton(Session)
|
|
106
|
-
end
|
|
104
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: httpx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tiago Cardoso
|
|
@@ -175,6 +175,7 @@ extra_rdoc_files:
|
|
|
175
175
|
- doc/release_notes/1_8_4.md
|
|
176
176
|
- doc/release_notes/1_9_0.md
|
|
177
177
|
- doc/release_notes/1_9_1.md
|
|
178
|
+
- doc/release_notes/1_9_2.md
|
|
178
179
|
files:
|
|
179
180
|
- LICENSE.txt
|
|
180
181
|
- README.md
|
|
@@ -322,6 +323,7 @@ files:
|
|
|
322
323
|
- doc/release_notes/1_8_4.md
|
|
323
324
|
- doc/release_notes/1_9_0.md
|
|
324
325
|
- doc/release_notes/1_9_1.md
|
|
326
|
+
- doc/release_notes/1_9_2.md
|
|
325
327
|
- lib/httpx.rb
|
|
326
328
|
- lib/httpx/adapters/datadog.rb
|
|
327
329
|
- lib/httpx/adapters/faraday.rb
|