httpx 1.2.6 → 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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/doc/release_notes/1_3_0.md +18 -0
  4. data/doc/release_notes/1_3_1.md +17 -0
  5. data/doc/release_notes/1_3_2.md +6 -0
  6. data/doc/release_notes/1_3_3.md +5 -0
  7. data/doc/release_notes/1_3_4.md +6 -0
  8. data/doc/release_notes/1_4_0.md +43 -0
  9. data/doc/release_notes/1_4_1.md +19 -0
  10. data/doc/release_notes/1_4_2.md +20 -0
  11. data/doc/release_notes/1_4_3.md +11 -0
  12. data/doc/release_notes/1_4_4.md +14 -0
  13. data/lib/httpx/adapters/datadog.rb +56 -80
  14. data/lib/httpx/adapters/faraday.rb +5 -2
  15. data/lib/httpx/adapters/webmock.rb +24 -8
  16. data/lib/httpx/callbacks.rb +2 -7
  17. data/lib/httpx/chainable.rb +3 -1
  18. data/lib/httpx/connection/http1.rb +11 -7
  19. data/lib/httpx/connection/http2.rb +57 -34
  20. data/lib/httpx/connection.rb +270 -71
  21. data/lib/httpx/errors.rb +15 -4
  22. data/lib/httpx/io/ssl.rb +6 -3
  23. data/lib/httpx/io/tcp.rb +1 -1
  24. data/lib/httpx/io/unix.rb +1 -1
  25. data/lib/httpx/loggable.rb +17 -10
  26. data/lib/httpx/options.rb +30 -23
  27. data/lib/httpx/plugins/aws_sdk_authentication.rb +3 -0
  28. data/lib/httpx/plugins/aws_sigv4.rb +36 -17
  29. data/lib/httpx/plugins/callbacks.rb +13 -2
  30. data/lib/httpx/plugins/circuit_breaker.rb +11 -5
  31. data/lib/httpx/plugins/content_digest.rb +202 -0
  32. data/lib/httpx/plugins/cookies.rb +9 -6
  33. data/lib/httpx/plugins/digest_auth.rb +3 -0
  34. data/lib/httpx/plugins/expect.rb +10 -4
  35. data/lib/httpx/plugins/follow_redirects.rb +68 -33
  36. data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -0
  37. data/lib/httpx/plugins/grpc.rb +2 -2
  38. data/lib/httpx/plugins/h2c.rb +23 -20
  39. data/lib/httpx/plugins/internal_telemetry.rb +48 -1
  40. data/lib/httpx/plugins/oauth.rb +1 -1
  41. data/lib/httpx/plugins/persistent.rb +16 -0
  42. data/lib/httpx/plugins/proxy/http.rb +19 -16
  43. data/lib/httpx/plugins/proxy/socks4.rb +1 -1
  44. data/lib/httpx/plugins/proxy/socks5.rb +1 -1
  45. data/lib/httpx/plugins/proxy.rb +96 -85
  46. data/lib/httpx/plugins/retries.rb +28 -10
  47. data/lib/httpx/plugins/ssrf_filter.rb +4 -1
  48. data/lib/httpx/plugins/stream.rb +42 -18
  49. data/lib/httpx/plugins/upgrade.rb +5 -10
  50. data/lib/httpx/plugins/webdav.rb +6 -0
  51. data/lib/httpx/plugins/xml.rb +76 -0
  52. data/lib/httpx/pool.rb +73 -244
  53. data/lib/httpx/request/body.rb +50 -55
  54. data/lib/httpx/request.rb +77 -14
  55. data/lib/httpx/resolver/https.rb +17 -20
  56. data/lib/httpx/resolver/multi.rb +34 -16
  57. data/lib/httpx/resolver/native.rb +140 -61
  58. data/lib/httpx/resolver/resolver.rb +64 -19
  59. data/lib/httpx/resolver/system.rb +32 -16
  60. data/lib/httpx/resolver.rb +21 -14
  61. data/lib/httpx/response/body.rb +12 -1
  62. data/lib/httpx/response.rb +16 -9
  63. data/lib/httpx/selector.rb +170 -91
  64. data/lib/httpx/session.rb +282 -139
  65. data/lib/httpx/timers.rb +17 -2
  66. data/lib/httpx/transcoder/body.rb +15 -29
  67. data/lib/httpx/transcoder/form.rb +2 -0
  68. data/lib/httpx/transcoder/gzip.rb +0 -3
  69. data/lib/httpx/transcoder/json.rb +16 -2
  70. data/lib/httpx/transcoder/multipart/encoder.rb +11 -2
  71. data/lib/httpx/transcoder/multipart/part.rb +1 -1
  72. data/lib/httpx/transcoder/utils/deflater.rb +7 -4
  73. data/lib/httpx/transcoder.rb +0 -1
  74. data/lib/httpx/version.rb +1 -1
  75. data/lib/httpx.rb +20 -21
  76. data/sig/callbacks.rbs +2 -3
  77. data/sig/chainable.rbs +6 -2
  78. data/sig/connection/http1.rbs +2 -2
  79. data/sig/connection/http2.rbs +22 -18
  80. data/sig/connection.rbs +40 -9
  81. data/sig/errors.rbs +9 -3
  82. data/sig/httpx.rbs +3 -3
  83. data/sig/io/tcp.rbs +1 -1
  84. data/sig/io/unix.rbs +1 -1
  85. data/sig/loggable.rbs +4 -2
  86. data/sig/options.rbs +8 -13
  87. data/sig/plugins/aws_sigv4.rbs +8 -2
  88. data/sig/plugins/content_digest.rbs +51 -0
  89. data/sig/plugins/cookies/cookie.rbs +9 -0
  90. data/sig/plugins/follow_redirects.rbs +1 -1
  91. data/sig/plugins/grpc/call.rbs +4 -0
  92. data/sig/plugins/persistent.rbs +4 -1
  93. data/sig/plugins/proxy/http.rbs +3 -0
  94. data/sig/plugins/proxy/socks5.rbs +11 -3
  95. data/sig/plugins/proxy.rbs +18 -9
  96. data/sig/plugins/push_promise.rbs +6 -3
  97. data/sig/plugins/rate_limiter.rbs +2 -0
  98. data/sig/plugins/retries.rbs +1 -1
  99. data/sig/plugins/ssrf_filter.rbs +26 -0
  100. data/sig/plugins/stream.rbs +3 -0
  101. data/sig/plugins/webdav.rbs +23 -0
  102. data/sig/plugins/xml.rbs +37 -0
  103. data/sig/pool.rbs +27 -33
  104. data/sig/request/body.rbs +4 -10
  105. data/sig/request.rbs +14 -1
  106. data/sig/resolver/multi.rbs +26 -1
  107. data/sig/resolver/native.rbs +6 -3
  108. data/sig/resolver/resolver.rbs +22 -3
  109. data/sig/resolver.rbs +5 -1
  110. data/sig/response/body.rbs +2 -2
  111. data/sig/response/buffer.rbs +2 -2
  112. data/sig/response.rbs +9 -4
  113. data/sig/selector.rbs +31 -4
  114. data/sig/session.rbs +54 -20
  115. data/sig/timers.rbs +15 -4
  116. data/sig/transcoder/body.rbs +2 -4
  117. data/sig/transcoder/chunker.rbs +1 -1
  118. data/sig/transcoder/deflate.rbs +1 -0
  119. data/sig/transcoder/form.rbs +8 -0
  120. data/sig/transcoder/gzip.rbs +4 -1
  121. data/sig/transcoder/json.rbs +1 -1
  122. data/sig/transcoder/multipart.rbs +6 -4
  123. data/sig/transcoder/utils/body_reader.rbs +3 -3
  124. data/sig/transcoder/utils/deflater.rbs +2 -3
  125. metadata +32 -14
  126. data/lib/httpx/session2.rb +0 -23
  127. data/lib/httpx/transcoder/utils/inflater.rb +0 -19
  128. data/lib/httpx/transcoder/xml.rb +0 -52
  129. data/sig/transcoder/utils/inflater.rbs +0 -12
  130. data/sig/transcoder/xml.rbs +0 -22
