httpx 1.2.6 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_3_0.md +18 -0
  3. data/doc/release_notes/1_3_1.md +17 -0
  4. data/lib/httpx/adapters/datadog.rb +8 -4
  5. data/lib/httpx/adapters/faraday.rb +2 -1
  6. data/lib/httpx/adapters/webmock.rb +1 -1
  7. data/lib/httpx/connection/http1.rb +11 -7
  8. data/lib/httpx/connection/http2.rb +15 -11
  9. data/lib/httpx/connection.rb +51 -24
  10. data/lib/httpx/io/tcp.rb +1 -1
  11. data/lib/httpx/io/unix.rb +1 -1
  12. data/lib/httpx/options.rb +4 -7
  13. data/lib/httpx/plugins/aws_sdk_authentication.rb +3 -0
  14. data/lib/httpx/plugins/aws_sigv4.rb +5 -1
  15. data/lib/httpx/plugins/circuit_breaker.rb +10 -0
  16. data/lib/httpx/plugins/cookies.rb +9 -6
  17. data/lib/httpx/plugins/digest_auth.rb +3 -0
  18. data/lib/httpx/plugins/expect.rb +5 -0
  19. data/lib/httpx/plugins/follow_redirects.rb +65 -29
  20. data/lib/httpx/plugins/grpc.rb +2 -2
  21. data/lib/httpx/plugins/h2c.rb +1 -1
  22. data/lib/httpx/plugins/oauth.rb +1 -1
  23. data/lib/httpx/plugins/proxy/http.rb +9 -4
  24. data/lib/httpx/plugins/proxy/socks4.rb +1 -1
  25. data/lib/httpx/plugins/proxy/socks5.rb +1 -1
  26. data/lib/httpx/plugins/proxy.rb +24 -13
  27. data/lib/httpx/plugins/retries.rb +25 -4
  28. data/lib/httpx/plugins/ssrf_filter.rb +4 -1
  29. data/lib/httpx/pool/synch_pool.rb +93 -0
  30. data/lib/httpx/pool.rb +1 -1
  31. data/lib/httpx/request/body.rb +37 -41
  32. data/lib/httpx/request.rb +42 -13
  33. data/lib/httpx/resolver/https.rb +7 -5
  34. data/lib/httpx/resolver/native.rb +1 -1
  35. data/lib/httpx/resolver/resolver.rb +1 -1
  36. data/lib/httpx/resolver/system.rb +1 -1
  37. data/lib/httpx/response.rb +2 -2
  38. data/lib/httpx/session.rb +34 -19
  39. data/lib/httpx/timers.rb +1 -1
  40. data/lib/httpx/version.rb +1 -1
  41. data/sig/chainable.rbs +2 -2
  42. data/sig/connection/http1.rbs +2 -2
  43. data/sig/connection/http2.rbs +17 -17
  44. data/sig/connection.rbs +10 -4
  45. data/sig/httpx.rbs +3 -3
  46. data/sig/io/tcp.rbs +1 -1
  47. data/sig/io/unix.rbs +1 -1
  48. data/sig/options.rbs +1 -13
  49. data/sig/plugins/follow_redirects.rbs +1 -1
  50. data/sig/plugins/proxy/http.rbs +3 -0
  51. data/sig/plugins/proxy.rbs +2 -0
  52. data/sig/plugins/push_promise.rbs +3 -3
  53. data/sig/pool.rbs +1 -1
  54. data/sig/request/body.rbs +1 -3
  55. data/sig/request.rbs +2 -1
  56. data/sig/resolver/resolver.rbs +2 -2
  57. data/sig/response.rbs +1 -1
  58. data/sig/session.rbs +11 -6
  59. metadata +11 -6
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+, an absolute or relative +uri+, and the
50
- # request options.
51
- def initialize(verb, uri, options = {})
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,28 +92,23 @@ 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
72
98
  @persistent = @options.persistent
73
99
  end
74
100
 
75
- # the read timeout defied for this requet.
101
+ # the read timeout defined for this requet.
76
102
  def read_timeout
77
103
  @options.timeout[:read_timeout]
78
104
  end
79
105
 
80
- # the write timeout defied for this requet.
106
+ # the write timeout defined for this requet.
81
107
  def write_timeout
82
108
  @options.timeout[:write_timeout]
83
109
  end
84
110
 
85
- # the request timeout defied for this requet.
111
+ # the request timeout defined for this requet.
86
112
  def request_timeout
87
113
  @options.timeout[:request_timeout]
88
114
  end
