httpx 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes/1_2_6.md +13 -0
- data/doc/release_notes/1_3_0.md +18 -0
- data/lib/httpx/adapters/datadog.rb +1 -1
- data/lib/httpx/adapters/faraday.rb +1 -0
- data/lib/httpx/adapters/webmock.rb +1 -1
- data/lib/httpx/connection/http1.rb +3 -2
- data/lib/httpx/connection/http2.rb +6 -6
- data/lib/httpx/connection.rb +11 -5
- data/lib/httpx/io/tcp.rb +1 -1
- data/lib/httpx/io/unix.rb +5 -3
- data/lib/httpx/options.rb +3 -7
- data/lib/httpx/parser/http1.rb +4 -0
- data/lib/httpx/plugins/aws_sigv4.rb +1 -1
- data/lib/httpx/plugins/cookies.rb +6 -6
- data/lib/httpx/plugins/follow_redirects.rb +44 -24
- data/lib/httpx/plugins/grpc.rb +3 -2
- data/lib/httpx/plugins/h2c.rb +1 -1
- data/lib/httpx/plugins/oauth.rb +1 -1
- data/lib/httpx/plugins/proxy/http.rb +2 -2
- data/lib/httpx/plugins/proxy/socks4.rb +1 -1
- data/lib/httpx/plugins/proxy/socks5.rb +1 -1
- data/lib/httpx/plugins/rate_limiter.rb +2 -0
- data/lib/httpx/plugins/ssrf_filter.rb +1 -1
- data/lib/httpx/request/body.rb +37 -41
- data/lib/httpx/request.rb +36 -10
- data/lib/httpx/resolver/https.rb +1 -1
- data/lib/httpx/resolver/native.rb +26 -8
- data/lib/httpx/resolver/resolver.rb +1 -1
- data/lib/httpx/response.rb +2 -2
- data/lib/httpx/session.rb +20 -17
- data/lib/httpx/timers.rb +1 -1
- data/lib/httpx/transcoder/multipart/encoder.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- data/sig/chainable.rbs +2 -2
- data/sig/connection/http1.rbs +2 -2
- data/sig/connection/http2.rbs +17 -17
- data/sig/connection.rbs +7 -6
- data/sig/httpx.rbs +3 -3
- data/sig/io/ssl.rbs +1 -0
- data/sig/io/tcp.rbs +1 -1
- data/sig/io/unix.rbs +18 -1
- data/sig/options.rbs +5 -14
- data/sig/parser/http1.rbs +1 -1
- data/sig/plugins/callbacks.rbs +1 -1
- data/sig/plugins/follow_redirects.rbs +10 -5
- data/sig/plugins/grpc.rbs +5 -0
- data/sig/plugins/proxy/http.rbs +3 -0
- data/sig/plugins/proxy/socks4.rbs +5 -2
- data/sig/plugins/proxy/socks5.rbs +5 -2
- data/sig/plugins/push_promise.rbs +3 -3
- data/sig/plugins/rate_limiter.rbs +1 -1
- data/sig/plugins/retries.rbs +2 -0
- data/sig/request/body.rbs +1 -3
- data/sig/request.rbs +2 -1
- data/sig/resolver/https.rbs +1 -1
- data/sig/resolver/native.rbs +2 -0
- data/sig/resolver/resolver.rbs +1 -1
- data/sig/response.rbs +1 -1
- data/sig/session.rbs +10 -7
- data/sig/transcoder/multipart.rbs +11 -6
- data/sig/transcoder/xml.rbs +1 -0
- data/sig/utils.rbs +4 -0
- metadata +10 -6
data/lib/httpx/request/body.rb
CHANGED
@@ -4,30 +4,53 @@ module HTTPX
|
|
4
4
|
# Implementation of the HTTP Request body as a delegator which iterates (responds to +each+) payload chunks.
|
5
5
|
class Request::Body < SimpleDelegator
|
6
6
|
class << self
|
7
|
-
def new(_, options)
|
8
|
-
|
7
|
+
def new(_, options, body: nil, **params)
|
8
|
+
if body.is_a?(self)
|
9
|
+
# request derives its options from body
|
10
|
+
body.options = options.merge(params)
|
11
|
+
return body
|
12
|
+
end
|
9
13
|
|
10
14
|
super
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
def initialize(headers, options)
|
16
|
-
@headers = headers
|
18
|
+
attr_accessor :options
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
# inits the instance with the request +headers+, +options+ and +params+, which contain the payload definition.
|
21
|
+
# it wraps the given body with the appropriate encoder on initialization.
|
22
|
+
#
|
23
|
+
# ..., json: { foo: "bar" }) #=> json encoder
|
24
|
+
# ..., form: { foo: "bar" }) #=> form urlencoded encoder
|
25
|
+
# ..., form: { foo: Pathname.open("path/to/file") }) #=> multipart urlencoded encoder
|
26
|
+
# ..., form: { foo: File.open("path/to/file") }) #=> multipart urlencoded encoder
|
27
|
+
# ..., form: { body: "bla") }) #=> raw data encoder
|
28
|
+
def initialize(headers, options, body: nil, form: nil, json: nil, xml: nil, **params)
|
29
|
+
@headers = headers
|
30
|
+
@options = options.merge(params)
|
31
|
+
|
32
|
+
@body = if body
|
33
|
+
Transcoder::Body.encode(body)
|
34
|
+
elsif form
|
35
|
+
Transcoder::Form.encode(form)
|
36
|
+
elsif json
|
37
|
+
Transcoder::JSON.encode(json)
|
38
|
+
elsif xml
|
39
|
+
Transcoder::Xml.encode(xml)
|
23
40
|
end
|
24
41
|
|
25
|
-
|
42
|
+
if @body
|
43
|
+
if @options.compress_request_body && @headers.key?("content-encoding")
|
26
44
|
|
27
|
-
|
45
|
+
@headers.get("content-encoding").each do |encoding|
|
46
|
+
@body = self.class.initialize_deflater_body(@body, encoding)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@headers["content-type"] ||= @body.content_type
|
51
|
+
@headers["content-length"] = @body.bytesize unless unbounded_body?
|
52
|
+
end
|
28
53
|
|
29
|
-
@headers["content-type"] ||= @body.content_type
|
30
|
-
@headers["content-length"] = @body.bytesize unless unbounded_body?
|
31
54
|
super(@body)
|
32
55
|
end
|
33
56
|
|
@@ -99,33 +122,6 @@ module HTTPX
|
|
99
122
|
end
|
100
123
|
# :nocov:
|
101
124
|
|
102
|
-
private
|
103
|
-
|
104
|
-
# wraps the given body with the appropriate encoder.
|
105
|
-
#
|
106
|
-
# ..., json: { foo: "bar" }) #=> json encoder
|
107
|
-
# ..., form: { foo: "bar" }) #=> form urlencoded encoder
|
108
|
-
# ..., form: { foo: Pathname.open("path/to/file") }) #=> multipart urlencoded encoder
|
109
|
-
# ..., form: { foo: File.open("path/to/file") }) #=> multipart urlencoded encoder
|
110
|
-
# ..., form: { body: "bla") }) #=> raw data encoder
|
111
|
-
def initialize_body(options)
|
112
|
-
@body = if options.body
|
113
|
-
Transcoder::Body.encode(options.body)
|
114
|
-
elsif options.form
|
115
|
-
Transcoder::Form.encode(options.form)
|
116
|
-
elsif options.json
|
117
|
-
Transcoder::JSON.encode(options.json)
|
118
|
-
elsif options.xml
|
119
|
-
Transcoder::Xml.encode(options.xml)
|
120
|
-
end
|
121
|
-
|
122
|
-
return unless @body && options.compress_request_body && @headers.key?("content-encoding")
|
123
|
-
|
124
|
-
@headers.get("content-encoding").each do |encoding|
|
125
|
-
@body = self.class.initialize_deflater_body(@body, encoding)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
125
|
class << self
|
130
126
|
# returns the +body+ wrapped with the correct deflater accordinng to the given +encodisng+.
|
131
127
|
def initialize_deflater_body(body, encoding)
|
data/lib/httpx/request.rb
CHANGED
@@ -46,12 +46,43 @@ module HTTPX
|
|
46
46
|
# will be +true+ when request body has been completely flushed.
|
47
47
|
def_delegator :@body, :empty?
|
48
48
|
|
49
|
-
# initializes the instance with the given +verb
|
50
|
-
#
|
51
|
-
|
49
|
+
# initializes the instance with the given +verb+ (an upppercase String, ex. 'GEt'),
|
50
|
+
# an absolute or relative +uri+ (either as String or URI::HTTP object), the
|
51
|
+
# request +options+ (instance of HTTPX::Options) and an optional Hash of +params+.
|
52
|
+
#
|
53
|
+
# Besides any of the options documented in HTTPX::Options (which would override or merge with what
|
54
|
+
# +options+ sets), it accepts also the following:
|
55
|
+
#
|
56
|
+
# :params :: hash or array of key-values which will be encoded and set in the query string of request uris.
|
57
|
+
# :body :: to be encoded in the request body payload. can be a String, an IO object (i.e. a File), or an Enumerable.
|
58
|
+
# :form :: hash of array of key-values which will be form-urlencoded- or multipart-encoded in requests body payload.
|
59
|
+
# :json :: hash of array of key-values which will be JSON-encoded in requests body payload.
|
60
|
+
# :xml :: Nokogiri XML nodes which will be encoded in requests body payload.
|
61
|
+
#
|
62
|
+
# :body, :form, :json and :xml are all mutually exclusive, i.e. only one of them gets picked up.
|
63
|
+
def initialize(verb, uri, options, params = EMPTY_HASH)
|
52
64
|
@verb = verb.to_s.upcase
|
53
|
-
@options = Options.new(options)
|
54
65
|
@uri = Utils.to_uri(uri)
|
66
|
+
|
67
|
+
@headers = options.headers.dup
|
68
|
+
merge_headers(params.delete(:headers)) if params.key?(:headers)
|
69
|
+
|
70
|
+
@headers["user-agent"] ||= USER_AGENT
|
71
|
+
@headers["accept"] ||= "*/*"
|
72
|
+
|
73
|
+
# forego compression in the Range request case
|
74
|
+
if @headers.key?("range")
|
75
|
+
@headers.delete("accept-encoding")
|
76
|
+
else
|
77
|
+
@headers["accept-encoding"] ||= options.supported_compression_formats
|
78
|
+
end
|
79
|
+
|
80
|
+
@query_params = params.delete(:params) if params.key?(:params)
|
81
|
+
|
82
|
+
@body = options.request_body_class.new(@headers, options, **params)
|
83
|
+
|
84
|
+
@options = @body.options
|
85
|
+
|
55
86
|
if @uri.relative?
|
56
87
|
origin = @options.origin
|
57
88
|
raise(Error, "invalid URI: #{@uri}") unless origin
|
@@ -61,11 +92,6 @@ module HTTPX
|
|
61
92
|
@uri = origin.merge("#{base_path}#{@uri}")
|
62
93
|
end
|
63
94
|
|
64
|
-
@headers = @options.headers.dup
|
65
|
-
@headers["user-agent"] ||= USER_AGENT
|
66
|
-
@headers["accept"] ||= "*/*"
|
67
|
-
|
68
|
-
@body = @options.request_body_class.new(@headers, @options)
|
69
95
|
@state = :idle
|
70
96
|
@response = nil
|
71
97
|
@peer_address = nil
|
@@ -172,7 +198,7 @@ module HTTPX
|
|
172
198
|
return @query if defined?(@query)
|
173
199
|
|
174
200
|
query = []
|
175
|
-
if (q = @
|
201
|
+
if (q = @query_params)
|
176
202
|
query << Transcoder::Form.encode(q)
|
177
203
|
end
|
178
204
|
query << @uri.query if @uri.query
|
data/lib/httpx/resolver/https.rb
CHANGED
@@ -219,7 +219,7 @@ module HTTPX
|
|
219
219
|
uri.query = URI.encode_www_form(params)
|
220
220
|
request = rklass.new("GET", uri, @options)
|
221
221
|
else
|
222
|
-
request = rklass.new("POST", uri, @options
|
222
|
+
request = rklass.new("POST", uri, @options, body: [payload])
|
223
223
|
request.headers["content-type"] = "application/dns-message"
|
224
224
|
end
|
225
225
|
request.headers["accept"] = "application/dns-message"
|
@@ -65,6 +65,7 @@ module HTTPX
|
|
65
65
|
if nameserver && @ns_index < nameserver.size
|
66
66
|
log { "resolver: failed resolving on nameserver #{@nameserver[@ns_index - 1]} (#{e.message})" }
|
67
67
|
transition(:idle)
|
68
|
+
@timeouts.clear
|
68
69
|
else
|
69
70
|
handle_error(e)
|
70
71
|
end
|
@@ -143,13 +144,16 @@ module HTTPX
|
|
143
144
|
|
144
145
|
if !@timeouts[host].empty?
|
145
146
|
log { "resolver: timeout after #{timeout}s, retry(#{@timeouts[host].first}) #{host}..." }
|
146
|
-
|
147
|
+
# must downgrade to tcp AND retry on same host as last
|
148
|
+
downgrade_socket
|
149
|
+
resolve(connection, h)
|
147
150
|
elsif @ns_index + 1 < @nameserver.size
|
148
151
|
# try on the next nameserver
|
149
152
|
@ns_index += 1
|
150
153
|
log { "resolver: failed resolving #{host} on nameserver #{@nameserver[@ns_index - 1]} (timeout error)" }
|
151
154
|
transition(:idle)
|
152
|
-
|
155
|
+
@timeouts.clear
|
156
|
+
resolve(connection, h)
|
153
157
|
else
|
154
158
|
|
155
159
|
@timeouts.delete(host)
|
@@ -187,10 +191,9 @@ module HTTPX
|
|
187
191
|
next unless @large_packet.full?
|
188
192
|
|
189
193
|
parse(@large_packet.to_s)
|
190
|
-
@socket_type = @resolver_options.fetch(:socket_type, :udp)
|
191
194
|
@large_packet = nil
|
192
|
-
|
193
|
-
|
195
|
+
# downgrade to udp again
|
196
|
+
downgrade_socket
|
194
197
|
return
|
195
198
|
else
|
196
199
|
size = @read_buffer[0, 2].unpack1("n")
|
@@ -304,13 +307,21 @@ module HTTPX
|
|
304
307
|
end
|
305
308
|
|
306
309
|
if address.key?("alias") # CNAME
|
310
|
+
hostname_alias = address["alias"]
|
307
311
|
# clean up intermediate queries
|
308
312
|
@timeouts.delete(name) unless connection.origin.host == name
|
309
313
|
|
310
|
-
if catch(:coalesced) { early_resolve(connection, hostname:
|
314
|
+
if catch(:coalesced) { early_resolve(connection, hostname: hostname_alias) }
|
311
315
|
@connections.delete(connection)
|
312
316
|
else
|
313
|
-
|
317
|
+
if @socket_type == :tcp
|
318
|
+
# must downgrade to udp if tcp
|
319
|
+
@socket_type = @resolver_options.fetch(:socket_type, :udp)
|
320
|
+
transition(:idle)
|
321
|
+
transition(:open)
|
322
|
+
end
|
323
|
+
log { "resolver: ALIAS #{hostname_alias} for #{name}" }
|
324
|
+
resolve(connection, hostname_alias)
|
314
325
|
return
|
315
326
|
end
|
316
327
|
else
|
@@ -386,6 +397,14 @@ module HTTPX
|
|
386
397
|
end
|
387
398
|
end
|
388
399
|
|
400
|
+
def downgrade_socket
|
401
|
+
return unless @socket_type == :tcp
|
402
|
+
|
403
|
+
@socket_type = @resolver_options.fetch(:socket_type, :udp)
|
404
|
+
transition(:idle)
|
405
|
+
transition(:open)
|
406
|
+
end
|
407
|
+
|
389
408
|
def transition(nextstate)
|
390
409
|
case nextstate
|
391
410
|
when :idle
|
@@ -393,7 +412,6 @@ module HTTPX
|
|
393
412
|
@io.close
|
394
413
|
@io = nil
|
395
414
|
end
|
396
|
-
@timeouts.clear
|
397
415
|
when :open
|
398
416
|
return unless @state == :idle
|
399
417
|
|
data/lib/httpx/response.rb
CHANGED
@@ -247,11 +247,11 @@ module HTTPX
|
|
247
247
|
# the IP address of the peer server.
|
248
248
|
def_delegator :@request, :peer_address
|
249
249
|
|
250
|
-
def initialize(request, error
|
250
|
+
def initialize(request, error)
|
251
251
|
@request = request
|
252
252
|
@response = request.response if request.response.is_a?(Response)
|
253
253
|
@error = error
|
254
|
-
@options =
|
254
|
+
@options = request.options
|
255
255
|
log_exception(@error)
|
256
256
|
end
|
257
257
|
|
data/lib/httpx/session.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module HTTPX
|
4
|
+
EMPTY_HASH = {}.freeze
|
5
|
+
|
4
6
|
# Class implementing the APIs being used publicly.
|
5
7
|
#
|
6
8
|
# HTTPX.get(..) #=> delegating to an internal HTTPX::Session object.
|
@@ -9,8 +11,6 @@ module HTTPX
|
|
9
11
|
include Loggable
|
10
12
|
include Chainable
|
11
13
|
|
12
|
-
EMPTY_HASH = {}.freeze
|
13
|
-
|
14
14
|
# initializes the session with a set of +options+, which will be shared by all
|
15
15
|
# requests sent from it.
|
16
16
|
#
|
@@ -65,10 +65,10 @@ module HTTPX
|
|
65
65
|
# resp1, resp2 = session.request(["POST", "https://server.org/a", form: { "foo" => "bar" }], ["GET", "https://server.org/b"])
|
66
66
|
# resp1, resp2 = session.request("GET", ["https://server.org/a", "https://server.org/b"], headers: { "x-api-token" => "TOKEN" })
|
67
67
|
#
|
68
|
-
def request(*args, **
|
68
|
+
def request(*args, **params)
|
69
69
|
raise ArgumentError, "must perform at least one request" if args.empty?
|
70
70
|
|
71
|
-
requests = args.first.is_a?(Request) ? args : build_requests(*args,
|
71
|
+
requests = args.first.is_a?(Request) ? args : build_requests(*args, params)
|
72
72
|
responses = send_requests(*requests)
|
73
73
|
return responses.first if responses.size == 1
|
74
74
|
|
@@ -81,10 +81,9 @@ module HTTPX
|
|
81
81
|
#
|
82
82
|
# req = session.build_request("GET", "https://server.com")
|
83
83
|
# resp = session.request(req)
|
84
|
-
def build_request(verb, uri, options =
|
85
|
-
rklass =
|
86
|
-
|
87
|
-
request = rklass.new(verb, uri, options)
|
84
|
+
def build_request(verb, uri, params = EMPTY_HASH, options = @options)
|
85
|
+
rklass = options.request_class
|
86
|
+
request = rklass.new(verb, uri, options, params)
|
88
87
|
request.persistent = @persistent
|
89
88
|
set_request_callbacks(request)
|
90
89
|
request
|
@@ -133,7 +132,7 @@ module HTTPX
|
|
133
132
|
end
|
134
133
|
return unless error.is_a?(Error)
|
135
134
|
|
136
|
-
request.emit(:response, ErrorResponse.new(request, error
|
135
|
+
request.emit(:response, ErrorResponse.new(request, error))
|
137
136
|
end
|
138
137
|
|
139
138
|
# sets the callbacks on the +connection+ required to process certain specific
|
@@ -192,22 +191,26 @@ module HTTPX
|
|
192
191
|
end
|
193
192
|
|
194
193
|
# returns a set of HTTPX::Request objects built from the given +args+ and +options+.
|
195
|
-
def build_requests(*args,
|
196
|
-
request_options = @options.merge(options)
|
197
|
-
|
194
|
+
def build_requests(*args, params)
|
198
195
|
requests = if args.size == 1
|
199
196
|
reqs = args.first
|
200
|
-
|
201
|
-
|
197
|
+
# TODO: find a way to make requests share same options object
|
198
|
+
reqs.map do |verb, uri, ps = EMPTY_HASH|
|
199
|
+
request_params = params
|
200
|
+
request_params = request_params.merge(ps) unless ps.empty?
|
201
|
+
build_request(verb, uri, request_params)
|
202
202
|
end
|
203
203
|
else
|
204
204
|
verb, uris = args
|
205
205
|
if uris.respond_to?(:each)
|
206
|
-
|
207
|
-
|
206
|
+
# TODO: find a way to make requests share same options object
|
207
|
+
uris.enum_for(:each).map do |uri, ps = EMPTY_HASH|
|
208
|
+
request_params = params
|
209
|
+
request_params = request_params.merge(ps) unless ps.empty?
|
210
|
+
build_request(verb, uri, request_params)
|
208
211
|
end
|
209
212
|
else
|
210
|
-
[build_request(verb, uris,
|
213
|
+
[build_request(verb, uris, params)]
|
211
214
|
end
|
212
215
|
end
|
213
216
|
raise ArgumentError, "wrong number of URIs (given 0, expect 1..+1)" if requests.empty?
|
data/lib/httpx/timers.rb
CHANGED
@@ -43,7 +43,7 @@ module HTTPX
|
|
43
43
|
|
44
44
|
elapsed_time = Utils.elapsed_time(@next_interval_at)
|
45
45
|
|
46
|
-
@intervals.
|
46
|
+
@intervals = @intervals.drop_while { |interval| interval.elapse(elapsed_time) <= 0 }
|
47
47
|
|
48
48
|
@next_interval_at = nil if @intervals.empty?
|
49
49
|
end
|
data/lib/httpx/version.rb
CHANGED
data/sig/chainable.rbs
CHANGED
@@ -3,8 +3,8 @@ module HTTPX
|
|
3
3
|
def request: (*Request, **untyped) -> Array[response]
|
4
4
|
| (Request, **untyped) -> response
|
5
5
|
| (verb, uri | [uri], **untyped) -> response
|
6
|
-
| (Array[[verb, uri] | [verb, uri,
|
7
|
-
| (verb, _Each[uri | [uri,
|
6
|
+
| (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
|
7
|
+
| (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
|
8
8
|
|
9
9
|
def accept: (String) -> Session
|
10
10
|
def wrap: () { (Session) -> void } -> void
|
data/sig/connection/http1.rbs
CHANGED
@@ -32,7 +32,7 @@ module HTTPX
|
|
32
32
|
|
33
33
|
def exhausted?: () -> bool
|
34
34
|
|
35
|
-
def <<: (
|
35
|
+
def <<: (string) -> void
|
36
36
|
|
37
37
|
def send: (Request) -> void
|
38
38
|
|
@@ -58,7 +58,7 @@ module HTTPX
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def initialize: (Buffer, options) -> untyped
|
61
|
+
def initialize: (Buffer buffer, Options options) -> untyped
|
62
62
|
|
63
63
|
def manage_connection: (Request request, Response response) -> void
|
64
64
|
|
data/sig/connection/http2.rbs
CHANGED
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
|
6
6
|
MAX_CONCURRENT_REQUESTS: Integer
|
7
7
|
|
8
|
-
attr_reader streams: Hash[Request,
|
8
|
+
attr_reader streams: Hash[Request, ::HTTP2::Stream]
|
9
9
|
attr_reader pending: Array[Request]
|
10
10
|
|
11
11
|
@options: Options
|
@@ -24,7 +24,7 @@ module HTTPX
|
|
24
24
|
|
25
25
|
def exhausted?: () -> bool
|
26
26
|
|
27
|
-
def <<: (
|
27
|
+
def <<: (string) -> void
|
28
28
|
|
29
29
|
def can_buffer_more_requests?: () -> bool
|
30
30
|
|
@@ -42,35 +42,35 @@ module HTTPX
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
def initialize: (Buffer, options) -> untyped
|
45
|
+
def initialize: (Buffer buffer, Options options) -> untyped
|
46
46
|
|
47
47
|
def send_pending: () -> void
|
48
48
|
|
49
49
|
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
50
50
|
|
51
|
-
def handle: (Request request,
|
51
|
+
def handle: (Request request, ::HTTP2::Stream stream) -> void
|
52
52
|
|
53
53
|
def init_connection: () -> void
|
54
54
|
|
55
|
-
def handle_stream: (
|
55
|
+
def handle_stream: (::HTTP2::Stream stream, Request request) -> void
|
56
56
|
|
57
57
|
def join_headline: (Request request) -> String
|
58
58
|
|
59
|
-
def join_headers: (
|
59
|
+
def join_headers: (::HTTP2::Stream stream, Request request) -> void
|
60
60
|
|
61
|
-
def join_trailers: (
|
61
|
+
def join_trailers: (::HTTP2::Stream stream, Request request) -> void
|
62
62
|
|
63
|
-
def join_body: (
|
63
|
+
def join_body: (::HTTP2::Stream stream, Request request) -> void
|
64
64
|
|
65
|
-
def on_stream_headers: (
|
65
|
+
def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
|
66
66
|
|
67
|
-
def on_stream_trailers: (
|
67
|
+
def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
|
68
68
|
|
69
|
-
def on_stream_data: (
|
69
|
+
def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
|
70
70
|
|
71
|
-
def on_stream_refuse: (
|
71
|
+
def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
|
72
72
|
|
73
|
-
def on_stream_close: (
|
73
|
+
def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
|
74
74
|
|
75
75
|
def on_frame: (string bytes) -> void
|
76
76
|
|
@@ -78,13 +78,13 @@ module HTTPX
|
|
78
78
|
|
79
79
|
def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
|
80
80
|
|
81
|
-
def on_frame_sent: (
|
81
|
+
def on_frame_sent: (::HTTP2::frame) -> void
|
82
82
|
|
83
|
-
def on_frame_received: (
|
83
|
+
def on_frame_received: (::HTTP2::frame) -> void
|
84
84
|
|
85
|
-
def on_altsvc: (String origin,
|
85
|
+
def on_altsvc: (String origin, ::HTTP2::frame) -> void
|
86
86
|
|
87
|
-
def on_promise: (
|
87
|
+
def on_promise: (::HTTP2::Stream) -> void
|
88
88
|
|
89
89
|
def on_origin: (String) -> void
|
90
90
|
|
data/sig/connection.rbs
CHANGED
@@ -20,11 +20,12 @@ module HTTPX
|
|
20
20
|
|
21
21
|
|
22
22
|
attr_reader type: io_type
|
23
|
-
attr_reader origin:
|
23
|
+
attr_reader origin: http_uri
|
24
24
|
attr_reader origins: Array[String]
|
25
25
|
attr_reader state: Symbol
|
26
26
|
attr_reader pending: Array[Request]
|
27
27
|
attr_reader options: Options
|
28
|
+
attr_reader ssl_session: OpenSSL::SSL::Session?
|
28
29
|
attr_writer timers: Timers
|
29
30
|
|
30
31
|
attr_accessor family: Integer?
|
@@ -37,7 +38,7 @@ module HTTPX
|
|
37
38
|
@timeout: Numeric?
|
38
39
|
@current_timeout: Numeric?
|
39
40
|
@io: TCP | SSL | UNIX
|
40
|
-
@parser:
|
41
|
+
@parser: Object & _Parser
|
41
42
|
@connected_at: Float
|
42
43
|
@response_received_at: Float
|
43
44
|
@intervals: Array[Timers::Interval]
|
@@ -92,9 +93,9 @@ module HTTPX
|
|
92
93
|
|
93
94
|
private
|
94
95
|
|
95
|
-
def initialize: (
|
96
|
+
def initialize: (http_uri uri, Options options) -> void
|
96
97
|
|
97
|
-
def initialize_type: (
|
98
|
+
def initialize_type: (http_uri uri, Options options) -> io_type
|
98
99
|
|
99
100
|
def connect: () -> void
|
100
101
|
|
@@ -104,11 +105,11 @@ module HTTPX
|
|
104
105
|
|
105
106
|
def send_pending: () -> void
|
106
107
|
|
107
|
-
def parser: () -> (
|
108
|
+
def parser: () -> (Object & _Parser)
|
108
109
|
|
109
110
|
def send_request_to_parser: (Request request) -> void
|
110
111
|
|
111
|
-
def build_parser: (?String protocol) -> (
|
112
|
+
def build_parser: (?String protocol) -> (Object & _Parser)
|
112
113
|
|
113
114
|
def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
|
114
115
|
|
data/sig/httpx.rbs
CHANGED
@@ -9,9 +9,9 @@ module HTTPX
|
|
9
9
|
type uri = http_uri | string
|
10
10
|
type generic_uri = String | URI::Generic
|
11
11
|
|
12
|
-
type verb =
|
13
|
-
|
14
|
-
|
12
|
+
type verb = String
|
13
|
+
|
14
|
+
type request_params = Hash[Symbol, untyped]
|
15
15
|
|
16
16
|
type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
|
17
17
|
|
data/sig/io/ssl.rbs
CHANGED
@@ -14,6 +14,7 @@ module HTTPX
|
|
14
14
|
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
15
15
|
# def initialize: (URI::Generic origin, Array[ipaddr]? addresses, options options) ?{ (self) -> void } -> void
|
16
16
|
|
17
|
+
def session_new_cb: { (OpenSSL::SSL::Session sess) -> void } -> void
|
17
18
|
def can_verify_peer?: () -> bool
|
18
19
|
|
19
20
|
def verify_hostname: (String host) -> bool
|
data/sig/io/tcp.rbs
CHANGED
@@ -15,7 +15,7 @@ module HTTPX
|
|
15
15
|
alias host ip
|
16
16
|
|
17
17
|
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
18
|
-
def initialize: (URI::Generic origin, Array[ipaddr]? addresses,
|
18
|
+
def initialize: (URI::Generic origin, Array[ipaddr]? addresses, Options options) ?{ (instance) -> void } -> void
|
19
19
|
|
20
20
|
def add_addresses: (Array[ipaddr] addrs) -> void
|
21
21
|
|
data/sig/io/unix.rbs
CHANGED
@@ -5,6 +5,23 @@ module HTTPX
|
|
5
5
|
|
6
6
|
alias host path
|
7
7
|
|
8
|
-
|
8
|
+
@hostname: String
|
9
|
+
|
10
|
+
@options: Options
|
11
|
+
|
12
|
+
@fallback_protocol: String
|
13
|
+
|
14
|
+
@keep_open: bool
|
15
|
+
|
16
|
+
@io: Socket
|
17
|
+
|
18
|
+
def initialize: (http_uri origin, String? path, Options options) -> void
|
19
|
+
|
20
|
+
def connect: () -> void
|
21
|
+
|
22
|
+
def expired?: () -> bool
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_socket: () -> Socket
|
9
26
|
end
|
10
27
|
end
|
data/sig/options.rbs
CHANGED
@@ -6,6 +6,9 @@ module HTTPX
|
|
6
6
|
WINDOW_SIZE: Integer
|
7
7
|
MAX_BODY_THRESHOLD_SIZE: Integer
|
8
8
|
CONNECT_TIMEOUT: Integer
|
9
|
+
READ_TIMEOUT: Integer
|
10
|
+
WRITE_TIMEOUT: Integer
|
11
|
+
REQUEST_TIMEOUT: Integer
|
9
12
|
OPERATION_TIMEOUT: Integer
|
10
13
|
KEEP_ALIVE_TIMEOUT: Integer
|
11
14
|
SETTINGS_TIMEOUT: Integer
|
@@ -46,7 +49,7 @@ module HTTPX
|
|
46
49
|
attr_reader body_threshold_size: Integer
|
47
50
|
|
48
51
|
# transport
|
49
|
-
attr_reader transport:
|
52
|
+
attr_reader transport: io_type | nil
|
50
53
|
|
51
54
|
# addresses
|
52
55
|
attr_reader addresses: Array[ipaddr]?
|
@@ -60,19 +63,7 @@ module HTTPX
|
|
60
63
|
# decompress_response_body
|
61
64
|
attr_reader decompress_response_body: bool
|
62
65
|
|
63
|
-
#
|
64
|
-
attr_reader params: Transcoder::urlencoded_input?
|
65
|
-
|
66
|
-
# form
|
67
|
-
attr_reader form: Transcoder::urlencoded_input?
|
68
|
-
|
69
|
-
# json
|
70
|
-
attr_reader json: _ToJson?
|
71
|
-
|
72
|
-
# body
|
73
|
-
attr_reader body: bodyIO?
|
74
|
-
|
75
|
-
# body
|
66
|
+
# origin
|
76
67
|
attr_reader origin: URI::Generic?
|
77
68
|
|
78
69
|
# base_path
|