@@ -6,7 +6,19 @@ module HTTPX::Transcoder
6
6
  module JSON
7
7
  module_function
8
8
 
9
- JSON_REGEX = %r{\bapplication/(?:vnd\.api\+|hal\+)?json\b}i.freeze
9
+ JSON_REGEX = %r{
10
+ \b
11
+ application/
12
+ # optional vendor specific type
13
+ (?:
14
+ # token as per https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6
15
+ [!#$%&'*+\-.^_`|~0-9a-z]+
16
+ # literal plus sign
17
+ \+
18
+ )?
19
+ json
20
+ \b
21
+ }ix.freeze
10
22
 
11
23
  class Encoder
12
24
  extend Forwardable
@@ -15,6 +27,8 @@ module HTTPX::Transcoder
15
27
 
16
28
  def_delegator :@raw, :bytesize
17
29
 
30
+ def_delegator :@raw, :==
31
+
18
32
  def initialize(json)
19
33
  @raw = JSON.json_dump(json)
20
34
  @charset = @raw.encoding.name.downcase
@@ -43,7 +57,7 @@ module HTTPX::Transcoder
43
57
  def json_dump(*args); MultiJson.dump(*args); end
44
58
  elsif defined?(Oj)
45
59
  def json_load(response, *args); Oj.load(response.to_s, *args); end
46
- def json_dump(*args); Oj.dump(*args); end
60
+ def json_dump(obj, options = {}); Oj.dump(obj, { mode: :compat }.merge(options)); end
47
61
  elsif defined?(Yajl)
48
62
  def json_load(response, *args); Yajl::Parser.new(*args).parse(response.to_s); end
49
63
  def json_dump(*args); Yajl::Encoder.encode(*args); end
@@ -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
 
@@ -18,6 +19,12 @@ module HTTPX
18
19
  "multipart/form-data; boundary=#{@boundary}"
19
20
  end
20
21
 
22
+ def to_s
23
+ read
24
+ ensure
25
+ rewind
26
+ end
27
+
21
28
  def read(length = nil, outbuf = nil)
22
29
  data = String(outbuf).clear.force_encoding(Encoding::BINARY) if outbuf
23
30
  data ||= "".b
@@ -29,11 +36,14 @@ module HTTPX
29
36
 
30
37
  def rewind
31
38
  form = @form.each_with_object([]) do |(key, val), aux|
32
- val = val.reopen(val.path, File::RDONLY) if val.is_a?(File) && val.closed?
39
+ if val.respond_to?(:path) && val.respond_to?(:reopen) && val.respond_to?(:closed?) && val.closed?
40
+ val = val.reopen(val.path, File::RDONLY)
41
+ end
33
42
  val.rewind if val.respond_to?(:rewind)
34
43
  aux << [key, val]
35
44
  end
36
45
  @form = form
46
+ @bytesize = 0
37
47
  @parts = to_parts(form)
38
48
  @part_index = 0
39
49
  end
@@ -41,7 +51,6 @@ module HTTPX
41
51
  private
42
52
 
43
53
  def to_parts(form)
44
- @bytesize = 0
45
54
  params = form.each_with_object([]) do |(key, val), aux|
46
55
  Transcoder.normalize_keys(key, val, MULTIPART_VALUE_COND) do |k, v|
47
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
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "forwardable"
4
3
  require_relative "body_reader"
5
4
 
6
5
  module HTTPX
7
6
  module Transcoder
8
7
  class Deflater
9
- extend Forwardable
10
-
11
8
  attr_reader :content_type
12
9
 
13
10
  def initialize(body)
@@ -51,6 +48,12 @@ module HTTPX
51
48
  @closed = true
52
49
  end
53
50
 
51
+ def rewind
52
+ return unless @buffer
53
+
54
+ @buffer.rewind
55
+ end
56
+
54
57
  private
55
58
 
56
59
  # rubocop:disable Naming/MemoizedInstanceVariableName
@@ -62,7 +65,7 @@ module HTTPX
62
65
  )