@@ -91,10 +117,12 @@ module HTTPX
91
117
  @persistent
92
118
  end
93
119
 
120
+ # if the request contains trailer headers
94
121
  def trailers?
95
122
  defined?(@trailers)
96
123
  end
97
124
 
125
+ # returns an instance of HTTPX::Headers containing the trailer headers
98
126
  def trailers
99
127
  @trailers ||= @options.headers_class.new
100
128
  end
@@ -106,6 +134,7 @@ module HTTPX
106
134
  :w
107
135
  end
108
136
 
137
+ # merges +h+ into the instance of HTTPX::Headers of the request.
109
138
  def merge_headers(h)
110
139
  @headers = @headers.merge(h)
111
140
  end
@@ -172,7 +201,7 @@ module HTTPX
172
201
  return @query if defined?(@query)
173
202
 
174
203
  query = []
175
- if (q = @options.params)
204
+ if (q = @query_params)
176
205
  query << Transcoder::Form.encode(q)
177
206
  end
178
207
  query << @uri.query if @uri.query
@@ -71,9 +71,11 @@ module HTTPX
71
71
  connection = @options.connection_class.new(@uri, @options.merge(ssl: { alpn_protocols: %w[h2] }))
72
72
  @pool.init_connection(connection, @options)
73
73
  # only explicity emit addresses if connection didn't pre-resolve, i.e. it's not an IP.
74
- emit_addresses(connection, @family, @uri_addresses) unless connection.addresses
75
- @building_connection = false
76
- connection
74
+ catch(:coalesced) do
75
+ @building_connection = false
76
+ emit_addresses(connection, @family, @uri_addresses) unless connection.addresses
77
+ connection
78
+ end
77
79
  end
78
80
  end
79
81
 
@@ -199,7 +201,7 @@ module HTTPX
199
201
  @queries.delete_if { |_, conn| connection == conn }
200
202
 
201
203
  Resolver.cached_lookup_set(hostname, @family, addresses) if @resolver_options[:cache]
202
- emit_addresses(connection, @family, addresses.map { |addr| addr["data"] })
204
+ catch(:coalesced) { emit_addresses(connection, @family, addresses.map { |addr| addr["data"] }) }
203
205
  end
204
206
  end
205
207
  return if @connections.empty?
@@ -219,7 +221,7 @@ module HTTPX
219
221
  uri.query = URI.encode_www_form(params)
220
222
  request = rklass.new("GET", uri, @options)
221
223
  else
222
- request = rklass.new("POST", uri, @options.merge(body: [payload]))
224
+ request = rklass.new("POST", uri, @options, body: [payload])
223
225
  request.headers["content-type"] = "application/dns-message"
224
226
  end
225
227
  request.headers["accept"] = "application/dns-message"
@@ -329,7 +329,7 @@ module HTTPX
329
329
  @timeouts.delete(connection.origin.host)
330
330
  @connections.delete(connection)
331
331
  Resolver.cached_lookup_set(connection.origin.host, @family, addresses) if @resolver_options[:cache]
332
- emit_addresses(connection, @family, addresses.map { |addr| addr["data"] })
332
+ catch(:coalesced) { emit_addresses(connection, @family, addresses.map { |addr| addr["data"] }) }
333
333
  end
334
334
  end
335
335
  return emit(:close) if @connections.empty?
@@ -33,7 +33,7 @@ module HTTPX
33
33
  def initialize(family, options)
34
34
  @family = family
35
35
  @record_type = RECORD_TYPES[family]
36
- @options = Options.new(options)
36
+ @options = options
37
37
  end
38
38
 
39
39
  def close; end
@@ -127,7 +127,7 @@ module HTTPX
127
127
  @queries.delete(pair)
128
128
 
129
129
  family, connection = pair
130
- emit_addresses(connection, family, addrs)
130
+ catch(:coalesced) { emit_addresses(connection, family, addrs) }
131
131
  when ERROR
132
132
  *pair, error = @pipe_mutex.synchronize { @ips.pop }
133
133
  @queries.delete(pair)
@@ -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, options)
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 = Options.new(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, **options)
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, options)
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 = EMPTY_HASH)
85
- rklass = @options.request_class
86
- options = @options.merge(options) unless options.is_a?(Options)
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
@@ -126,6 +125,7 @@ module HTTPX
126
125
  connection
127
126
  end
128
127
 
128
+ # sends the +request+ to the corresponding HTTPX::Connection
129
129
  def send_request(request, connections, options = request.options)
130
130
  error = catch(:resolve_error) do
