httpx 1.2.4 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d5abc65b9f6377dbcefbe9170c7c47ef3555b4286c2d9c5e6e521467a75d57e
4
- data.tar.gz: 7dfac2d6aa4ed5ecba31479ec0750de9d310657c39e12efd57f62d1544d9d1b7
3
+ metadata.gz: 0fc8cbe89a9d05f24f615e5de7874c65147954cc8d06524955fea9d0e4ef5598
4
+ data.tar.gz: e97b5febb579cd1c5e035faef9cf0368ab7148882d2ed95a0454b52fd0d31621
5
5
  SHA512:
6
- metadata.gz: 720fe0c6f0883d0755122ae8009da116f7b06b0f009b56480cf3f1f80ef998e4671d6f53ce039e6d52f502c596e22fa524d6292a3372c8bd3a7f88616f6aaffc
7
- data.tar.gz: 75fdb8eee5568a3be2fdd19a4750b18166d2eb25749a0a1cde672b0deab76d1e64c8d573665488b7d2db99d4de73f387583a75ad5a957be9529dfef4b36f11ac
6
+ metadata.gz: 55631972d465e4ea086dcaced389f7998380f052c369004f45d286d0502c612289dc5a19deff7ca26c9c0cfd6e2c4926ba5e32744c366f18884f97aedb3ad5bf
7
+ data.tar.gz: 9eb1be90bceb56c335a84b180ae6c7fc065944ae1fd6dab17d9e4802c7fb62c7d3f34d3c98ba41a9cb1b8e503a929eb97cd8a667a9f536090ef266936efb81d9
@@ -0,0 +1,7 @@
1
+ # 1.2.5
2
+
3
+ ## Bugfixes
4
+
5
+ * fix for usage of correct `last-modified` header in `response_cache` plugin.
6
+ * fix usage of decoding helper methods (i.e. `response.json`) with `response_cache` plugin.
7
+ * `stream` plugin: reverted back to yielding buffered payloads for streamed responses (broke `down` integration)
@@ -0,0 +1,13 @@
1
+ # 1.2.6
2
+
3
+ ## Improvements
4
+
5
+ * `native` resolver: when timing out on DNS query for an alias, retry the DNS query for the alias (instead of the original hostname).
6
+
7
+ ## Bugfixes
8
+
9
+ * `faraday` adapter: set `env` options on the request object, so they are available in the request object when yielded.
10
+ * `follow_redirects` plugin: remove body-related headers (`content-length`, `content-type`) on POST-to-GET redirects.
11
+ * `follow_redirects` plugin: maintain verb (and body) of original request when the response status code is 307.
12
+ * `native` resolver: when timing out on TCP-based name resolution, downgrade to UDP before retrying.
13
+ * `rate_limiter` plugin: do not try fetching the retry-after of error responses.
@@ -61,6 +61,7 @@ module Faraday
61
61
  request_options = {
62
62
  headers: env.request_headers,
63
63
  body: env.body,
64
+ **options_from_env(env),
64
65
  }
65
66
  [meth.to_s.upcase, env.url, request_options]
66
67
  end
@@ -387,6 +387,7 @@ module HTTPX
387
387
  UPCASED = {
388
388
  "www-authenticate" => "WWW-Authenticate",
389
389
  "http2-settings" => "HTTP2-Settings",
390
+ "content-md5" => "Content-MD5",
390
391
  }.freeze
391
392
 
392
393
  def capitalized(field)
@@ -48,10 +48,10 @@ module HTTPX
48
48
  attr_accessor :family
49
49
 
50
50
  def initialize(uri, options)
51
- @origins = [uri.origin]
52
- @origin = Utils.to_uri(uri.origin)
53
51
  @options = Options.new(options)
54
52
  @type = initialize_type(uri, @options)
53
+ @origins = [uri.origin]
54
+ @origin = Utils.to_uri(uri.origin)
55
55
  @window_size = @options.window_size
56
56
  @read_buffer = Buffer.new(@options.buffer_size)
57
57
  @write_buffer = Buffer.new(@options.buffer_size)
@@ -626,7 +626,11 @@ module HTTPX
626
626
  end