63
66
  ::IO.copy_stream(self, buffer)
64
67
 
65
- buffer.rewind
68
+ buffer.rewind if buffer.respond_to?(:rewind)
66
69
 
67
70
  @buffer = buffer
68
71
  end
@@ -86,7 +86,6 @@ end
86
86
  require "httpx/transcoder/body"
87
87
  require "httpx/transcoder/form"
88
88
  require "httpx/transcoder/json"
89
- require "httpx/transcoder/xml"
90
89
  require "httpx/transcoder/chunker"
91
90
  require "httpx/transcoder/deflate"
92
91
  require "httpx/transcoder/gzip"
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.4.4"
5
5
  end
data/lib/httpx.rb CHANGED
@@ -2,28 +2,11 @@
2
2
 
3
3
  require "httpx/version"
4
4
 
5
- require "httpx/extensions"
6
-
7
- require "httpx/errors"
8
- require "httpx/utils"
9
- require "httpx/punycode"
10
- require "httpx/domain_name"
11
- require "httpx/altsvc"
12
- require "httpx/callbacks"
13
- require "httpx/loggable"
14
- require "httpx/transcoder"
15
- require "httpx/timers"
16
- require "httpx/pool"
17
- require "httpx/headers"
18
- require "httpx/request"
19
- require "httpx/response"
20
- require "httpx/options"
21
- require "httpx/chainable"
22
-
23
5
  # Top-Level Namespace
