httpx 1.6.3 → 1.7.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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_11_0.md +3 -3
  3. data/doc/release_notes/1_6_3.md +2 -2
  4. data/doc/release_notes/1_7_0.md +149 -0
  5. data/doc/release_notes/1_7_1.md +21 -0
  6. data/lib/httpx/adapters/datadog.rb +1 -1
  7. data/lib/httpx/adapters/faraday.rb +1 -1
  8. data/lib/httpx/adapters/webmock.rb +18 -9
  9. data/lib/httpx/altsvc.rb +4 -2
  10. data/lib/httpx/connection/http1.rb +9 -9
  11. data/lib/httpx/connection/http2.rb +2 -0
  12. data/lib/httpx/connection.rb +7 -9
  13. data/lib/httpx/domain_name.rb +1 -1
  14. data/lib/httpx/headers.rb +2 -2
  15. data/lib/httpx/io/tcp.rb +1 -1
  16. data/lib/httpx/loggable.rb +2 -0
  17. data/lib/httpx/options.rb +118 -22
  18. data/lib/httpx/parser/http1.rb +1 -0
  19. data/lib/httpx/plugins/auth/digest.rb +44 -4
  20. data/lib/httpx/plugins/auth.rb +113 -4
  21. data/lib/httpx/plugins/aws_sdk_authentication.rb +0 -1
  22. data/lib/httpx/plugins/cookies/cookie.rb +1 -0
  23. data/lib/httpx/plugins/digest_auth.rb +4 -5
  24. data/lib/httpx/plugins/fiber_concurrency.rb +16 -1
  25. data/lib/httpx/plugins/grpc/grpc_encoding.rb +1 -1
  26. data/lib/httpx/plugins/grpc.rb +2 -2
  27. data/lib/httpx/plugins/internal_telemetry.rb +1 -1
  28. data/lib/httpx/plugins/ntlm_auth.rb +5 -3
  29. data/lib/httpx/plugins/oauth.rb +156 -57
  30. data/lib/httpx/plugins/persistent.rb +3 -5
  31. data/lib/httpx/plugins/proxy/http.rb +0 -4
  32. data/lib/httpx/plugins/proxy.rb +3 -1
  33. data/lib/httpx/plugins/query.rb +1 -1
  34. data/lib/httpx/plugins/rate_limiter.rb +20 -15
  35. data/lib/httpx/plugins/response_cache.rb +3 -7
  36. data/lib/httpx/plugins/retries.rb +60 -24
  37. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  38. data/lib/httpx/plugins/stream.rb +60 -9
  39. data/lib/httpx/plugins/stream_bidi.rb +84 -16
  40. data/lib/httpx/pool.rb +12 -3
  41. data/lib/httpx/request/body.rb +1 -1
  42. data/lib/httpx/request.rb +10 -1
  43. data/lib/httpx/resolver/cache/base.rb +136 -0
  44. data/lib/httpx/resolver/cache/memory.rb +42 -0
  45. data/lib/httpx/resolver/cache.rb +18 -0
  46. data/lib/httpx/resolver/https.rb +74 -20
  47. data/lib/httpx/resolver/multi.rb +10 -2
  48. data/lib/httpx/resolver/native.rb +32 -6
  49. data/lib/httpx/resolver/resolver.rb +3 -3
  50. data/lib/httpx/resolver.rb +36 -114
  51. data/lib/httpx/response/body.rb +5 -3
  52. data/lib/httpx/response.rb +22 -6
  53. data/lib/httpx/selector.rb +14 -3
  54. data/lib/httpx/session.rb +6 -6
  55. data/lib/httpx/timers.rb +6 -12
  56. data/lib/httpx/transcoder/body.rb +1 -1
  57. data/lib/httpx/transcoder/gzip.rb +7 -2
  58. data/lib/httpx/transcoder/json.rb +1 -1
  59. data/lib/httpx/transcoder/multipart/decoder.rb +5 -5
  60. data/lib/httpx/transcoder/multipart/encoder.rb +1 -1
  61. data/lib/httpx/transcoder/multipart.rb +17 -9
  62. data/lib/httpx/transcoder.rb +4 -6
  63. data/lib/httpx/utils.rb +13 -0
  64. data/lib/httpx/version.rb +1 -1
  65. data/sig/altsvc.rbs +9 -3
  66. data/sig/chainable.rbs +3 -3
  67. data/sig/connection.rbs +1 -3
  68. data/sig/loggable.rbs +1 -1
  69. data/sig/options.rbs +12 -4
  70. data/sig/plugins/auth/digest.rbs +6 -0
  71. data/sig/plugins/auth.rbs +37 -4
  72. data/sig/plugins/basic_auth.rbs +3 -3
  73. data/sig/plugins/digest_auth.rbs +2 -4
  74. data/sig/plugins/fiber_concurrency.rbs +6 -0
  75. data/sig/plugins/ntlm_auth.rbs +2 -2
  76. data/sig/plugins/oauth.rbs +44 -15
  77. data/sig/plugins/rate_limiter.rbs +4 -2
  78. data/sig/plugins/response_cache/file_store.rbs +2 -0
  79. data/sig/plugins/response_cache.rbs +4 -0
  80. data/sig/plugins/retries.rbs +12 -4
  81. data/sig/plugins/stream.rbs +13 -3
  82. data/sig/plugins/stream_bidi.rbs +2 -2
  83. data/sig/pool.rbs +1 -1
  84. data/sig/resolver/cache/base.rbs +28 -0
  85. data/sig/resolver/cache/memory.rbs +13 -0
  86. data/sig/resolver/cache.rbs +16 -0
  87. data/sig/resolver/https.rbs +24 -0
  88. data/sig/resolver/multi.rbs +8 -0
  89. data/sig/resolver/native.rbs +2 -0
  90. data/sig/resolver.rbs +5 -20
  91. data/sig/response.rbs +3 -0
  92. data/sig/session.rbs +3 -5
  93. data/sig/timers.rbs +1 -1
  94. data/sig/transcoder/multipart.rbs +4 -2
  95. data/sig/transcoder.rbs +5 -1
  96. data/sig/utils.rbs +2 -0
  97. metadata +11 -1
