httpx 1.4.0 → 1.4.4
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/README.md +1 -2
- data/doc/release_notes/1_4_1.md +19 -0
- data/doc/release_notes/1_4_2.md +20 -0
- data/doc/release_notes/1_4_3.md +11 -0
- data/doc/release_notes/1_4_4.md +14 -0
- data/lib/httpx/adapters/datadog.rb +55 -83
- data/lib/httpx/adapters/faraday.rb +1 -1
- data/lib/httpx/adapters/webmock.rb +11 -1
- data/lib/httpx/callbacks.rb +2 -2
- data/lib/httpx/connection/http2.rb +33 -18
- data/lib/httpx/connection.rb +115 -55
- data/lib/httpx/errors.rb +3 -4
- data/lib/httpx/io/ssl.rb +6 -3
- data/lib/httpx/loggable.rb +13 -6
- data/lib/httpx/plugins/callbacks.rb +1 -0
- data/lib/httpx/plugins/circuit_breaker.rb +1 -0
- data/lib/httpx/plugins/expect.rb +1 -1
- data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -0
- data/lib/httpx/plugins/internal_telemetry.rb +21 -1
- data/lib/httpx/plugins/retries.rb +2 -2
- data/lib/httpx/plugins/stream.rb +42 -18
- data/lib/httpx/request/body.rb +9 -14
- data/lib/httpx/request.rb +37 -3
- data/lib/httpx/resolver/https.rb +4 -2
- data/lib/httpx/resolver/native.rb +111 -55
- data/lib/httpx/resolver/resolver.rb +18 -11
- data/lib/httpx/resolver/system.rb +3 -5
- data/lib/httpx/response.rb +9 -4
- data/lib/httpx/selector.rb +33 -23
- data/lib/httpx/session.rb +20 -49
- data/lib/httpx/timers.rb +16 -1
- data/lib/httpx/transcoder/body.rb +15 -31
- data/lib/httpx/transcoder/multipart/encoder.rb +2 -1
- data/lib/httpx/transcoder/multipart/part.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +1 -1
- data/sig/callbacks.rbs +2 -2
- data/sig/connection/http2.rbs +4 -0
- data/sig/connection.rbs +19 -5
- data/sig/errors.rbs +3 -3
- data/sig/loggable.rbs +2 -2
- data/sig/plugins/stream.rbs +3 -0
- data/sig/pool.rbs +2 -0
- data/sig/request/body.rbs +0 -8
- data/sig/request.rbs +12 -0
- data/sig/resolver/native.rbs +6 -1
- data/sig/response.rbs +8 -3
- data/sig/selector.rbs +1 -0
- data/sig/session.rbs +2 -0
- data/sig/timers.rbs +15 -4
- data/sig/transcoder/body.rbs +1 -3
- data/sig/transcoder/json.rbs +1 -1
- data/sig/transcoder/multipart.rbs +1 -1
- data/sig/transcoder/utils/body_reader.rbs +1 -1
- data/sig/transcoder/utils/deflater.rbs +1 -2
- metadata +11 -9
- data/lib/httpx/session2.rb +0 -23
- data/lib/httpx/transcoder/utils/inflater.rb +0 -21
- data/sig/transcoder/utils/inflater.rbs +0 -12
data/lib/httpx/session.rb
CHANGED
@@ -69,8 +69,6 @@ module HTTPX
|
|
69
69
|
while (connection = @pool.pop_connection)
|
70
70
|
next if connection.state == :closed
|
71
71
|
|
72
|
-
connection.current_session = self
|
73
|
-
connection.current_selector = selector
|
74
72
|
select_connection(connection, selector)
|
75
73
|
end
|
76
74
|
begin
|
@@ -126,9 +124,15 @@ module HTTPX
|
|
126
124
|
end
|
127
125
|
|
128
126
|
def select_connection(connection, selector)
|
127
|
+
pin_connection(connection, selector)
|
129
128
|
selector.register(connection)
|
130
129
|
end
|
131
130
|
|
131
|
+
def pin_connection(connection, selector)
|
132
|
+
connection.current_session = self
|
133
|
+
connection.current_selector = selector
|
134
|
+
end
|
135
|
+
|
132
136
|
alias_method :select_resolver, :select_connection
|
133
137
|
|
134
138
|
def deselect_connection(connection, selector, cloned = false)
|
@@ -160,36 +164,8 @@ module HTTPX
|
|
160
164
|
new_connection = connection.class.new(connection.origin, connection.options)
|
161
165
|
|
162
166
|
new_connection.family = family
|
163
|
-
new_connection.current_session = self
|
164
|
-
new_connection.current_selector = selector
|
165
|
-
|
166
|
-
connection.once(:tcp_open) { new_connection.force_reset(true) }
|
167
|
-
connection.once(:connect_error) do |err|
|
168
|
-
if new_connection.connecting?
|
169
|
-
new_connection.merge(connection)
|
170
|
-
connection.emit(:cloned, new_connection)
|
171
|
-
connection.force_reset(true)
|
172
|
-
else
|
173
|
-
connection.__send__(:handle_error, err)
|
174
|
-
end
|
175
|
-
end
|
176
167
|
|
177
|
-
|
178
|
-
if new_conn != connection
|
179
|
-
new_conn.merge(connection)
|
180
|
-
connection.force_reset(true)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
new_connection.once(:connect_error) do |err|
|
184
|
-
if connection.connecting?
|
185
|
-
# main connection has the requests
|
186
|
-
connection.merge(new_connection)
|
187
|
-
new_connection.emit(:cloned, connection)
|
188
|
-
new_connection.force_reset(true)
|
189
|
-
else
|
190
|
-
new_connection.__send__(:handle_error, err)
|
191
|
-
end
|
192
|
-
end
|
168
|
+
connection.sibling = new_connection
|
193
169
|
|
194
170
|
do_init_connection(new_connection, selector)
|
195
171
|
new_connection
|
@@ -203,22 +179,20 @@ module HTTPX
|
|
203
179
|
|
204
180
|
connection = @pool.checkout_connection(request_uri, options)
|
205
181
|
|
206
|
-
connection.current_session = self
|
207
|
-
connection.current_selector = selector
|
208
|
-
|
209
182
|
case connection.state
|
210
183
|
when :idle
|
211
184
|
do_init_connection(connection, selector)
|
212
185
|
when :open
|
213
|
-
|
214
|
-
when :closed
|
215
|
-
connection.idling
|
216
|
-
select_connection(connection, selector)
|
217
|
-
when :closing
|
218
|
-
connection.once(:close) do
|
219
|
-
connection.idling
|
186
|
+
if options.io
|
220
187
|
select_connection(connection, selector)
|
188
|
+
else
|
189
|
+
pin_connection(connection, selector)
|
221
190
|
end
|
191
|
+
when :closing, :closed
|
192
|
+
connection.idling
|
193
|
+
select_connection(connection, selector)
|
194
|
+
else
|
195
|
+
pin_connection(connection, selector)
|
222
196
|
end
|
223
197
|
|
224
198
|
connection
|
@@ -261,11 +235,9 @@ module HTTPX
|
|
261
235
|
end
|
262
236
|
return unless error && error.is_a?(Exception)
|
263
237
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
raise error if selector.empty?
|
268
|
-
end
|
238
|
+
raise error unless error.is_a?(Error)
|
239
|
+
|
240
|
+
request.emit(:response, ErrorResponse.new(request, error))
|
269
241
|
end
|
270
242
|
|
271
243
|
# returns a set of HTTPX::Request objects built from the given +args+ and +options+.
|
@@ -372,7 +344,6 @@ module HTTPX
|
|
372
344
|
# resolve a name (not the same as name being an IP, yet)
|
373
345
|
# 2. when the connection is initialized with an external already open IO.
|
374
346
|
#
|
375
|
-
connection.once(:connect_error, &connection.method(:handle_error))
|
376
347
|
on_resolver_connection(connection, selector)
|
377
348
|
return
|
378
349
|
end
|
@@ -395,6 +366,8 @@ module HTTPX
|
|
395
366
|
coalesce_connections(found_connection, connection, selector, from_pool)
|
396
367
|
else
|
397
368
|
found_connection.once(:open) do
|
369
|
+
next unless found_connection.current_session == self
|
370
|
+
|
398
371
|
coalesce_connections(found_connection, connection, selector, from_pool)
|
399
372
|
end
|
400
373
|
end
|
@@ -428,8 +401,6 @@ module HTTPX
|
|
428
401
|
return false
|
429
402
|
end
|
430
403
|
|
431
|
-
conn2.emit(:tcp_open, conn1)
|
432
|
-
conn1.merge(conn2)
|
433
404
|
conn2.coalesced_connection = conn1
|
434
405
|
select_connection(conn1, selector) if from_pool
|
435
406
|
deselect_connection(conn2, selector)
|
data/lib/httpx/timers.rb
CHANGED
@@ -26,7 +26,7 @@ module HTTPX
|
|
26
26
|
|
27
27
|
@next_interval_at = nil
|
28
28
|
|
29
|
-
interval
|
29
|
+
Timer.new(interval, callback)
|
30
30
|
end
|
31
31
|
|
32
32
|
def wait_interval
|
@@ -48,6 +48,17 @@ module HTTPX
|
|
48
48
|
@next_interval_at = nil if @intervals.empty?
|
49
49
|
end
|
50
50
|
|
51
|
+
class Timer
|
52
|
+
def initialize(interval, callback)
|
53
|
+
@interval = interval
|
54
|
+
@callback = callback
|
55
|
+
end
|
56
|
+
|
57
|
+
def cancel
|
58
|
+
@interval.delete(@callback)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
51
62
|
class Interval
|
52
63
|
include Comparable
|
53
64
|
|
@@ -63,6 +74,10 @@ module HTTPX
|
|
63
74
|
@on_empty = blk
|
64
75
|
end
|
65
76
|
|
77
|
+
def cancel
|
78
|
+
@on_empty.call
|
79
|
+
end
|
80
|
+
|
66
81
|
def <=>(other)
|
67
82
|
@interval <=> other.interval
|
68
83
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "delegate"
|
4
4
|
|
5
5
|
module HTTPX::Transcoder
|
6
6
|
module Body
|
@@ -8,48 +8,32 @@ module HTTPX::Transcoder
|
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
class Encoder
|
12
|
-
extend Forwardable
|
13
|
-
|
14
|
-
def_delegator :@raw, :to_s
|
15
|
-
|
16
|
-
def_delegator :@raw, :==
|
17
|
-
|
11
|
+
class Encoder < SimpleDelegator
|
18
12
|
def initialize(body)
|
19
|
-
|
13
|
+
body = body.open(File::RDONLY, encoding: Encoding::BINARY) if Object.const_defined?(:Pathname) && body.is_a?(Pathname)
|
14
|
+
@body = body
|
15
|
+
super(body)
|
20
16
|
end
|
21
17
|
|
22
18
|
def bytesize
|
23
|
-
if @
|
24
|
-
@
|
25
|
-
elsif @
|
26
|
-
@
|
27
|
-
elsif @
|
28
|
-
@
|
29
|
-
elsif @
|
30
|
-
@
|
31
|
-
elsif @
|
19
|
+
if @body.respond_to?(:bytesize)
|
20
|
+
@body.bytesize
|
21
|
+
elsif @body.respond_to?(:to_ary)
|
22
|
+
@body.sum(&:bytesize)
|
23
|
+
elsif @body.respond_to?(:size)
|
24
|
+
@body.size || Float::INFINITY
|
25
|
+
elsif @body.respond_to?(:length)
|
26
|
+
@body.length || Float::INFINITY
|
27
|
+
elsif @body.respond_to?(:each)
|
32
28
|
Float::INFINITY
|
33
29
|
else
|
34
|
-
raise Error, "cannot determine size of body: #{@
|
30
|
+
raise Error, "cannot determine size of body: #{@body.inspect}"
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
34
|
def content_type
|
39
35
|
"application/octet-stream"
|
40
36
|
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def respond_to_missing?(meth, *args)
|
45
|
-
@raw.respond_to?(meth, *args) || super
|
46
|
-
end
|
47
|
-
|
48
|
-
def method_missing(meth, *args, &block)
|
49
|
-
return super unless @raw.respond_to?(meth)
|
50
|
-
|
51
|
-
@raw.__send__(meth, *args, &block)
|
52
|
-
end
|
53
37
|
end
|
54
38
|
|
55
39
|
def encode(body)
|
@@ -11,6 +11,7 @@ module HTTPX
|
|
11
11
|
@buffer = "".b
|
12
12
|
|
13
13
|
@form = form
|
14
|
+
@bytesize = 0
|
14
15
|
@parts = to_parts(form)
|
15
16
|
end
|
16
17
|
|
@@ -42,6 +43,7 @@ module HTTPX
|
|
42
43
|
aux << [key, val]
|
43
44
|
end
|
44
45
|
@form = form
|
46
|
+
@bytesize = 0
|
45
47
|
@parts = to_parts(form)
|
46
48
|
@part_index = 0
|
47
49
|
end
|
@@ -49,7 +51,6 @@ module HTTPX
|
|
49
51
|
private
|
50
52
|
|
51
53
|
def to_parts(form)
|
52
|
-
@bytesize = 0
|
53
54
|
params = form.each_with_object([]) do |(key, val), aux|
|
54
55
|
Transcoder.normalize_keys(key, val, MULTIPART_VALUE_COND) do |k, v|
|
55
56
|
next if v.nil?
|
@@ -19,7 +19,7 @@ module HTTPX
|
|
19
19
|
value = value[:body]
|
20
20
|
end
|
21
21
|
|
22
|
-
value = value.open(File::RDONLY) if Object.const_defined?(:Pathname) && value.is_a?(Pathname)
|
22
|
+
value = value.open(File::RDONLY, encoding: Encoding::BINARY) if Object.const_defined?(:Pathname) && value.is_a?(Pathname)
|
23
23
|
|
24
24
|
if value.respond_to?(:path) && value.respond_to?(:read)
|
25
25
|
# either a File, a Tempfile, or something else which has to quack like a file
|
data/lib/httpx/version.rb
CHANGED
data/lib/httpx.rb
CHANGED
@@ -61,6 +61,6 @@ require "httpx/session_extensions"
|
|
61
61
|
|
62
62
|
# load integrations when possible
|
63
63
|
|
64
|
-
require "httpx/adapters/datadog" if defined?(DDTrace) || defined?(Datadog)
|
64
|
+
require "httpx/adapters/datadog" if defined?(DDTrace) || defined?(Datadog::Tracing)
|
65
65
|
require "httpx/adapters/sentry" if defined?(Sentry)
|
66
66
|
require "httpx/adapters/webmock" if defined?(WebMock)
|
data/sig/callbacks.rbs
CHANGED
@@ -4,8 +4,8 @@ module HTTPX
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module Callbacks
|
7
|
-
def on: (Symbol) { (*untyped) -> void } ->
|
8
|
-
def once: (Symbol) { (*untyped) -> void } ->
|
7
|
+
def on: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
|
8
|
+
def once: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
|
9
9
|
def emit: (Symbol, *untyped) -> void
|
10
10
|
|
11
11
|
def callbacks_for?: (Symbol) -> bool
|
data/sig/connection/http2.rbs
CHANGED
@@ -8,6 +8,7 @@ module HTTPX
|
|
8
8
|
attr_reader streams: Hash[Request, ::HTTP2::Stream]
|
9
9
|
attr_reader pending: Array[Request]
|
10
10
|
|
11
|
+
@connection: HTTP2::Client
|
11
12
|
@options: Options
|
12
13
|
@settings: Hash[Symbol, Integer | bool]
|
13
14
|
@max_concurrent_requests: Integer
|
@@ -95,5 +96,8 @@ module HTTPX
|
|
95
96
|
|
96
97
|
class GoawayError < Error
|
97
98
|
end
|
99
|
+
|
100
|
+
class PingError < Error
|
101
|
+
end
|
98
102
|
end
|
99
103
|
end
|
data/sig/connection.rbs
CHANGED
@@ -26,11 +26,12 @@ module HTTPX
|
|
26
26
|
attr_reader pending: Array[Request]
|
27
27
|
attr_reader options: Options
|
28
28
|
attr_reader ssl_session: OpenSSL::SSL::Session?
|
29
|
+
attr_reader sibling: instance?
|
29
30
|
attr_writer current_selector: Selector?
|
30
|
-
attr_writer coalesced_connection: instance?
|
31
31
|
attr_accessor current_session: Session?
|
32
32
|
attr_accessor family: Integer?
|
33
33
|
|
34
|
+
|
34
35
|
@window_size: Integer
|
35
36
|
@read_buffer: Buffer
|
36
37
|
@write_buffer: Buffer
|
@@ -42,9 +43,12 @@ module HTTPX
|
|
42
43
|
@parser: Object & _Parser
|
43
44
|
@connected_at: Float
|
44
45
|
@response_received_at: Float
|
45
|
-
@intervals: Array[Timers::Interval]
|
46
46
|
@exhausted: bool
|
47
47
|
@cloned: bool
|
48
|
+
@coalesced_connection: instance?
|
49
|
+
@sibling: instance?
|
50
|
+
@main_sibling: bool
|
51
|
+
|
48
52
|
|
49
53
|
def addresses: () -> Array[ipaddr]?
|
50
54
|
|
@@ -70,6 +74,8 @@ module HTTPX
|
|
70
74
|
|
71
75
|
def connecting?: () -> bool
|
72
76
|
|
77
|
+
def io_connected?: () -> bool
|
78
|
+
|
73
79
|
def inflight?: () -> boolish
|
74
80
|
|
75
81
|
def interests: () -> io_interests?
|
@@ -98,6 +104,14 @@ module HTTPX
|
|
98
104
|
|
99
105
|
def handle_socket_timeout: (Numeric interval) -> void
|
100
106
|
|
107
|
+
def coalesced_connection=: (instance connection) -> void
|
108
|
+
|
109
|
+
def sibling=: (instance? connection) -> void
|
110
|
+
|
111
|
+
def handle_connect_error: (StandardError error) -> void
|
112
|
+
|
113
|
+
def disconnect: () -> void
|
114
|
+
|
101
115
|
private
|
102
116
|
|
103
117
|
def initialize: (http_uri uri, Options options) -> void
|
@@ -106,8 +120,6 @@ module HTTPX
|
|
106
120
|
|
107
121
|
def connect: () -> void
|
108
122
|
|
109
|
-
def disconnect: () -> void
|
110
|
-
|
111
123
|
def exhausted?: () -> boolish
|
112
124
|
|
113
125
|
def consume: () -> void
|
@@ -134,6 +146,8 @@ module HTTPX
|
|
134
146
|
|
135
147
|
def handle_error: (StandardError error, ?Request? request) -> void
|
136
148
|
|
149
|
+
def close_sibling: () -> void
|
150
|
+
|
137
151
|
def purge_after_closed: () -> void
|
138
152
|
|
139
153
|
def set_request_timeouts: (Request request) -> void
|
@@ -148,7 +162,7 @@ module HTTPX
|
|
148
162
|
|
149
163
|
def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
|
150
164
|
|
151
|
-
def set_request_timeout: (Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
|
165
|
+
def set_request_timeout: (Symbol label, Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
|
152
166
|
|
153
167
|
def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
|
154
168
|
end
|
data/sig/errors.rbs
CHANGED
@@ -45,6 +45,9 @@ module HTTPX
|
|
45
45
|
class WriteTimeoutError < RequestTimeoutError
|
46
46
|
end
|
47
47
|
|
48
|
+
class OperationTimeoutError < TimeoutError
|
49
|
+
end
|
50
|
+
|
48
51
|
class ResolveError < Error
|
49
52
|
end
|
50
53
|
|
@@ -64,7 +67,4 @@ module HTTPX
|
|
64
67
|
|
65
68
|
def initialize: (Connection connection, String hostname, ?String message) -> untyped
|
66
69
|
end
|
67
|
-
|
68
|
-
class MisdirectedRequestError < HTTPError
|
69
|
-
end
|
70
70
|
end
|
data/sig/loggable.rbs
CHANGED
@@ -8,8 +8,8 @@ module HTTPX
|
|
8
8
|
|
9
9
|
COLORS: Hash[Symbol, Integer]
|
10
10
|
|
11
|
-
def log: (?level: Integer?, ?color: Symbol?) { () -> String } -> void
|
11
|
+
def log: (?level: Integer?, ?color: Symbol?, ?debug_level: Integer, ?debug: _IOLogger?) { () -> String } -> void
|
12
12
|
|
13
|
-
def log_exception: (Exception error, ?level: Integer, ?color: Symbol) -> void
|
13
|
+
def log_exception: (Exception error, ?level: Integer, ?color: Symbol, ?debug_level: Integer, ?debug: _IOLogger?) -> void
|
14
14
|
end
|
15
15
|
end
|
data/sig/plugins/stream.rbs
CHANGED
@@ -27,7 +27,10 @@ module HTTPX
|
|
27
27
|
type streamRequest = Request & Plugins::Stream::RequestMethods
|
28
28
|
|
29
29
|
@request: streamRequest
|
30
|
+
@options: Options
|
30
31
|
@session: Plugins::sessionStream
|
32
|
+
@response_enum: Enumerator[String]?
|
33
|
+
@buffered_chunks: Array[String]
|
31
34
|
@on_chunk: ^(String) -> void | nil
|
32
35
|
|
33
36
|
def each: () { (String) -> void } -> void
|
data/sig/pool.rbs
CHANGED
data/sig/request/body.rbs
CHANGED
@@ -31,12 +31,4 @@ module HTTPX
|
|
31
31
|
|
32
32
|
def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
|
33
33
|
end
|
34
|
-
|
35
|
-
class ProcIO
|
36
|
-
@block: ^(String) -> void
|
37
|
-
|
38
|
-
def initialize: (^(String) -> void) -> untyped
|
39
|
-
|
40
|
-
def write: (String data) -> Integer
|
41
|
-
end
|
42
34
|
end
|
data/sig/request.rbs
CHANGED
@@ -14,11 +14,13 @@ module HTTPX
|
|
14
14
|
attr_reader options: Options
|
15
15
|
attr_reader response: response?
|
16
16
|
attr_reader drain_error: StandardError?
|
17
|
+
attr_reader active_timeouts: Array[Symbol]
|
17
18
|
|
18
19
|
attr_accessor peer_address: ipaddr?
|
19
20
|
|
20
21
|
attr_writer persistent: bool
|
21
22
|
|
23
|
+
@ping: bool
|
22
24
|
@query_params: Hash[interned, untyped]?
|
23
25
|
@trailers: Headers?
|
24
26
|
@informational_status: Integer?
|
@@ -27,6 +29,14 @@ module HTTPX
|
|
27
29
|
|
28
30
|
def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
|
29
31
|
|
32
|
+
def ping?: () -> bool
|
33
|
+
|
34
|
+
def ping!: () -> void
|
35
|
+
|
36
|
+
def empty?: () -> bool
|
37
|
+
|
38
|
+
def close: () -> void
|
39
|
+
|
30
40
|
def interests: () -> (:r | :w)
|
31
41
|
|
32
42
|
def merge_headers: (_Each[[String, headers_value]]) -> void
|
@@ -63,6 +73,8 @@ module HTTPX
|
|
63
73
|
|
64
74
|
def request_timeout: () -> Numeric?
|
65
75
|
|
76
|
+
def set_timeout_callback: (Symbol event) { (*untyped) -> void } -> void
|
77
|
+
|
66
78
|
private
|
67
79
|
|
68
80
|
def initialize_body: (Options options) -> Transcoder::_Encoder?
|
data/sig/resolver/native.rbs
CHANGED
@@ -21,6 +21,7 @@ module HTTPX
|
|
21
21
|
@write_buffer: Buffer
|
22
22
|
@large_packet: Buffer?
|
23
23
|
@io: UDP | TCP
|
24
|
+
@name: String?
|
24
25
|
|
25
26
|
attr_reader state: Symbol
|
26
27
|
|
@@ -42,7 +43,9 @@ module HTTPX
|
|
42
43
|
|
43
44
|
def consume: () -> void
|
44
45
|
|
45
|
-
def
|
46
|
+
def schedule_retry: () -> void
|
47
|
+
|
48
|
+
def do_retry: (String host, Connection connection, Numeric interval) -> void
|
46
49
|
|
47
50
|
def dread: (Integer) -> void
|
48
51
|
| () -> void
|
@@ -64,6 +67,8 @@ module HTTPX
|
|
64
67
|
def handle_error: (NativeResolveError | StandardError) -> void
|
65
68
|
|
66
69
|
def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
|
70
|
+
|
71
|
+
def close_or_resolve: () -> void
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
data/sig/response.rbs
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module HTTPX
|
2
2
|
interface _Response
|
3
|
+
def <<: (String data) -> void
|
4
|
+
|
3
5
|
def finished?: () -> bool
|
4
6
|
|
5
7
|
def raise_for_status: () -> self
|
@@ -23,6 +25,7 @@ module HTTPX
|
|
23
25
|
@options: Options
|
24
26
|
@request: Request
|
25
27
|
@content_type: ContentType
|
28
|
+
@finished: bool
|
26
29
|
|
27
30
|
def copy_to: (_ToPath | _Writer destination) -> void
|
28
31
|
|
@@ -38,9 +41,11 @@ module HTTPX
|
|
38
41
|
|
39
42
|
def content_type: () -> ContentType
|
40
43
|
|
44
|
+
def finish!: () -> void
|
45
|
+
|
41
46
|
def complete?: () -> bool
|
42
47
|
|
43
|
-
def json: (?
|
48
|
+
def json: (?JSON::options opts) -> untyped
|
44
49
|
|
45
50
|
def form: () -> Hash[String, untyped]
|
46
51
|
|
@@ -77,9 +82,9 @@ module HTTPX
|
|
77
82
|
@options: Options
|
78
83
|
@error: Exception
|
79
84
|
|
80
|
-
attr_reader request: Request
|
85
|
+
%a{pure} attr_reader request: Request
|
81
86
|
|
82
|
-
attr_reader response: Response?
|
87
|
+
%a{pure} attr_reader response: Response?
|
83
88
|
|
84
89
|
def status: () -> (Integer | _ToS)
|
85
90
|
|
data/sig/selector.rbs
CHANGED
data/sig/session.rbs
CHANGED
@@ -25,6 +25,8 @@ module HTTPX
|
|
25
25
|
|
26
26
|
def select_connection: (Connection connection, Selector selector) -> void
|
27
27
|
|
28
|
+
def pin_connection: (Resolver::Resolver | Connection connection, Selector selector) -> void
|
29
|
+
|
28
30
|
def deselect_connection: (Connection connection, Selector selector, ?bool cloned) -> void
|
29
31
|
|
30
32
|
def select_resolver: (Resolver::Native | Resolver::HTTPS resolver, Selector selector) -> void
|
data/sig/timers.rbs
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module HTTPX
|
2
2
|
class Timers
|
3
|
+
type callback = ^() -> void
|
4
|
+
|
3
5
|
@intervals: Array[Interval]
|
4
6
|
@next_interval_at: Float
|
5
7
|
|
6
|
-
def after: (Numeric interval_in_secs, ^() -> void) ->
|
7
|
-
| (Numeric interval_in_secs) { () -> void } ->
|
8
|
+
def after: (Numeric interval_in_secs, ^() -> void) -> Timer
|
9
|
+
| (Numeric interval_in_secs) { () -> void } -> Timer
|
8
10
|
|
9
11
|
def wait_interval: () -> Numeric?
|
10
12
|
|
@@ -15,8 +17,6 @@ module HTTPX
|
|
15
17
|
class Interval
|
16
18
|
include Comparable
|
17
19
|
|
18
|
-
type callback = ^() -> void
|
19
|
-
|
20
20
|
attr_reader interval: Numeric
|
21
21
|
|
22
22
|
@callbacks: Array[callback]
|
@@ -25,6 +25,8 @@ module HTTPX
|
|
25
25
|
|
26
26
|
def on_empty: () { () -> void } -> void
|
27
27
|
|
28
|
+
def cancel: () -> void
|
29
|
+
|
28
30
|
def to_f: () -> Float
|
29
31
|
|
30
32
|
def <<: (callback) -> void
|
@@ -41,5 +43,14 @@ module HTTPX
|
|
41
43
|
|
42
44
|
def initialize: (Numeric interval) -> void
|
43
45
|
end
|
46
|
+
|
47
|
+
class Timer
|
48
|
+
@interval: Interval
|
49
|
+
@callback: callback
|
50
|
+
|
51
|
+
def initialize: (Interval interval, callback callback) -> void
|
52
|
+
|
53
|
+
def cancel: () -> void
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
data/sig/transcoder/body.rbs
CHANGED
data/sig/transcoder/json.rbs
CHANGED
@@ -5,7 +5,7 @@ module HTTPX::Transcoder
|
|
5
5
|
def self?.encode: (_ToJson json) -> Encoder
|
6
6
|
def self?.decode: (HTTPX::Response response) -> _Decoder
|
7
7
|
|
8
|
-
def self?.json_load: (string source, ?
|
8
|
+
def self?.json_load: (string source, ?JSON::options) -> untyped
|
9
9
|
def self?.json_dump: (_ToJson obj, *untyped) -> String
|
10
10
|
|
11
11
|
class Encoder
|