24
6
  #
25
7
  module HTTPX
26
8
  EMPTY = [].freeze
9
+ EMPTY_HASH = {}.freeze
27
10
 
28
11
  # All plugins should be stored under this module/namespace. Can register and load
29
12
  # plugins.
@@ -53,15 +36,31 @@ module HTTPX
53
36
  m.synchronize { h[name] = mod }
54
37
  end
55
38
  end
56
-
57
- extend Chainable
58
39
  end
59
40
 
41
+ require "httpx/extensions"
42
+
43
+ require "httpx/errors"
44
+ require "httpx/utils"
45
+ require "httpx/punycode"
46
+ require "httpx/domain_name"
47
+ require "httpx/altsvc"
48
+ require "httpx/callbacks"
49
+ require "httpx/loggable"
50
+ require "httpx/transcoder"
51
+ require "httpx/timers"
52
+ require "httpx/pool"
53
+ require "httpx/headers"
54
+ require "httpx/request"
55
+ require "httpx/response"
56
+ require "httpx/options"
57
+ require "httpx/chainable"
58
+
60
59
  require "httpx/session"
61
60
  require "httpx/session_extensions"
62
61
 
63
62
  # load integrations when possible
64
63
 
65
- require "httpx/adapters/datadog" if defined?(DDTrace) || defined?(Datadog)
64
+ require "httpx/adapters/datadog" if defined?(DDTrace) || defined?(Datadog::Tracing)
66
65
  require "httpx/adapters/sentry" if defined?(Sentry)
67
66
  require "httpx/adapters/webmock" if defined?(WebMock)
data/sig/callbacks.rbs CHANGED
@@ -4,9 +4,8 @@ module HTTPX
4
4
  end
5
5
 
6
6
  module Callbacks
7
- def on: (Symbol) { (*untyped) -> void } -> self
8
- def once: (Symbol) { (*untyped) -> void } -> self
9
- def only: (Symbol) { (*untyped) -> void } -> self
7
+ def on: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
8
+ def once: (Symbol) { (*untyped) -> void } -> ^(*untyped) -> void
10
9
  def emit: (Symbol, *untyped) -> void