627
627
  end
628
628
  when "unix"
629
- UNIX.new(@origin, addrs, @options)
629
+ path = Array(addrs).first
630
+
631
+ path = String(path) if path
632
+
633
+ UNIX.new(@origin, path, @options)
630
634
  else
631
635
  raise Error, "unsupported transport (#{@type})"
632
636
  end
data/lib/httpx/io/unix.rb CHANGED
@@ -8,7 +8,7 @@ module HTTPX
8
8
 
9
9
  alias_method :host, :path
10
10
 
11
- def initialize(origin, addresses, options)
11
+ def initialize(origin, path, options)
12
12
  @addresses = []
13
13
  @hostname = origin.host
14
14
  @state = :idle
@@ -26,8 +26,10 @@ module HTTPX
26
26
  @path = @io.path
27
27
  @keep_open = true
28
28
  @state = :connected
29
+ elsif path
30
+ @path = path
29
31
  else
30
- @path = addresses.first
32
+ raise Error, "No path given where to store the socket"
31
33
  end
32
34
  @io ||= build_socket
33
35
  end
@@ -75,6 +75,7 @@ module HTTPX
75
75
  buffer = @buffer
76
76
 
77
77
  while (idx = buffer.index("\n"))
78
+ # @type var line: String
78
79
  line = buffer.byteslice(0..idx)
79
80
  raise Error, "wrong header format" if line.start_with?("\s", "\t")
80
81
 
@@ -101,9 +102,11 @@ module HTTPX
101
102
  separator_index = line.index(":")
102
103
  raise Error, "wrong header format" unless separator_index
103
104
 
105
+ # @type var key: String
104
106
  key = line.byteslice(0..(separator_index - 1))
105
107
 
106
108
  key.rstrip! # was lstripped previously!
109
+ # @type var value: String
107
110
  value = line.byteslice((separator_index + 1)..-1)
108
111
  value.strip!
109
112
  raise Error, "wrong header format" if value.nil?
@@ -118,6 +121,7 @@ module HTTPX
118
121
  @observer.on_data(chunk)
119
122
  end
120
123
  elsif @content_length
124
+ # @type var data: String
121
125
  data = @buffer.byteslice(0, @content_length)
122
126
  @buffer = @buffer.byteslice(@content_length..-1) || "".b
123
127
  @content_length -= data.bytesize
@@ -16,6 +16,7 @@ module HTTPX
16
16
  module FollowRedirects
17
17
  MAX_REDIRECTS = 3
18
18
  REDIRECT_STATUS = (300..399).freeze
19
+ REQUEST_BODY_HEADERS = %w[transfer-encoding content-encoding content-type content-length content-language content-md5 trailer].freeze
19
20
 
20
21
  using URIExtensions
21
22
 
@@ -60,7 +61,6 @@ module HTTPX
60
61
  return response unless REDIRECT_STATUS.include?(response.status) && response.headers.key?("location")
61
62
  return response unless max_redirects.positive?
62
63
 
63
- # build redirect request
64
64
  redirect_uri = __get_location_from_response(response)
65
65
 
66
66
  if options.redirect_on
@@ -68,24 +68,42 @@ module HTTPX
68
68
  return response unless redirect_allowed
69
69
  end
70
70
 
71
+ # build redirect request
72
+ request_body = redirect_request.body
73
+ redirect_method = "GET"
74
+
71
75
  if response.status == 305 && options.respond_to?(:proxy)
76
+ request_body.rewind
72
77
  # The requested resource MUST be accessed through the proxy given by
73
78
  # the Location field. The Location field gives the URI of the proxy.
74
79
  retry_options = options.merge(headers: redirect_request.headers,
75
80
  proxy: { uri: redirect_uri },
76
- body: redirect_request.body,
81
+ body: request_body,
77
82
  max_redirects: max_redirects - 1)
78
83
  redirect_uri = redirect_request.uri
79
84
  options = retry_options
80
85
  else
81
86
  redirect_headers = redirect_request_headers(redirect_request.uri, redirect_uri, request.headers, options)
82
87
 