data/lib/httpx/session.rb CHANGED
@@ -177,6 +177,7 @@ module HTTPX
177
177
 
178
178
  # returns the HTTPX::Connection through which the +request+ should be sent through.
179
179
  def find_connection(request_uri, selector, options)
180
+ log(level: 2) { "finding connection for #{request_uri}..." }
180
181
  if (connection = selector.find_connection(request_uri, options))
181
182
  connection.idling if connection.state == :closed
182
183
  connection.log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
@@ -224,7 +225,7 @@ module HTTPX
224
225
 
225
226
  # tries deactivating connections in the +selector+, deregistering the ones that have been deactivated.
226
227
  def deactivate(selector)
227
- selector.each_connection.each(&:deactivate)
228
+ selector.each_connection.to_a.each(&:deactivate)
228
229
  end
229
230
 
230
231
  # callback executed when an HTTP/2 promise frame has been received.
@@ -415,12 +416,12 @@ module HTTPX
415
416
 
416
417
  def find_resolver_for(connection, selector)
417
418
  if (resolver = selector.find_resolver(connection.options))
418
- resolver.log(level: 2) { "found resolver##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
419
+ resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in selector##{selector.object_id}" }
419
420
  return resolver
420
421
  end
421
422
 
422
423
  resolver = @pool.checkout_resolver(connection.options)
423
- resolver.log(level: 2) { "found resolver##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
424
+ resolver.log(level: 2) { "found resolver##{resolver.object_id}(#{resolver.state}) in pool##{@pool.object_id}" }
424
425
  pin(resolver, selector)
425
426
 
426
427
  resolver
@@ -436,14 +437,13 @@ module HTTPX
436
437
  conn1.log(level: 2) { "check-in connection##{conn1.object_id}(#{conn1.state}) in pool##{@pool.object_id}" }
437
438
  @pool.checkin_connection(conn1)
438
439
  end
439
- return false
440
+ return
440
441
  end
441
442
 
442
443
  conn2.log(level: 2) { "coalescing with connection##{conn1.object_id}[#{conn1.origin}])" }
443
444
  select_connection(conn1, selector) if from_pool
444
445
  conn2.coalesce!(conn1)
445
446
  conn2.disconnect
446
- true
447
447
  end
448
448
 
449
449
  def get_current_selector
@@ -472,6 +472,7 @@ module HTTPX
472
472
  th.thread_variable_get(:httpx_persistent_selector_store)
473
473
  end
474
474
 
475
+ Options.freeze
475
476
  @default_options = Options.new
476
477
  @default_options.freeze
477
478
  @plugins = []
@@ -493,7 +494,6 @@ module HTTPX
493
494
  #
494
495
  def plugin(pl, options = nil, &block)
495
496
  label = pl
496
- # raise Error, "Cannot add a plugin to a frozen config" if frozen?
497
497
  pl = Plugins.load_plugin(pl) if pl.is_a?(Symbol)
498
498
  raise ArgumentError, "Invalid plugin type: #{pl.class.inspect}" unless pl.is_a?(Module)
499
499
 
data/lib/httpx/timers.rb CHANGED
@@ -29,13 +29,15 @@ module HTTPX
29
29
  end
30
30
 
31
31
  def wait_interval
32
- drop_elapsed!
33
-
34
32
  return if @intervals.empty?
35
33
 
34
+ first_interval = @intervals.first
35
+
36
+ drop_elapsed!(0) if first_interval.elapsed?(0)
37
+
36
38
  @next_interval_at = Utils.now
37
39
 
38
- @intervals.first.interval
40
+ first_interval.interval
39
41
  end
40
42
 
41
43
  def fire(error = nil)
@@ -46,20 +48,12 @@ module HTTPX
46
48
 
47
49
  drop_elapsed!(elapsed_time)
48
50
 
49
- @intervals = @intervals.drop_while { |interval| interval.elapse(elapsed_time) <= 0 }
50
-
51
51
  @next_interval_at = nil if @intervals.empty?
52
52
  end
53
53
 
54
54
  private
55
55
 
56
- def drop_elapsed!(elapsed_time = 0)
57
- # check first, if not elapsed, then return
58
- first_interval = @intervals.first
59
-
60
- return unless first_interval && first_interval.elapsed?(elapsed_time)
61
-
62
- # TODO: would be nice to have a drop_while!
56
+ def drop_elapsed!(elapsed_time)
63
57
  @intervals = @intervals.drop_while { |interval| interval.elapse(elapsed_time) <= 0 }
64
58
  end
65
59
 
@@ -12,7 +12,7 @@ module HTTPX::Transcoder
12
12
  def initialize(body)
13
13
  body = body.open(File::RDONLY, encoding: Encoding::BINARY) if Object.const_defined?(:Pathname) && body.is_a?(Pathname)
14
14
  @body = body
15
- super(body)
15
+ super
16
16
  end
17
17
 
18
18
  def bytesize
@@ -8,6 +8,7 @@ module HTTPX
8
8
  class Deflater < Transcoder::Deflater
9
9
  def initialize(body)
10
10
  @compressed_chunk = "".b
11
+ @deflater = nil
11
12
  super
12
13
  end
13
14
 
@@ -28,8 +29,12 @@ module HTTPX
28
29
 
29
30
  private
30
31
 
31
- def write(chunk)
32
- @compressed_chunk << chunk
32
+ def write(*chunks)
33
+ chunks.sum do |chunk|
34
+ chunk = chunk.to_s
35
+ @compressed_chunk << chunk
36
+ chunk.bytesize
37
+ end
33
38
  end
34
39
 
35
40
  def compressed_chunk
@@ -64,7 +64,7 @@ module HTTPX::Transcoder
64
64
  else
65
65
  require "json"
66
66
  def json_load(*args); ::JSON.parse(*args); end
67
- def json_dump(*args); ::JSON.dump(*args); end
67
+ def json_dump(*args); ::JSON.generate(*args); end
68
68
  end
69
69
  # rubocop:enable Style/SingleLineMethods
70
70
  end
@@ -12,7 +12,6 @@ module HTTPX
12
12
  def initialize(filename, content_type)
13
13
  @original_filename = filename
14
14
  @content_type = content_type
15
- @current = nil
16
15
  @file = Tempfile.new("httpx", encoding: Encoding::BINARY, mode: File::RDWR)
17
16
  super(@file)
18
17
  end
@@ -39,6 +38,7 @@ module HTTPX
39
38
  @parts = {}
40
39
  @intermediate_boundary = "--#{@boundary}"
41
40
  @state = :idle
41
+ @current = nil
42
42
  end
43
43
 
44
44
  def call(response, *)
@@ -60,7 +60,7 @@ module HTTPX
60
60
  when :idle
61
61
  raise Error, "payload does not start with boundary" unless @buffer.start_with?("#{@intermediate_boundary}#{CRLF}")
62
62
 
63
- @buffer = @buffer.byteslice(@intermediate_boundary.bytesize + 2..-1)
63
+ @buffer = @buffer.byteslice((@intermediate_boundary.bytesize + 2)..-1)
64
64
 
65
65
  @state = :part_header
66
66
  when :part_header
@@ -70,7 +70,7 @@ module HTTPX
70
70
  return unless idx
71
71
 
72
72
  # @type var head: String
73
- head = @buffer.byteslice(0..idx + 4 - 1)
73
+ head = @buffer.byteslice(0..(idx + 4 - 1))
74
74
 
75
75
  @buffer = @buffer.byteslice(head.bytesize..-1)
76
76
 
@@ -107,8 +107,8 @@ module HTTPX
107
107
  idx = @buffer.index(body_separator)
108
108
 
109
109
  if idx
110
- payload = @buffer.byteslice(0..idx - 1)
111
- @buffer = @buffer.byteslice(idx + body_separator.bytesize..-1)
110
+ payload = @buffer.byteslice(0..(idx - 1))
111
+ @buffer = @buffer.byteslice((idx + body_separator.bytesize)..-1)
112
112
  part << payload
113
113
  part.rewind if part.respond_to?(:rewind)
114
114
  @state = :parse_boundary
@@ -53,7 +53,7 @@ module HTTPX
53
53
 
54
54
  def to_parts(form)
55
55
  params = form.each_with_object([]) do |(key, val), aux|
56
- Transcoder.normalize_keys(key, val, MULTIPART_VALUE_COND) do |k, v|
56
+ Transcoder::Multipart.normalize_keys(key, val) do |k, v|
57
57
  next if v.nil?
58
58
 
59
59
  value, content_type, filename = Part.call(v)
@@ -7,20 +7,28 @@ require_relative "multipart/mime_type_detector"
7
7
 
8
8
  module HTTPX::Transcoder
9
9
  module Multipart
10
- MULTIPART_VALUE_COND = lambda do |value|
10
+ module_function
11
+
12
+ def multipart?(form_data)
13
+ form_data.any? do |_, v|
14
+ multipart_value?(v) ||
15
+ (v.respond_to?(:to_ary) && v.to_ary.any? { |av| multipart_value?(av) }) ||
16
+ (v.respond_to?(:to_hash) && v.to_hash.any? { |_, e| multipart_value?(e) })
17
+ end
18
+ end
19
+
20
+ def multipart_value?(value)
11
21
  value.respond_to?(:read) ||
12
- (value.respond_to?(:to_hash) &&
22
+ (value.is_a?(Hash) &&
13
23
  value.key?(:body) &&
14
24
  (value.key?(:filename) || value.key?(:content_type)))
15
25
  end
16
26
 
17
- module_function
18
-
19
- def multipart?(form_data)
20
- form_data.any? do |_, v|
21
- Multipart::MULTIPART_VALUE_COND.call(v) ||
22
- (v.respond_to?(:to_ary) && v.to_ary.any?(&Multipart::MULTIPART_VALUE_COND)) ||
23
- (v.respond_to?(:to_hash) && v.to_hash.any? { |_, e| Multipart::MULTIPART_VALUE_COND.call(e) })
27
+ def normalize_keys(key, value, transcoder = self, &block)
28
+ if multipart_value?(value)
29
+ block.call(key.to_s, value)
30
+ else
31
+ HTTPX::Transcoder.normalize_keys(key, value, transcoder, &block)
24
32
  end
25
33
  end
26
34
 
@@ -4,20 +4,18 @@ module HTTPX
4
4
  module Transcoder
5
5
  module_function
6
6
 
7
- def normalize_keys(key, value, cond = nil, &block)
8
- if cond && cond.call(value)
9
- block.call(key.to_s, value)
10
- elsif value.respond_to?(:to_ary)
7
+ def normalize_keys(key, value, transcoder = self, &block)
8
+ if value.respond_to?(:to_ary)
11
9
  if value.empty?
12
10
  block.call("#{key}[]")
13
11
  else
14
12
  value.to_ary.each do |element|
15
- normalize_keys("#{key}[]", element, cond, &block)
13
+ transcoder.normalize_keys("#{key}[]", element, transcoder, &block)
16
14
  end
17
15
  end
18
16
  elsif value.respond_to?(:to_hash)
19
17
  value.to_hash.each do |child_key, child_value|
20
- normalize_keys("#{key}[#{child_key}]", child_value, cond, &block)
18
+ transcoder.normalize_keys("#{key}[#{child_key}]", child_value, transcoder, &block)
21
19
  end
22
20
  else
23
21
  block.call(key.to_s, value)
data/lib/httpx/utils.rb CHANGED
@@ -71,5 +71,18 @@ module HTTPX
71
71
  uri.non_ascii_hostname = non_ascii_hostname
72
72
  uri
73
73
  end
74
+
75
+ if defined?(Ractor) &&
76
+ # no ractor support for 3.0
77
+ RUBY_VERSION >= "3.1.0"
78
+
79
+ def in_ractor?
80
+ Ractor.main != Ractor.current
81
+ end
82
+ else
83
+ def in_ractor?
84
+ false
85
+ end
86
+ end
74
87
  end
75
88
  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.6.3"
4
+ VERSION = "1.7.1"
5
5
  end
data/sig/altsvc.rbs CHANGED
@@ -1,20 +1,26 @@
1
1
  module HTTPX
2
2
  module AltSvc
3
3
  module ConnectionMixin
4
+ H2_ALTSVC_SCHEMES: Array[String]
4
5
 
5
6
  def send: (Request request) -> void
6
7
 
7
- def match?: (URI::Generic uri, Options options) -> bool
8
+ def match?: (http_uri uri, Options options) -> bool
8
9
 
9
10
  private
10
11
 
11
- def match_altsvcs?: (URI::Generic uri) -> bool
12
+ def match_altsvcs?: (http_uri uri) -> bool
12
13
 
13
- def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
14
+ def match_altsvc_options?: (http_uri uri, Options options) -> bool
15
+
16
+ def altsvc_match?: (http_uri uri, uri other_uri) -> bool
14
17
  end
15
18
 
16
19
  type altsvc_params = Hash[String, untyped]
17
20
 
21
+ self.@altsvc_mutex: Thread::Mutex
22
+ self.@altsvcs: Hash[String, Array[altsvc_params]]
23
+
18
24
  def self?.cached_altsvc: (String origin) -> Array[altsvc_params]
19
25
 
20
26
  def self?.cached_altsvc_set: (String origin, altsvc_params) -> void
data/sig/chainable.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Chainable
3
- def request: (*Request, **untyped) -> Array[response]
4
- | (Request, **untyped) -> response
3
+ def request: (Request, **untyped) -> response
4
+ | (*Request, **untyped) -> Array[response]
5
5
  | (verb, uri | [uri], **untyped) -> response
6
6
  | (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
7
7
  | (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
@@ -12,7 +12,7 @@ module HTTPX
12
12
  def with: (options) -> Session
13
13
  | (options) { (Session) -> void } -> void
14
14
 
15
- def plugin: (:auth, ?options) -> Plugins::sessionAuthorization
15
+ def plugin: (:auth, ?options) -> Plugins::sessionAuth
16
16
  | (:basic_auth, ?options) -> Plugins::sessionBasicAuth
17
17
  | (:digest_auth, ?options) -> Plugins::sessionDigestAuth
18
18
  | (:ntlm_auth, ?options) -> Plugins::sessionNTLMAuth
data/sig/connection.rbs CHANGED
@@ -61,7 +61,7 @@ module HTTPX
61
61
 
62
62
  def addresses?: () -> boolish
63
63
 
64
- def match?: (URI::Generic uri, Options options) -> bool
64
+ def match?: (http_uri uri, Options options) -> bool
65
65
 
66
66
  def mergeable?: (Connection connection) -> bool
67
67
 
@@ -71,8 +71,6 @@ module HTTPX
71
71
 
72
72
  def coalescable?: (Connection connection) -> bool
73
73
 
74
- def create_idle: (?Hash[Symbol, untyped] options) -> instance
75
-
76
74
  def merge: (Connection connection) -> void
77
75
 
78
76
  def purge_pending: () { (Request request) -> void } -> void
data/sig/loggable.rbs CHANGED
@@ -4,7 +4,7 @@ module HTTPX
4
4
  end
5
5
 
6
6
  module Loggable
7
- USE_DEBUG_LOGS: bool
7
+ USE_DEBUG_LOG: bool
8
8
 
9
9
  COLORS: Hash[Symbol, Integer]
10
10
 
data/sig/options.rbs CHANGED
@@ -17,11 +17,13 @@ module HTTPX
17
17
 
18
18
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
19
19
  REQUEST_BODY_IVARS: Array[Symbol]
20
+ RESOLVER_TYPES: Array[Symbol]
20
21
  USER_AGENT: String
21
22
 
22
23
  type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
23
24
  type timeout = Hash[timeout_type, Numeric?]
24
25
  type redact_value = :headers | :body | bool
26
+ type resolver_cache_option = :memory | :file | (Object & Resolver::_Cache)
25
27
 
26
28
  def self.new: (?options) -> instance
27
29
 
@@ -102,8 +104,6 @@ module HTTPX
102
104
 
103
105
  attr_reader options_class: singleton(Options)
104
106
 
105
- attr_reader resolver_class: Symbol | singleton(Resolver::Resolver)
106
-
107
107
  attr_reader ssl: Hash[Symbol, untyped]
108
108
 
109
109
  # io
@@ -134,11 +134,17 @@ module HTTPX
134
134
  # ip_families
135
135
  attr_reader ip_families: Array[ip_family]?
136
136
 
137
+ @resolver_cache: resolver_cache_option
138
+
139
+ def resolver_class: () -> singleton(Resolver::Resolver)
140
+
141
+ def resolver_cache: () -> (Object & Resolver::_Cache)
142
+
137
143
  def ==: (Options other) -> bool
138
144
 
139
145
  def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
140
146
 
141
- def merge: (_ToHash[Symbol, untyped] other) -> instance
147
+ def merge: (Object & _ToHash[Symbol, untyped] other) -> (instance | self)
142
148
 
143
149
  def to_hash: () -> Hash[Symbol, untyped]
144
150
 
@@ -148,7 +154,7 @@ module HTTPX
148
154
 
149
155
  def initialize: (?options options) -> void
150
156
 
151
- def do_initialize: (?options options) -> void
157
+ def do_initialize: () -> void
152
158
 
153
159
  def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
154
160
 
@@ -185,6 +191,8 @@ module HTTPX
185
191
  def option_persistent: (bool value) -> bool
186
192
  def option_close_on_fork: (bool value) -> bool
187
193
 
194
+ def option_resolver_cache: (resolver_cache_option value) -> resolver_cache_option
195
+
188
196
  def option_origin: (http_uri | String value) -> http_uri
189
197
 
190
198
  def option_base_path: (_ToStr value) -> String
@@ -2,9 +2,13 @@ module HTTPX
2
2
  module Plugins
3
3
  module Authentication
4
4
  class Digest
5
+ Error: singleton(HTTPX::Error)
6
+
7
+
5
8
  @user: String
6
9
  @password: String
7
10
  @hashed: bool
11
+ @nonce: Integer
8
12
 
9
13
  def can_authenticate?: (String? authenticate) -> boolish
10
14
 
@@ -19,6 +23,8 @@ module HTTPX
19
23
  def make_cnonce: () -> String
20
24
 
21
25
  def next_nonce: () -> Integer
26
+
27
+ def raise_format_error: () -> void
22
28
  end
23
29
  end
24
30
  end
data/sig/plugins/auth.rbs CHANGED
@@ -1,13 +1,46 @@
1
1
  module HTTPX
2
2
  module Plugins
3
- module Authorization
3
+ module Auth
4
+ type auth_header_value_type = String | ^(Request request) -> string
5
+
6
+ interface _AuthOptions
7
+ def auth_header_value: () -> auth_header_value_type?
8
+
9
+ def auth_header_type: () -> String?
10
+ end
11
+
4
12
  module InstanceMethods
5
- def authorization: (string token) -> instance
13
+ @auth_header_value: String
14
+ @skip_auth_header_value: bool
15
+
16
+ def authorization: (?string token, ?auth_header_type: string) ?{ (Request) -> string } -> instance
17
+
18
+ def bearer_auth: (?string token) ?{ (Request) -> string } -> instance
19
+
20
+ def skip_auth_header: [T] { () -> T } -> T
21
+
22
+ def reset_auth_header_value!: () -> void
23
+
24
+ private
25
+
26
+ def generate_auth_token: () -> String?
27
+
28
+ def dynamic_auth_token?: (auth_header_value_type auth_header_value) -> boolish
29
+ end
30
+
31
+ module RequestMethods
32
+ def authorize: (String auth_value) -> void
33
+ end
34
+
35
+ module AuthRetries
36
+ module InstanceMethods
37
+ private
6
38
 
7
- def bearer_auth: (string token) -> instance
39
+ def auth_error?: (response response, Options options) -> boolish
40
+ end
8
41
  end
9
42
  end
10
43
 
11
- type sessionAuthorization = Session & Authorization::InstanceMethods
44
+ type sessionAuth = Session & Auth::InstanceMethods
12
45
  end
13
46
  end
@@ -1,15 +1,15 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module BasicAuth
4
- def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session) klass) -> void
5
5
 
6
- def self.configure: (singleton(Session)) -> void
6
+ def self.configure: (singleton(Session) klass) -> void
7
7
 
8
8
  module InstanceMethods
9
9
  def basic_auth: (string user, string password) -> instance
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuth = sessionAuthorization & BasicAuth::InstanceMethods
13
+ type sessionBasicAuth = sessionAuth & BasicAuth::InstanceMethods
14
14
  end
15
15
  end
@@ -1,21 +1,19 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module DigestAuth
4
- DigestError: singleton(Error)
5
-
6
4
  interface _DigestOptions
7
5
  def digest: () -> Authentication::Digest?
8
6
  end
9
7
 
10
8
  def self.extra_options: (Options) -> (Options & _DigestOptions)
11
9
 
12
- def self.load_dependencies: (*untyped) -> void
10
+ def self.load_dependencies: (singleton(Session) klass) -> void
13
11
 
14
12
  module InstanceMethods
15
13
  def digest_auth: (string user, string password, ?hashed: bool) -> instance
16
14
  end
17
15
  end
18
16
 
19
- type sessionDigestAuth = sessionAuthorization & DigestAuth::InstanceMethods
17
+ type sessionDigestAuth = sessionAuth & DigestAuth::InstanceMethods
20
18
  end
21
19
  end
@@ -43,6 +43,12 @@ module HTTPX
43
43
  end
44
44
  end
45
45
 
46
+ module FiberConcurrencyStream
47
+ module StreamResponseMethods
48
+ def close: () -> void
49
+ end
50
+ end
51
+
46
52
  type request = Request & RequestMethods
47
53
  end
48
54
 
@@ -8,7 +8,7 @@ module HTTPX
8
8
 
9
9
  def self.extra_options: (Options) -> (Options & _NTLMOptions)
10
10
 
11
- def self.load_dependencies: (*untyped) -> void
11
+ def self.load_dependencies: (singleton(Session) klass) -> void
12
12
 
13
13
  module InstanceMethods
14
14
  def ntlm_auth: (string user, string password, ?string? domain) -> instance
@@ -16,6 +16,6 @@ module HTTPX
16
16
 
17
17
  end
18
18
 
19
- type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
19
+ type sessionNTLMAuth = sessionAuth & NTLMAuth::InstanceMethods
20
20
  end
21
21
  end