11
10
 
12
11
  def callbacks_for?: (Symbol) -> bool
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
@@ -35,6 +35,10 @@ module HTTPX
35
35
  | (:circuit_breaker, ?options) -> Plugins::sessionCircuitBreaker
36
36
  | (:oauth, ?options) -> Plugins::sessionOAuth
37
37
  | (:callbacks, ?options) -> Plugins::sessionCallbacks
38
+ | (:content_digest, ?options) -> Plugins::sessionContentDigest
39
+ | (:ssrf_filter, ?options) -> Plugins::sessionSsrf
40
+ | (:webdav, ?options) -> Plugins::sessionWebDav
41
+ | (:xml, ?options) -> Plugins::sessionXML
38
42
  | (Symbol | Module, ?options) { (Class) -> void } -> Session
39
43
  | (Symbol | Module, ?options) -> Session
40
44
 
@@ -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,9 +5,10 @@ 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
+ @connection: HTTP2::Client
11
12
  @options: Options
12
13
  @settings: Hash[Symbol, Integer | bool]
13
14
  @max_concurrent_requests: Integer
@@ -28,11 +29,11 @@ module HTTPX
28
29
 
29
30
  def can_buffer_more_requests?: () -> bool
30
31
 
31
- def send: (Request) -> void
32
+ def send: (Request request, ?bool head) -> bool
32
33
 
33
34
  def consume: () -> void
34
35
 
35
- def handle_error: (StandardError ex) -> void
36
+ def handle_error: (StandardError ex, ?Request? request) -> void
36
37
 
37
38
  def ping: () -> void
38
39
 
@@ -42,35 +43,35 @@ module HTTPX
42
43
 
43
44
  private
44
45
 
45
- def initialize: (Buffer, options) -> untyped
46
+ def initialize: (Buffer buffer, Options options) -> untyped
46
47
 
47
48
  def send_pending: () -> void
48
49
 
49
50
  def set_protocol_headers: (Request) -> _Each[[String, String]]
50
51
 
51
- def handle: (Request request, HTTP2Next::Stream stream) -> void
52
+ def handle: (Request request, ::HTTP2::Stream stream) -> void
52
53
 
53
54
  def init_connection: () -> void
54
55
 
55
- def handle_stream: (HTTP2Next::Stream stream, Request request) -> void
56
+ def handle_stream: (::HTTP2::Stream stream, Request request) -> void
56
57
 
57
58
  def join_headline: (Request request) -> String
58
59
 
59
- def join_headers: (HTTP2Next::Stream stream, Request request) -> void
60
+ def join_headers: (::HTTP2::Stream stream, Request request) -> void
60
61
 
61
- def join_trailers: (HTTP2Next::Stream stream, Request request) -> void
62
+ def join_trailers: (::HTTP2::Stream stream, Request request) -> void
62
63
 
63
- def join_body: (HTTP2Next::Stream stream, Request request) -> void
64
+ def join_body: (::HTTP2::Stream stream, Request request) -> void
64
65
 
65
- def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
66
+ def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
66
67
 
67
- def on_stream_trailers: (HTTP2Next::Stream stream, Response response, Array[[String, String]] headers) -> void
68
+ def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
68
69
 
69
- def on_stream_data: (HTTP2Next::Stream stream, Request request, String data) -> void
70
+ def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
70
71
 
71
- def on_stream_refuse: (HTTP2Next::Stream stream, Request request, StandardError error) -> void
72
+ def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
72
73
 
73
- def on_stream_close: (HTTP2Next::Stream stream, Request request, (Symbol | StandardError)? error) -> void
74
+ def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
74
75
 
75
76
  def on_frame: (string bytes) -> void
76
77
 
@@ -78,13 +79,13 @@ module HTTPX
78
79
 
79
80
  def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
80
81
 