83
- # redirects are **ALWAYS** GET
84
- retry_opts = Hash[options].merge(
85
- headers: redirect_headers.to_h,
86
- body: redirect_request.body,
87
- max_redirects: max_redirects - 1
88
- )
88
+ retry_opts = Hash[options].merge(max_redirects: max_redirects - 1)
89
+
90
+ unless request_body.empty?
91
+ if response.status == 307
92
+ # The method and the body of the original request are reused to perform the redirected request.
93
+ redirect_method = redirect_request.verb
94
+ request_body.rewind
95
+ retry_opts[:body] = request_body
96
+ else
97
+ # redirects are **ALWAYS** GET, so remove body-related headers
98
+ REQUEST_BODY_HEADERS.each do |h|
99
+ redirect_headers.delete(h)
100
+ end
101
+ retry_opts.delete(:body)
102
+ end
103
+ end
104
+
105
+ retry_opts[:headers] = redirect_headers.to_h
106
+
89
107
  retry_options = options.class.new(retry_opts)
90
108
  end
91
109
 
@@ -99,7 +117,7 @@ module HTTPX
99
117
  return ErrorResponse.new(request, error, options)
100
118
  end
101
119
 
102
- retry_request = build_request("GET", redirect_uri, retry_options)
120
+ retry_request = build_request(redirect_method, redirect_uri, retry_options)
103
121
 
104
122
  request.redirect_request = retry_request
105
123
 
@@ -125,6 +143,8 @@ module HTTPX
125
143
  end
126
144
 
127
145
  def redirect_request_headers(original_uri, redirect_uri, headers, options)
146
+ headers = headers.dup
147
+
128
148
  return headers if options.allow_auth_to_other_origins
129
149
 
130
150
  return headers unless headers.key?("authorization")
@@ -138,6 +158,7 @@ module HTTPX
138
158
  end
139
159
 
140
160
  def __get_location_from_response(response)
161
+ # @type var location_uri: http_uri
141
162
  location_uri = URI(response.headers["location"])
142
163
  location_uri = response.uri.merge(location_uri) if location_uri.relative?
143
164
  location_uri
@@ -124,6 +124,7 @@ module HTTPX
124
124
 
125
125
  module InstanceMethods
126
126
  def with_channel_credentials(ca_path, key = nil, cert = nil, **ssl_opts)
127
+ # @type var ssl_params: ::Hash[::Symbol, untyped]
127
128
  ssl_params = {
128
129
  **ssl_opts,
129
130
  ca_file: ca_path,
@@ -39,6 +39,8 @@ module HTTPX
39
39
  # the redirected request.
40
40
  #
41
41
  def retry_after_rate_limit(_, response)
42
+ return unless response.is_a?(Response)
43
+
42
44
  retry_after = response.headers["retry-after"]
43
45
 
44
46
  return unless retry_after
@@ -40,7 +40,7 @@ module HTTPX
40
40
  # the Range and Content-Range headers MUST NOT cache 206 (Partial
41
41
  # Content) responses.
42
42
  response.status != 206 && (
43
- response.headers.key?("etag") || response.headers.key?("last-modified-at") || response.fresh?
43
+ response.headers.key?("etag") || response.headers.key?("last-modified") || response.fresh?
44
44
  )
45
45
  end
46
46
 
@@ -102,6 +102,9 @@ module HTTPX
102
102
 
103
103
  module ResponseMethods
104
104
  def copy_from_cached(other)
105
+ # 304 responses do not have content-type, which are needed for decoding.
106
+ @headers = @headers.class.new(other.headers.merge(@headers))
107
+
105
108
  @body = other.body.dup
106
109
 
107
110
  @body.rewind
@@ -16,9 +16,18 @@ module HTTPX
16
16
  begin
17
17
  @on_chunk = block
18
18
 
19
+ if @request.response
20
+ # if we've already started collecting the payload, yield it first
21
+ # before proceeding.
22
+ body = @request.response.body
23
+
24
+ body.each do |chunk|
25
+ on_chunk(chunk)
26
+ end
27
+ end
28
+
19
29
  response.raise_for_status
20
30
  ensure
21
- response.close if @response
22
31
  @on_chunk = nil
23
32
  end
24
33
  end
@@ -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
- resolve(connection)
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
- resolve(connection)
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
- transition(:idle)
193
- transition(:open)
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: address["alias"]) }
314
+ if catch(:coalesced) { early_resolve(connection, hostname: hostname_alias) }
311
315
  @connections.delete(connection)