131
131
  connection = find_connection(request, connections, options)
@@ -133,7 +133,7 @@ module HTTPX
133
133
  end
134
134
  return unless error.is_a?(Error)
135
135
 
136
- request.emit(:response, ErrorResponse.new(request, error, options))
136
+ request.emit(:response, ErrorResponse.new(request, error))
137
137
  end
138
138
 
139
139
  # sets the callbacks on the +connection+ required to process certain specific
@@ -192,22 +192,26 @@ module HTTPX
192
192
  end
193
193
 
194
194
  # returns a set of HTTPX::Request objects built from the given +args+ and +options+.
195
- def build_requests(*args, options)
196
- request_options = @options.merge(options)
197
-
195
+ def build_requests(*args, params)
198
196
  requests = if args.size == 1
199
197
  reqs = args.first
200
- reqs.map do |verb, uri, opts = EMPTY_HASH|
201
- build_request(verb, uri, request_options.merge(opts))
198
+ # TODO: find a way to make requests share same options object
199
+ reqs.map do |verb, uri, ps = EMPTY_HASH|
200
+ request_params = params
201
+ request_params = request_params.merge(ps) unless ps.empty?
202
+ build_request(verb, uri, request_params)
202
203
  end
203
204
  else
204
205
  verb, uris = args
205
206
  if uris.respond_to?(:each)
206
- uris.enum_for(:each).map do |uri, opts = EMPTY_HASH|
207
- build_request(verb, uri, request_options.merge(opts))
207
+ # TODO: find a way to make requests share same options object
208
+ uris.enum_for(:each).map do |uri, ps = EMPTY_HASH|
209
+ request_params = params
210
+ request_params = request_params.merge(ps) unless ps.empty?
211
+ build_request(verb, uri, request_params)
208
212
  end
209
213
  else
210
- [build_request(verb, uris, request_options)]
214
+ [build_request(verb, uris, params)]
211
215
  end
212
216
  end
213
217
  raise ArgumentError, "wrong number of URIs (given 0, expect 1..+1)" if requests.empty?
@@ -228,6 +232,14 @@ module HTTPX
228
232
  end
229
233
  end
230
234
 
235
+ def deactivate_connection(request, connections, options)
236
+ conn = connections.find do |c|
237
+ c.match?(request.uri, options)
238
+ end
239
+
240
+ pool.deactivate(conn) if conn
241
+ end
242
+
231
243
  # sends an array of HTTPX::Request +requests+, returns the respective array of HTTPX::Response objects.
232
244
  def send_requests(*requests)
233
245
  connections = _send_requests(requests)
@@ -258,6 +270,7 @@ module HTTPX
258
270
  return responses unless request
259
271
 
260
272
  catch(:coalesced) { pool.next_tick } until (response = fetch_response(request, connections, request.options))
273
+ request.emit(:complete, response)
261
274
 
262
275
  responses << response
263
276
  requests.shift
@@ -271,14 +284,16 @@ module HTTPX
271
284
  # opportunity to traverse the requests, hence we're returning only a fraction of the errors
272
285
  # we were supposed to. This effectively fetches the existing responses and return them.
273
286
  while (request = requests.shift)
274
- responses << fetch_response(request, connections, request.options)
287
+ response = fetch_response(request, connections, request.options)
288
+ request.emit(:complete, response) if response
289
+ responses << response
275
290
  end
276
291
  break
277
292
  end
278
293
  responses
279
294
  ensure
280
295
  if @persistent
281
- pool.deactivate(connections)
296
+ pool.deactivate(*connections)
282
297
  else
283
298
  close(connections)
284
299
  end
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.delete_if { |interval| interval.elapse(elapsed_time) <= 0 }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "1.2.6"
4
+ VERSION = "1.3.1"
5
5
  end
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, options]], **untyped) -> Array[response]
7
- | (verb, _Each[uri | [uri, options]], **untyped) -> Array[response]
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
@@ -38,7 +38,7 @@ module HTTPX
38
38
 
39
39
  def consume: () -> void
40
40
 
41
- def handle_error: (StandardError ex) -> void
41
+ def handle_error: (StandardError ex, ?Request? request) -> void
42
42
 
43
43
  def on_start: () -> void
44
44
 
@@ -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
 
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  MAX_CONCURRENT_REQUESTS: Integer
7
7
 
8
- attr_reader streams: Hash[Request, HTTP2Next::Stream]
8
+ attr_reader streams: Hash[Request, ::HTTP2::Stream]
9
9
  attr_reader pending: Array[Request]
10
10
 