81
- def on_frame_sent: (HTTP2Next::frame) -> void
82
+ def on_frame_sent: (::HTTP2::frame) -> void
82
83
 
83
- def on_frame_received: (HTTP2Next::frame) -> void
84
+ def on_frame_received: (::HTTP2::frame) -> void
84
85
 
85
- def on_altsvc: (String origin, HTTP2Next::frame) -> void
86
+ def on_altsvc: (String origin, ::HTTP2::frame) -> void
86
87
 
87
- def on_promise: (HTTP2Next::Stream) -> void
88
+ def on_promise: (::HTTP2::Stream) -> void
88
89
 
89
90
  def on_origin: (String) -> void
90
91
 
@@ -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,10 +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_writer timers: Timers
30
-
29
+ attr_reader sibling: instance?
30
+ attr_writer current_selector: Selector?
31
+ attr_accessor current_session: Session?
31
32
  attr_accessor family: Integer?
32
33
 
34
+
33
35
  @window_size: Integer
34
36
  @read_buffer: Buffer
35
37
  @write_buffer: Buffer
@@ -41,10 +43,17 @@ module HTTPX
41
43
  @parser: Object & _Parser
42
44
  @connected_at: Float
43
45
  @response_received_at: Float
44
- @intervals: Array[Timers::Interval]
46
+ @exhausted: bool
47
+ @cloned: bool
48
+ @coalesced_connection: instance?
49
+ @sibling: instance?
50
+ @main_sibling: bool
51
+
45
52
 
46
53
  def addresses: () -> Array[ipaddr]?
47
54
 
55
+ def peer: () -> URI::Generic
56
+
48
57
  def addresses=: (Array[ipaddr] addresses) -> void
49
58
 
50
59
  def send: (Request request) -> void
@@ -57,7 +66,7 @@ module HTTPX
57
66
 
58
67
  def coalescable?: (Connection connection) -> bool
59
68
 
60
- def create_idle: (?Hash[Symbol, untyped] options) -> Connection
69
+ def create_idle: (?Hash[Symbol, untyped] options) -> instance
61
70
 
62
71
  def merge: (Connection connection) -> void
63
72
 
@@ -65,6 +74,8 @@ module HTTPX
65
74
 
66
75
  def connecting?: () -> bool
67
76
 
77
+ def io_connected?: () -> bool
78
+
68
79
  def inflight?: () -> boolish
69
80
 
70
81
  def interests: () -> io_interests?
@@ -77,6 +88,8 @@ module HTTPX
77
88
 
78
89
  def close: () -> void
79
90
 
91
+ def force_reset: (?bool cloned) -> void
92
+
80
93
  def reset: () -> void
81
94
 
82
95
  def timeout: () -> Numeric?
@@ -91,11 +104,19 @@ module HTTPX
91
104
 
92
105
  def handle_socket_timeout: (Numeric interval) -> void
93
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
+
94
115
  private
95
116
 
96
- def initialize: (http_uri uri, options) -> void
117
+ def initialize: (http_uri uri, Options options) -> void
97
118
 
98
- def initialize_type: (http_uri uri, Options) -> io_type
119
+ def initialize_type: (http_uri uri, Options options) -> io_type
99
120
 
100
121
  def connect: () -> void
101
122
 
@@ -117,21 +138,31 @@ module HTTPX
117
138
 
118
139
  def handle_transition: (Symbol nextstate) -> void
119
140
 
141
+ def build_altsvc_connection: (URI::Generic alt_origin, String origin, Hash[String, String] alt_params) -> void
142
+
120
143
  def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
121
144
 
122
- def on_error: (HTTPX::TimeoutError | Error | StandardError error) -> void
145
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
146
+
147
+ def handle_error: (StandardError error, ?Request? request) -> void
123
148
 
124
- def handle_error: (StandardError error) -> void
149
+ def close_sibling: () -> void
125
150
 
126
151
  def purge_after_closed: () -> void
127
152
 
128
153
  def set_request_timeouts: (Request request) -> void