312
316
  else
313
- resolve(connection, address["alias"])
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
 
@@ -19,7 +19,7 @@ module HTTPX
19
19
  end
20
20
 
21
21
  def read(length = nil, outbuf = nil)
22
- data = outbuf.clear.force_encoding(Encoding::BINARY) if outbuf
22
+ data = String(outbuf).clear.force_encoding(Encoding::BINARY) if outbuf
23
23
  data ||= "".b
24
24
 
25
25
  read_chunks(data, length)
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.4"
4
+ VERSION = "1.2.6"
5
5
  end
@@ -32,7 +32,7 @@ module HTTPX
32
32
 
33
33
  def exhausted?: () -> bool
34
34
 
35
- def <<: (String) -> void
35
+ def <<: (string) -> void
36
36
 
37
37
  def send: (Request) -> void
38
38
 
@@ -24,7 +24,7 @@ module HTTPX
24
24
 
25
25
  def exhausted?: () -> bool
26
26
 
27
- def <<: (String) -> void
27
+ def <<: (string) -> void
28
28
 
29
29
  def can_buffer_more_requests?: () -> bool
30
30
 
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: URI::Generic
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: HTTP1 | HTTP2 | _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: (URI::Generic uri, options) -> void
96
+ def initialize: (http_uri uri, options) -> void
96
97
 