11
11
  @options: Options
@@ -32,7 +32,7 @@ module HTTPX
32
32
 
33
33
  def consume: () -> void
34
34
 
35
- def handle_error: (StandardError ex) -> void
35
+ def handle_error: (StandardError ex, ?Request? request) -> void
36
36
 
37
37
  def ping: () -> void
38
38
 
@@ -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, HTTP2Next::Stream stream) -> void
51
+ def handle: (Request request, ::HTTP2::Stream stream) -> void
52
52
 
53
53
  def init_connection: () -> void
54
54
 
55
- def handle_stream: (HTTP2Next::Stream stream, Request request) -> void
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: (HTTP2Next::Stream stream, Request request) -> void
59
+ def join_headers: (::HTTP2::Stream stream, Request request) -> void
60
60
 
61
- def join_trailers: (HTTP2Next::Stream stream, Request request) -> void
61
+ def join_trailers: (::HTTP2::Stream stream, Request request) -> void
62
62
 
63
- def join_body: (HTTP2Next::Stream stream, Request request) -> void
63
+ def join_body: (::HTTP2::Stream stream, Request request) -> void
64
64
 
65
- def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
65
+ def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
66
66
 
67
- def on_stream_trailers: (HTTP2Next::Stream stream, Response response, Array[[String, String]] headers) -> void
67
+ def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
68
68
 
69
- def on_stream_data: (HTTP2Next::Stream stream, Request request, String data) -> void
69
+ def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
70
70
 
71
- def on_stream_refuse: (HTTP2Next::Stream stream, Request request, StandardError error) -> void
71
+ def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
72
72
 
73
- def on_stream_close: (HTTP2Next::Stream stream, Request request, (Symbol | StandardError)? error) -> void
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: (HTTP2Next::frame) -> void
81
+ def on_frame_sent: (::HTTP2::frame) -> void
82
82
 
83
- def on_frame_received: (HTTP2Next::frame) -> void
83
+ def on_frame_received: (::HTTP2::frame) -> void
84
84
 
85
- def on_altsvc: (String origin, HTTP2Next::frame) -> void
85
+ def on_altsvc: (String origin, ::HTTP2::frame) -> void
86
86
 
87
- def on_promise: (HTTP2Next::Stream) -> void
87
+ def on_promise: (::HTTP2::Stream) -> void
88
88
 
89
89
  def on_origin: (String) -> void
90
90
 
data/sig/connection.rbs CHANGED
@@ -93,9 +93,9 @@ module HTTPX
93
93
 
94
94
  private
95
95
 
96
- def initialize: (http_uri uri, options) -> void
96
+ def initialize: (http_uri uri, Options options) -> void
97
97
 
98
- def initialize_type: (http_uri uri, Options) -> io_type
98
+ def initialize_type: (http_uri uri, Options options) -> io_type
99
99
 
100
100
  def connect: () -> void
101
101
 
@@ -119,14 +119,20 @@ module HTTPX
119
119
 
120
120
  def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
121
121
 
122
- def on_error: (HTTPX::TimeoutError | Error | StandardError error) -> void
122
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
123
123
 
124
- def handle_error: (StandardError error) -> void
124
+ def handle_error: (StandardError error, ?Request? request) -> void
125
125
 
126
126
  def purge_after_closed: () -> void
127
127
 
128
128
  def set_request_timeouts: (Request request) -> void
129
129
 
130
+ def set_request_read_timeout: (Request request) -> void
131
+
132
+ def set_request_write_timeout: (Request request) -> void
133
+
134
+ def set_request_request_timeout: (Request request) -> void
135
+
130
136
  def write_timeout_callback: (Request request, Numeric write_timeout) -> void
131
137
 
132
138
  def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
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 = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" |
13
- "PROPFIND" | "PROPPATCH" | "MKCOL" | "COPY" | "MOVE" | "LOCK" | "UNLOCK" | "ORDERPATCH" |
14
- "ACL" | "REPORT" | "PATCH" | "SEARCH"
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/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, options options) ?{ (instance) -> void } -> void
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
@@ -15,7 +15,7 @@ module HTTPX
15
15
 
16
16
  @io: Socket
17
17
 
18
- def initialize: (http_uri origin, String? path, options options) -> void
18
+ def initialize: (http_uri origin, String? path, Options options) -> void
19
19
 
20
20
  def connect: () -> void
21
21
 
data/sig/options.rbs CHANGED
@@ -63,19 +63,7 @@ module HTTPX
63
63
  # decompress_response_body