129
154
 
155
+ def set_request_read_timeout: (Request request) -> void
156
+
157
+ def set_request_write_timeout: (Request request) -> void
158
+
159
+ def set_request_request_timeout: (Request request) -> void
160
+
130
161
  def write_timeout_callback: (Request request, Numeric write_timeout) -> void
131
162
 
132
163
  def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
133
164
 
134
- 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
135
166
 
136
167
  def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
137
168
  end
data/sig/errors.rbs CHANGED
@@ -17,6 +17,12 @@ module HTTPX
17
17
  def initialize: (Numeric timeout, String message) -> untyped
18
18
  end
19
19
 
20
+ class PoolTimeoutError < TimeoutError
21
+ attr_reader origin: String
22
+
23
+ def initialize: (String origin, Numeric timeout) -> void
24
+ end
25
+
20
26
  class ConnectTimeoutError < TimeoutError
21
27
  end
22
28
 
@@ -39,6 +45,9 @@ module HTTPX
39
45
  class WriteTimeoutError < RequestTimeoutError
40
46
  end
41
47
 
48
+ class OperationTimeoutError < TimeoutError
49
+ end
50
+
42
51
  class ResolveError < Error
43
52
  end
44
53
 
@@ -58,7 +67,4 @@ module HTTPX
58
67
 
59
68
  def initialize: (Connection connection, String hostname, ?String message) -> untyped
60
69
  end
61
-
62
- class MisdirectedRequestError < HTTPError
63
- end
64
70
  end
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/loggable.rbs CHANGED
@@ -4,10 +4,12 @@ module HTTPX
4
4
  end
5
5
 
6
6
  module Loggable
7
+ USE_DEBUG_LOGS: bool
8
+
7
9
  COLORS: Hash[Symbol, Integer]
8
10
 
9
- def log: (?level: Integer?, ?color: Symbol?) { () -> String } -> void
11
+ def log: (?level: Integer?, ?color: Symbol?, ?debug_level: Integer, ?debug: _IOLogger?) { () -> String } -> void
10
12
 
11
- 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
12
14
  end
13
15
  end
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
@@ -89,6 +77,8 @@ module HTTPX
89
77
  # classes
90
78
  attr_reader connection_class: singleton(Connection)
91
79
 
80
+ attr_reader pool_class: singleton(Pool)
81
+
92
82
  attr_reader request_class: singleton(Request)
93
83
 
94
84
  attr_reader response_class: singleton(Response)
@@ -122,6 +112,9 @@ module HTTPX
122
112
  # resolver_options
123
113
  attr_reader resolver_options: Hash[Symbol, untyped]
124
114
 
115
+ # resolver_options
116
+ attr_reader pool_options: pool_options
117
+
125
118
  # ip_families
126
119
  attr_reader ip_families: Array[ip_family]
127
120
 
@@ -142,6 +135,8 @@ module HTTPX
142
135
  def initialize: (?options options) -> void
143
136
 
144
137
  def do_initialize: (?options options) -> void
138
+
139
+ def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
145
140
  end
146
141
 
147
142
  type options = Options | Hash[Symbol, untyped]
@@ -17,8 +17,14 @@ module HTTPX
17
17
 
18
18
 
19
19
  class Signer
20
-
20
+ @credentials: Object & _SigV4Credentials
21
+ @service: String
22
+ @region: String
21
23
  @unsigned_headers: Set[String]
24
+ @apply_checksum_header: bool
25
+ @provider_prefix: String
26
+ @header_provider_field: String
27
+ @algorithm: String
22
28
 
23
29
  def sign!: (Request & RequestMethods request) -> void
24
30
 
@@ -41,7 +47,7 @@ module HTTPX
41
47
  ) -> untyped
42
48
 
43
49
 
44
- def hexdigest: (bodyIO value) -> String
50
+ def hexdigest: (Request::Body value) -> String
45
51
 
46
52
  def hmac: (String key, String value) -> String
47
53