97
- def initialize_type: (URI::Generic uri, options) -> io_type
98
+ def initialize_type: (http_uri uri, 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: () -> (HTTP1 | HTTP2 | _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) -> (HTTP1 | HTTP2)
112
+ def build_parser: (?String protocol) -> (Object & _Parser)
112
113
 
113
114
  def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
114
115
 
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, options options) ?{ (self) -> 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
@@ -5,6 +5,23 @@ module HTTPX
5
5
 
6
6
  alias host path
7
7
 
8
- def initialize: (http_uri origin, Array[String]? addresses, options options) -> void
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: "unix" | nil
52
+ attr_reader transport: io_type | nil
50
53
 
51
54
  # addresses
52
55
  attr_reader addresses: Array[ipaddr]?
data/sig/parser/http1.rbs CHANGED
@@ -29,7 +29,7 @@ module HTTPX
29
29
  @_has_trailers: bool
30
30
  @upgrade: bool
31
31
 
32
- def <<: (String chunk) -> void
32
+ def <<: (string chunk) -> void
33
33
 
34
34
  def reset!: () -> void
35
35
 
@@ -7,7 +7,7 @@ module HTTPX
7
7
  module InstanceMethods
8
8
  include HTTPX::Callbacks
9
9
 
10
- type socket = TCPSocket | SSLSocket | UNIXSocket
10
+ type socket = TCPSocket | OpenSSL::SSL::SSLSocket | UNIXSocket
11
11
 
12
12
  def on_connection_opened: () { (http_uri origin, socket sock) -> void } -> self
13
13
 
@@ -5,6 +5,9 @@ module HTTPX
5
5
  module FollowRedirects
6
6
  MAX_REDIRECTS: Integer
7
7
  REDIRECT_STATUS: Range[Integer]
8
+ REQUEST_BODY_HEADERS: Array[String]
9
+
10
+ type redirect_request = Request & RequestMethods
8
11
 
9
12
  interface _FollowRedirectsOptions
10
13
  def max_redirects: () -> Integer?
@@ -13,7 +16,7 @@ module HTTPX
13
16
 
14
17
  def allow_auth_to_other_origins: () -> bool?
15
18
 
16
- def redirect_on: (http_uri) -> bool?
19
+ def redirect_on: () -> (^(http_uri) -> boolish | nil)
17
20
  end
18
21
 
19
22
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
@@ -23,15 +26,17 @@ module HTTPX
23
26
 
24
27
  def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
25
28
 
26
- def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
29
+ def __get_location_from_response: (Response) -> http_uri
27
30
  end
28
31
 
29
32
  module RequestMethods
30
33
  attr_accessor root_request: instance?
31
34
 
32
- def redirect_request: () -> instance
35
+ @redirect_request: redirect_request
36
+
37
+ def redirect_request: () -> redirect_request
33
38
 
34
- def redirect_request=: (Request) -> void
39
+ def redirect_request=: (redirect_request req) -> void
35
40
 
36
41
  def max_redirects: () -> Integer
37
42
  end
data/sig/plugins/grpc.rbs CHANGED
@@ -7,6 +7,11 @@ module HTTPX
7
7
 
8
8
  module Plugins
9
9
  module GRPC
10
+ DEADLINE: Integer
11
+ MARSHAL_METHOD: Symbol
12
+ UNMARSHAL_METHOD: Symbol
13
+ HEADERS: Hash[String, String]
14
+
10
15
  type compression_option = bool | String
11
16
  type rpc_def = [String, untyped, untyped, Hash[Symbol, untyped]]
12
17
 
@@ -13,7 +13,10 @@ module HTTPX
13
13
  end
14
14
 
15
15
  class SocksParser
16
- include Callbacks
16
+ include HTTPX::Callbacks
17
+
18
+ @buffer: Buffer
19
+ @options: Options
17
20
 
18
21
  def close: () -> void
19
22
  def consume: (*untyped) -> void
@@ -22,7 +25,7 @@ module HTTPX
22
25
 
23
26
  private
24
27
 
25
- def initialize: (Buffer buffer, Options) -> untyped
28
+ def initialize: (Buffer buffer, Options options) -> untyped
26
29
  end
27
30
 
28
31
  module Packet
@@ -15,7 +15,10 @@ module HTTPX
15
15
  end
16
16
 
17
17
  class SocksParser
18
- include Callbacks
18
+ include HTTPX::Callbacks
19
+
20
+ @buffer: Buffer
21
+ @options: Options
19
22
 
20
23
  def close: () -> void
21
24
  def consume: (*untyped) -> void
@@ -24,7 +27,7 @@ module HTTPX
24
27
 
25
28
  private
26
29
 
27
- def initialize: (Buffer buffer, Options) -> untyped
30
+ def initialize: (Buffer buffer, Options options) -> untyped
28
31
  end
29
32
 
30
33
  module Packet
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.retry_on_rate_limited_response: (_Response) -> bool
7
7
 
8
- def self.retry_after_rate_limit: (untyped, _Response) -> Numeric?
8
+ def self.retry_after_rate_limit: (untyped, response) -> Numeric?
9
9
  end
10
10
  end
11
11
  end
@@ -29,6 +29,8 @@ module HTTPX
29
29
 
30
30
  private
31
31
 
32
+ def fetch_response: (retriesRequest request, Array[Connection] connections, retriesOptions options) -> (retriesResponse | ErrorResponse)?
33
+
32
34
  def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
33
35
 
34
36
  def __retryable_error?: (_Exception error) -> bool
@@ -11,7 +11,7 @@ module HTTPX
11
11
  @options: Options
12
12
  @requests: Hash[Request, String]
13
13
  @connections: Array[Connection]
14
- @uri: URI::Generic
14
+ @uri: http_uri
15
15
  @uri_addresses: Array[String]?
16
16
  @resolver: Resolv::DNS
17
17
  @resolver_connection: Connection
@@ -59,6 +59,8 @@ module HTTPX
59
59
 
60
60
  def build_socket: () -> (UDP | TCP)
61
61
 
62
+ def downgrade_socket: () -> void
63
+
62
64
  def transition: (Symbol nextstate) -> void
63
65
 
64
66
  def handle_error: (NativeResolveError | StandardError) -> void
data/sig/session.rbs CHANGED
@@ -43,7 +43,7 @@ module HTTPX
43
43
  | (verb, _Each[[uri, options]], Options) -> Array[Request]
44
44
  | (verb, _Each[uri], options) -> Array[Request]
45
45
 
46
- def init_connection: (URI::HTTP | URI::HTTP uri, Options options) -> Connection
46
+ def init_connection: (http_uri uri, Options options) -> Connection
47
47
 
48
48
  def send_requests: (*Request) -> Array[response]
49
49
 
@@ -21,8 +21,8 @@ module HTTPX
21
21
  @part_index: Integer
22
22
  @buffer: String
23
23
 
24
- @form: Enumerable[[Symbol | string, multipart_nested_value]]
25
- @parts: Array[_Reader]
24
+ @form: Enumerable[[Symbol | string, Object & multipart_nested_value]]
25
+ @parts: Array[Object & _Reader]
26
26
 
27
27
  def bytesize: () -> Integer
28
28
 
@@ -40,13 +40,18 @@ module HTTPX
40
40
 
41
41
  def header_part: (string key, String content_type, String? filename) -> StringIO
42
42
 
43
- def read_chunks: (String buffer, ?Integer? length) -> void
43
+ def read_chunks: (String buffer, ?int? length) -> void
44
44
 
45
- def read_from_part: (?Integer? max_length) -> String?
45
+ def read_from_part: (?int? max_length) -> String?
46
46
  end
47
47
 
48
48
  class Decoder
49
+ CRLF: String
49
50
  BOUNDARY_RE: Regexp
51
+ MULTIPART_CONTENT_TYPE: Regexp
52
+ MULTIPART_CONTENT_DISPOSITION: Regexp
53
+ MULTIPART_CONTENT_ID: Regexp
54
+ WINDOW_SIZE: Integer
50
55
 
51
56
  @state: :idle | :part_header | :part_body | :parse_boundary | :done
52
57
  @buffer: String
@@ -75,8 +80,8 @@ module HTTPX
75
80
  end
76
81
 
77
82
  module Part
78
- def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
79
- | (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
83
+ def self?.call: [U] (Object & _MultipartInput multipart_input) -> [U, String, String]
84
+ | (Object & multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
80
85
  end
81
86
 
82
87
  module MimeTypeDetector
@@ -1,5 +1,6 @@
1
1
  module HTTPX::Transcoder
2
2
  module Xml
3
+ MIME_TYPES: Regexp
3
4
 
4
5
  def self?.encode: (untyped xml) -> Encoder
5
6
  def self?.decode: (HTTPX::Response response) -> _Decoder
data/sig/utils.rbs CHANGED
@@ -1,5 +1,9 @@
1
1
  module HTTPX
2
2
  module Utils
3
+ TOKEN: Regexp
4
+ VALUE: Regexp
5
+ FILENAME_REGEX: Regexp
6
+ FILENAME_EXTENSION_REGEX: Regexp
3
7
  URIParser: URI::RFC2396_Parser
4
8
 
5
9
  def self?.parse_retry_after: (String) -> Numeric
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-02 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -142,6 +142,8 @@ extra_rdoc_files:
142
142
  - doc/release_notes/1_2_2.md
143
143
  - doc/release_notes/1_2_3.md
144
144
  - doc/release_notes/1_2_4.md
145
+ - doc/release_notes/1_2_5.md
146
+ - doc/release_notes/1_2_6.md
145
147
  files:
146
148
  - LICENSE.txt
147
149
  - README.md
@@ -255,6 +257,8 @@ files:
255
257
  - doc/release_notes/1_2_2.md
256
258
  - doc/release_notes/1_2_3.md
257
259
  - doc/release_notes/1_2_4.md
260
+ - doc/release_notes/1_2_5.md
261
+ - doc/release_notes/1_2_6.md
258
262
  - lib/httpx.rb
259
263
  - lib/httpx/adapters/datadog.rb
260
264
  - lib/httpx/adapters/faraday.rb
@@ -471,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
471
475
  - !ruby/object:Gem::Version
472
476
  version: '0'
473
477
  requirements: []
474
- rubygems_version: 3.4.10
478
+ rubygems_version: 3.5.3
475
479
  signing_key:
476
480
  specification_version: 4
477
481
  summary: HTTPX, to the future, and beyond