64
64
  attr_reader decompress_response_body: bool
65
65
 
66
- # params
67
- attr_reader params: Transcoder::urlencoded_input?
68
-
69
- # form
70
- attr_reader form: Transcoder::urlencoded_input?
71
-
72
- # json
73
- attr_reader json: _ToJson?
74
-
75
- # body
76
- attr_reader body: bodyIO?
77
-
78
- # body
66
+ # origin
79
67
  attr_reader origin: URI::Generic?
80
68
 
81
69
  # base_path
@@ -24,7 +24,7 @@ module HTTPX
24
24
  module InstanceMethods
25
25
  def max_redirects: (_ToI) -> instance
26
26
 
27
- def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
27
+ def handle_after_redirect_request: (http_uri original_uri, http_uri redirect_uri, Request request, Options & _FollowRedirectsOptions options) -> void
28
28
 
29
29
  def __get_location_from_response: (Response) -> http_uri
30
30
  end
@@ -16,6 +16,9 @@ module HTTPX
16
16
  def __http_on_connect: (top, Response) -> void
17
17
  end
18
18
 
19
+ class ConnectRequest < Request
20
+ def initialize: (generic_uri uri, Options options) -> void
21
+ end
19
22
  end
20
23
  end
21
24
 
@@ -43,6 +43,8 @@ module HTTPX
43
43
  private
44
44
 
45
45
  def proxy_error?: (Request request, response) -> bool
46
+
47
+ def proxy_options: (http_uri request_uri, Options & _ProxyOptions options) -> (Options & _ProxyOptions)
46
48
  end
47
49
 
48
50
  module ConnectionMethods
@@ -9,9 +9,9 @@ module HTTPX
9
9
  module InstanceMethods
10
10
  private
11
11
 
12
- def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
13
- def __on_promise_request: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
14
- def __on_promise_response: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
12
+ def promise_headers: () -> Hash[::HTTP2::Stream, Request]
13
+ def __on_promise_request: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
14
+ def __on_promise_response: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
15
15
  end
16
16
  end
17
17
 
data/sig/pool.rbs CHANGED
@@ -19,7 +19,7 @@ module HTTPX
19
19
 
20
20
  def find_connection: (URI::Generic uri, Options options) -> Connection?
21
21
 
22
- def deactivate: (*Array[Connection]) -> void
22
+ def deactivate: (*Connection connections) -> void
23
23
 
24
24
  private
25
25
 
data/sig/request/body.rbs CHANGED
@@ -4,7 +4,7 @@ module HTTPX
4
4
  @body: body_encoder?
5
5
  @unbounded_body: bool
6
6
 
7
- def initialize: (Headers headers, Options options) -> void
7
+ def initialize: (Headers headers, Options options, ?body: bodyIO, ?form: Transcoder::urlencoded_input?, ?json: _ToJson?, **untyped) -> void
8
8
 
9
9
  def each: () { (String) -> void } -> void
10
10
  | () -> Enumerable[String]
@@ -25,8 +25,6 @@ module HTTPX
25
25
 
26
26
  private
27
27
 
28
- def initialize_body: (Options options) -> void
29
-
30
28
  def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
31
29
  end
32
30
 
data/sig/request.rbs CHANGED
@@ -19,12 +19,13 @@ module HTTPX
19
19
 
20
20
  attr_writer persistent: bool
21
21
 
22
+ @query_params: Hash[interned, untyped]?
22
23
  @trailers: Headers?
23
24
  @informational_status: Integer?
24
25
  @query: String?
25
26
  @drainer: Enumerator[String, void]?
26
27
 
27
- def initialize: (Symbol | String, generic_uri, ?options) -> untyped
28
+ def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
28
29
 
29
30
  def interests: () -> (:r | :w)
30
31
 
@@ -26,9 +26,9 @@ module HTTPX
26
26
 
27
27
  def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
28
28
 
29
- def initialize: (ip_family? family, options options) -> void
29
+ def initialize: (ip_family? family, Options options) -> void
30
30
 
31
- def early_resolve: (Connection connection, ?hostname: String) -> void
31
+ def early_resolve: (Connection connection, ?hostname: String) -> boolish
32
32
 
33
33
  def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
34
34
 
data/sig/response.rbs CHANGED
@@ -91,7 +91,7 @@ module HTTPX
91
91
 
92
92
  private
93
93
 
94
- def initialize: (Request, Exception, options) -> untyped
94
+ def initialize: (Request, Exception) -> untyped
95
95
  end
96
96
 
97
97
  type response = Response | ErrorResponse