httpx 1.7.7 → 1.8.0

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_7_8.md +5 -0
  3. data/doc/release_notes/1_8_0.md +100 -0
  4. data/lib/httpx/adapters/datadog.rb +3 -1
  5. data/lib/httpx/connection/http1.rb +10 -1
  6. data/lib/httpx/connection/http2.rb +37 -4
  7. data/lib/httpx/connection.rb +76 -7
  8. data/lib/httpx/errors.rb +8 -1
  9. data/lib/httpx/io/tcp.rb +11 -1
  10. data/lib/httpx/options.rb +16 -4
  11. data/lib/httpx/parser/http1.rb +8 -2
  12. data/lib/httpx/plugins/auth.rb +52 -4
  13. data/lib/httpx/plugins/{response_cache → cache}/file_store.rb +1 -1
  14. data/lib/httpx/plugins/{response_cache → cache}/store.rb +1 -1
  15. data/lib/httpx/plugins/cache.rb +221 -0
  16. data/lib/httpx/plugins/fiber_concurrency.rb +50 -3
  17. data/lib/httpx/plugins/ntlm_v2_auth.rb +92 -0
  18. data/lib/httpx/plugins/oauth.rb +66 -14
  19. data/lib/httpx/plugins/proxy.rb +5 -0
  20. data/lib/httpx/plugins/response_cache.rb +26 -105
  21. data/lib/httpx/plugins/retries.rb +13 -5
  22. data/lib/httpx/plugins/server_sent_events.rb +158 -0
  23. data/lib/httpx/plugins/ssrf_filter.rb +16 -1
  24. data/lib/httpx/plugins/stream.rb +7 -3
  25. data/lib/httpx/plugins/tracing.rb +15 -4
  26. data/lib/httpx/request.rb +18 -1
  27. data/lib/httpx/resolver/cache/file.rb +56 -0
  28. data/lib/httpx/resolver/native.rb +14 -3
  29. data/lib/httpx/response/body.rb +4 -2
  30. data/lib/httpx/response.rb +9 -1
  31. data/lib/httpx/selector.rb +7 -1
  32. data/lib/httpx/version.rb +1 -1
  33. data/sig/chainable.rbs +3 -0
  34. data/sig/connection/http1.rbs +1 -1
  35. data/sig/connection/http2.rbs +1 -1
  36. data/sig/connection.rbs +11 -8
  37. data/sig/errors.rbs +9 -3
  38. data/sig/httpx.rbs +2 -0
  39. data/sig/io/tcp.rbs +2 -0
  40. data/sig/loggable.rbs +4 -0
  41. data/sig/options.rbs +25 -12
  42. data/sig/parser/http1.rbs +3 -1
  43. data/sig/plugins/auth/ntlm.rbs +1 -1
  44. data/sig/plugins/{response_cache → cache}/file_store.rbs +2 -2
  45. data/sig/plugins/{response_cache → cache}/store.rbs +2 -2
  46. data/sig/plugins/cache.rbs +69 -0
  47. data/sig/plugins/fiber_concurrency.rbs +4 -0
  48. data/sig/plugins/ntlm_v2_auth.rbs +36 -0
  49. data/sig/plugins/response_cache.rbs +13 -38
  50. data/sig/plugins/retries.rbs +5 -5
  51. data/sig/plugins/server_sent_events.rbs +45 -0
  52. data/sig/plugins/ssrf_filter.rbs +5 -1
  53. data/sig/plugins/stream.rbs +1 -1
  54. data/sig/plugins/stream_bidi.rbs +0 -2
  55. data/sig/plugins/webdav.rbs +1 -1
  56. data/sig/pool.rbs +2 -2
  57. data/sig/request.rbs +7 -3
  58. data/sig/resolver/cache/file.rbs +13 -0
  59. data/sig/resolver/entry.rbs +1 -1
  60. data/sig/resolver/https.rbs +3 -3
  61. data/sig/resolver/multi.rbs +1 -1
  62. data/sig/resolver/native.rbs +5 -5
  63. data/sig/resolver/resolver.rbs +1 -3
  64. data/sig/resolver/system.rbs +2 -2
  65. data/sig/resolver.rbs +3 -0
  66. data/sig/response.rbs +3 -0
  67. data/sig/selector.rbs +11 -8
  68. data/sig/timers.rbs +5 -5
  69. data/sig/transcoder/body.rbs +1 -1
  70. data/sig/transcoder/gzip.rbs +3 -2
  71. data/sig/transcoder/multipart.rbs +4 -1
  72. data/sig/transcoder/utils/deflater.rbs +2 -0
  73. data/sig/transcoder.rbs +2 -0
  74. data/sig/utils.rbs +1 -1
  75. metadata +19 -7
@@ -20,10 +20,10 @@ module HTTPX
20
20
  @headers = response.headers
21
21
  @options = options
22
22
  @window_size = options.window_size
23
+ @max_response_body_size = options.max_response_body_size
23
24
  @encodings = []
24
25
  @length = 0
25
- @buffer = nil
26
- @reader = nil
26
+ @buffer = @reader = nil
27
27
  @state = :idle
28
28
 
29
29
  # initialize response encoding
@@ -59,6 +59,8 @@ module HTTPX
59
59
 
60
60
  chunk = decode_chunk(chunk)
61
61
 
62
+ raise Error, "maximum response body size exceeded" if @max_response_body_size < @length
63
+
62
64
  transition(:open)
63
65
  @buffer.write(chunk)
64
66
 
@@ -68,7 +68,7 @@ module HTTPX
68
68
  @headers = @options.headers_class.new(headers)
69
69
  @body = @options.response_body_class.new(self, @options)
70
70
  @finished = complete?
71
- @content_type = nil
71
+ @content_type = @content_length = nil
72
72
  end
73
73
 
74
74
  # dupped initialization
@@ -88,6 +88,7 @@ module HTTPX
88
88
  # merges headers defined in +h+ into the response headers.
89
89
  def merge_headers(h)
90
90
  @headers = @headers.merge(h)
91
+ @content_type = @content_length = nil
91
92
  end
92
93
 
93
94
  # writes +data+ chunk into the response body.
@@ -103,6 +104,13 @@ module HTTPX
103
104
  @content_type ||= ContentType.new(@headers["content-type"])
104
105
  end
105
106
 
107
+ # returns the response content length as advertised in the HTTP Content-Length header value.
108
+ def content_length
109
+ return @content_length if defined?(@content_length)
110
+
111
+ @content_length = @headers["content-length"]&.to_i
112
+ end
113
+
106
114
  # returns whether the response has been fully fetched.
107
115
  def finished?
108
116
  @finished
@@ -134,7 +134,13 @@ module HTTPX
134
134
  # the connections to be reaped (such as the total timeout error) before #select
135
135
  # gets called.
136
136
  if @selectables.empty?
137
- sleep(interval) if interval
137
+ begin
138
+ sleep(interval)
139
+ rescue IOError
140
+ # @fiber-switch-guard
141
+ # in a fiber scheduler scenario, IOs may be closed by the scheduler and raised in a separate fiber
142
+ # on wakeup, which includes a sleep call.
143
+ end if interval
138
144
  return
139
145
  end
140
146
 
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.7.7"
4
+ VERSION = "1.8.0"
5
5
  end
data/sig/chainable.rbs CHANGED
@@ -16,6 +16,7 @@ module HTTPX
16
16
  | (:basic_auth, ?options) -> Plugins::sessionBasicAuth
17
17
  | (:digest_auth, ?options) -> Plugins::sessionDigestAuth
18
18
  | (:ntlm_auth, ?options) -> Plugins::sessionNTLMAuth
19
+ | (:ntlm_v2_auth, ?options) -> Plugins::sessionNTLMV2Auth
19
20
  | (:aws_sdk_authentication, ?options) -> Plugins::sessionAwsSdkAuthentication
20
21
  | (:brotli, ?options) -> Session
21
22
  | (:cookies, ?options) -> Plugins::sessionCookies
@@ -32,8 +33,10 @@ module HTTPX
32
33
  | (:rate_limiter, ?options) -> Plugins::sessionRateLimiter
33
34
  | (:stream, ?options) -> Plugins::sessionStream
34
35
  | (:stream_bidi, ?options) -> Plugins::sessionStreamBidi
36
+ | (:server_sent_events, ?options) -> Plugins::sessionServerSentEvents
35
37
  | (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
36
38
  | (:grpc, ?options) -> Plugins::grpcSession
39
+ | (:cache, ?options) -> Plugins::sessionCache
37
40
  | (:response_cache, ?options) -> Plugins::sessionResponseCache
38
41
  | (:circuit_breaker, ?options) -> Plugins::sessionCircuitBreaker
39
42
  | (:oauth, ?options) -> Plugins::sessionOAuth
@@ -58,7 +58,7 @@ module HTTPX
58
58
 
59
59
  def waiting_for_ping?: () -> bool
60
60
 
61
- def timeout: () -> Numeric?
61
+ def timeout: () -> interval?
62
62
 
63
63
  private
64
64
 
@@ -42,7 +42,7 @@ module HTTPX
42
42
 
43
43
  alias reset init_connection
44
44
 
45
- def timeout: () -> Numeric?
45
+ def timeout: () -> interval?
46
46
 
47
47
  def reset_requests: () -> void
48
48
 
data/sig/connection.rbs CHANGED
@@ -38,9 +38,9 @@ module HTTPX
38
38
  @write_buffer: Buffer
39
39
  @inflight: Integer
40
40
  @max_concurrent_requests: Integer?
41
- @keep_alive_timeout: Numeric?
42
- @timeout: Numeric?
43
- @current_timeout: Numeric?
41
+ @keep_alive_timeout: interval?
42
+ @timeout: interval?
43
+ @current_timeout: interval?
44
44
  @parser: Object & _Parser
45
45
  @connected_at: Float
46
46
  @response_received_at: Float
@@ -51,6 +51,7 @@ module HTTPX
51
51
  @sibling: instance?
52
52
  @main_sibling: bool
53
53
  @no_more_requests_counter: Integer
54
+ @ping_timer: Timers::Timer?
54
55
 
55
56
 
56
57
  def addresses: () -> Array[Resolver::Entry]?
@@ -101,7 +102,7 @@ module HTTPX
101
102
 
102
103
  def reset: () -> void
103
104
 
104
- def timeout: () -> Numeric?
105
+ def timeout: () -> interval?
105
106
 
106
107
  def idling: () -> void
107
108
 
@@ -111,7 +112,7 @@ module HTTPX
111
112
 
112
113
  def open?: () -> bool
113
114
 
114
- def handle_socket_timeout: (Numeric interval) -> void
115
+ def handle_socket_timeout: (interval interval) -> void
115
116
 
116
117
  def sibling=: (instance? connection) -> void
117
118
 
@@ -157,7 +158,7 @@ module HTTPX
157
158
 
158
159
  def build_socket: (?Array[Resolver::Entry]? addrs) -> (TCP | SSL | UNIX)
159
160
 
160
- def ping: () -> void
161
+ def ping: (Request request) -> void
161
162
 
162
163
  def pong: () -> void
163
164
 
@@ -179,11 +180,13 @@ module HTTPX
179
180
 
180
181
  def set_request_request_timeout: (Request request) -> void
181
182
 
183
+ def set_request_total_request_timeout: (Request request) -> void
184
+
182
185
  def write_timeout_callback: (Request request, Numeric timeout) -> void
183
186
 
184
- def read_timeout_callback: (Request request, Numeric timeout, ?singleton(RequestTimeoutError) error_type) -> void
187
+ def read_timeout_callback: (Request request, interval timeout, ?singleton(RequestTimeoutError) error_type) -> void
185
188
 
186
- def set_request_timeout: (Symbol label, Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
189
+ def set_request_timeout: (Symbol label, Request request, interval timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
187
190
 
188
191
  def parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
189
192
  end
data/sig/errors.rbs CHANGED
@@ -9,12 +9,12 @@ module HTTPX
9
9
  end
10
10
 
11
11
  class TimeoutError < Error
12
- attr_reader timeout: Numeric
12
+ attr_reader timeout: interval
13
13
 
14
14
  def to_connection_error: () -> ConnectTimeoutError
15
15
  private
16
16
 
17
- def initialize: (Numeric timeout, String message) -> untyped
17
+ def initialize: (interval timeout, String message) -> untyped
18
18
  end
19
19
 
20
20
  class PoolTimeoutError < TimeoutError
@@ -33,7 +33,7 @@ module HTTPX
33
33
  attr_reader request: Request
34
34
  attr_reader response: response?
35
35
 
36
- def initialize: (Request request, response? response, Numeric timeout) -> void
36
+ def initialize: (Request request, response? response, interval timeout) -> void
37
37
  end
38
38
 
39
39
  class ReadTimeoutError < RequestTimeoutError
@@ -42,9 +42,15 @@ module HTTPX
42
42
  class WriteTimeoutError < RequestTimeoutError
43
43
  end
44
44
 
45
+ class TotalRequestTimeoutError < RequestTimeoutError
46
+ end
47
+
45
48
  class OperationTimeoutError < TimeoutError
46
49
  end
47
50
 
51
+ class PingTimeoutError < TimeoutError
52
+ end
53
+
48
54
  class ResolveError < Error
49
55
  end
50
56
 
data/sig/httpx.rbs CHANGED
@@ -10,6 +10,8 @@ module HTTPX
10
10
  type uri = http_uri | string
11
11
  type generic_uri = String | URI::Generic
12
12
 
13
+ type interval = Numeric & _ToF & Time::_Timeout?
14
+
13
15
  type verb = String
14
16
 
15
17
  type request_params = Hash[Symbol, untyped]
data/sig/io/tcp.rbs CHANGED
@@ -52,6 +52,8 @@ module HTTPX
52
52
 
53
53
  def close: () -> void
54
54
 
55
+ def can_disconnect?: () -> bool
56
+
55
57
  def connected?: () -> bool
56
58
 
57
59
  def closed?: () -> bool
data/sig/loggable.rbs CHANGED
@@ -3,6 +3,10 @@ module HTTPX
3
3
  def <<: (string?) -> void
4
4
  end
5
5
 
6
+ interface _Loggable
7
+ def log: (?level: Integer?, ?color: Symbol?, ?debug_level: Integer, ?debug: _IOLogger?) { () -> String } -> void
8
+ end
9
+
6
10
  module Loggable
7
11
  USE_DEBUG_LOG: bool
8
12
 
data/sig/options.rbs CHANGED
@@ -2,6 +2,8 @@ module HTTPX
2
2
  class Options
3
3
  # include _ToHash
4
4
 
5
+ type maybe_unbounded = Integer | Float # because infinity
6
+
5
7
  BUFFER_SIZE: Integer
6
8
  WINDOW_SIZE: Integer
7
9
  MAX_BODY_THRESHOLD_SIZE: Integer
@@ -9,8 +11,10 @@ module HTTPX
9
11
  READ_TIMEOUT: Integer
10
12
  WRITE_TIMEOUT: Integer
11
13
  REQUEST_TIMEOUT: Integer
14
+ TOTAL_REQUEST_TIMEOUT: Integer
12
15
  OPERATION_TIMEOUT: Integer
13
16
  KEEP_ALIVE_TIMEOUT: Integer
17
+ PING_TIMEOUT: Integer
14
18
  SETTINGS_TIMEOUT: Integer
15
19
  CLOSE_HANDSHAKE_TIMEOUT: Integer
16
20
  SET_TEMPORARY_NAME: ^(Class klass, ?Symbol pl) -> void
@@ -21,8 +25,8 @@ module HTTPX
21
25
  RESOLVER_TYPES: Array[Symbol]
22
26
  USER_AGENT: String
23
27
 
24
- type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
25
- type timeout = Hash[timeout_type, Numeric?]
28
+ type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :total_request_timeout | :request_timeout | :ping_timeout
29
+ type timeout = Hash[timeout_type, interval?]
26
30
  type redact_value = :headers | :body | bool
27
31
  type resolver_cache_option = :memory | :file | (Object & Resolver::_Cache)
28
32
 
@@ -43,10 +47,10 @@ module HTTPX
43
47
  attr_reader http2_settings: Hash[Symbol, Integer | bool]
44
48
 
45
49
  # max_concurrent_requests
46
- attr_reader max_concurrent_requests: Integer?
50
+ attr_reader max_concurrent_requests: maybe_unbounded?
47
51
 
48
52
  # max_requests
49
- attr_reader max_requests: Numeric?
53
+ attr_reader max_requests: maybe_unbounded?
50
54
 
51
55
  # window_size
52
56
  attr_reader window_size: Integer
@@ -57,6 +61,15 @@ module HTTPX
57
61
  # body_threshold_size
58
62
  attr_reader body_threshold_size: Integer
59
63
 
64
+ # max_response_headers
65
+ attr_reader max_response_headers: Integer
66
+
67
+ # max_response_header_value_size
68
+ attr_reader max_response_header_value_size: maybe_unbounded?
69
+
70
+ # max_response_body_size
71
+ attr_reader max_response_body_size: maybe_unbounded
72
+
60
73
  # transport
61
74
  attr_reader transport: io_type | nil
62
75
 
@@ -164,12 +177,12 @@ module HTTPX
164
177
  def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
165
178
 
166
179
  # integer
167
- def option_max_concurrent_requests: (Numeric value) -> Numeric
168
- def option_max_requests: (Numeric value) -> Numeric
169
- def option_window_size: (Numeric value) -> Numeric
170
- def option_buffer_size: (Numeric value) -> Numeric
171
- def option_body_threshold_size: (Numeric value) -> Numeric
172
- def option_debug_level: (Numeric value) -> Numeric
180
+ def option_max_concurrent_requests: (int value) -> maybe_unbounded
181
+ def option_max_requests: (int value) -> maybe_unbounded
182
+ def option_window_size: (int value) -> Integer
183
+ def option_buffer_size: (int value) -> Integer
184
+ def option_body_threshold_size: (int value) -> Integer
185
+ def option_debug_level: (int value) -> Integer
173
186
 
174
187
  # to hash
175
188
  def option_ssl: (_ToHash[Symbol, untyped] value) -> Hash[Symbol, untyped]
@@ -186,7 +199,7 @@ module HTTPX
186
199
  def option_connection_class: (singleton(Connection) value) -> singleton(Connection)
187
200
  def option_options_class: (singleton(Options) value) -> singleton(Options)
188
201
  def option_pool_class: (singleton(Pool) value) -> singleton(Pool)
189
- def option_resolver_class: (Symbol | singleton(Resolver::Resolver) value) -> (Symbol | singleton(Resolver::Resolver))
202
+ def option_resolver_class: (Symbol | resolver_type value) -> (Symbol | resolver_type)
190
203
  def option_io: (io_option value) -> io_option
191
204
  def option_fallback_protocol: (String value) -> String
192
205
  def option_debug: (_IOLogger value) -> _IOLogger
@@ -204,7 +217,7 @@ module HTTPX
204
217
 
205
218
  def option_headers: (headers_input | Headers value) -> Headers
206
219
 
207
- def option_timeout: (_ToHash[timeout_type, Numeric?]) -> timeout
220
+ def option_timeout: (_ToHash[timeout_type, interval?]) -> timeout
208
221
 
209
222
  def option_supported_compression_formats: (_ToS | _ToAry[_ToS] value) -> Array[String]
210
223
 
data/sig/parser/http1.rbs CHANGED
@@ -28,6 +28,8 @@ module HTTPX
28
28
  @content_length: Integer
29
29
  @_has_trailers: bool
30
30
  @upgrade: bool
31
+ @max_headers: Options::maybe_unbounded
32
+ @max_header_value_size: Options::maybe_unbounded?
31
33
 
32
34
  def <<: (string chunk) -> void
33
35
 
@@ -39,7 +41,7 @@ module HTTPX
39
41
 
40
42
  private
41
43
 
42
- def initialize: (_HTTP1Events observer) -> untyped
44
+ def initialize: (_HTTP1Events observer, Options::maybe_unbounded max_headers, Options::maybe_unbounded? max_header_value_size) -> void
43
45
 
44
46
  def nextstate: (Symbol state) -> void
45
47
 
@@ -10,7 +10,7 @@ module HTTPX
10
10
 
11
11
  def authenticate: (Request request, String authenticate) -> String
12
12
 
13
- def negotiate: () -> void
13
+ def negotiate: () -> String
14
14
 
15
15
  private
16
16
 
@@ -1,12 +1,12 @@
1
1
  module HTTPX
2
2
  module Plugins
3
- module ResponseCache
3
+ module Cache
4
4
  class FileStore
5
5
  CRLF: String
6
6
 
7
7
  @dir: Pathname
8
8
 
9
- include _ResponseCacheStore
9
+ include _CacheStore
10
10
 
11
11
  def initialize: (?path dir) -> void
12
12
 
@@ -1,12 +1,12 @@
1
1
  module HTTPX
2
2
  module Plugins
3
- module ResponseCache
3
+ module Cache
4
4
  class Store
5
5
  @store: Hash[String, cacheResponse]
6
6
 
7
7
  @store_mutex: Thread::Mutex
8
8
 
9
- include _ResponseCacheStore
9
+ include _CacheStore
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,69 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Cache
4
+ interface _CacheStore
5
+ def get: (cacheRequest request) -> cacheResponse?
6
+
7
+ def set: (cacheRequest request, cacheResponse response) -> void
8
+
9
+ def clear: () -> void
10
+ end
11
+
12
+ interface _CacheOptions
13
+ def cache_key: () -> String?
14
+
15
+ def cacheable_request: () -> ^(cacheRequest request) -> boolish
16
+
17
+ def cacheable_response: () -> ^(cacheRequest request, cacheResponse response) -> boolish
18
+
19
+ def valid_cached_response: () -> ^(cacheRequest request, cacheResponse response) -> boolish
20
+
21
+ def response_cache_store: () -> Store
22
+ end
23
+
24
+ module InstanceMethods
25
+ def clear_response_cache: () -> void
26
+
27
+ private
28
+
29
+ def cacheable_request?: (cacheRequest request) -> boolish
30
+
31
+ def cacheable_response?: (cacheRequest request, cacheResponse response) -> boolish
32
+
33
+ def valid_cached_response?: (cacheRequest request, cacheResponse cached_response) -> boolish
34
+
35
+ def prepare_cache: (cacheRequest request) -> void
36
+
37
+ def retrieve_cached_response: (cacheRequest request) -> cacheResponse?
38
+ end
39
+
40
+ module RequestMethods
41
+ attr_accessor cached_response: cacheResponse?
42
+ attr_reader options: cacheOptions
43
+
44
+ def response_cache_key: () -> String?
45
+ end
46
+
47
+ module ResponseMethods
48
+ attr_writer original_request: cacheRequest
49
+
50
+ @cached: bool
51
+
52
+ def original_request: () -> cacheRequest?
53
+
54
+ def cached?: () -> bool
55
+
56
+ def mark_as_cached!: () -> void
57
+ end
58
+
59
+
60
+ type cacheOptions = Options & _CacheOptions
61
+
62
+ type cacheRequest = Request & RequestMethods
63
+
64
+ type cacheResponse = Response & ResponseMethods
65
+ end
66
+
67
+ type sessionCache = Session & Cache::InstanceMethods
68
+ end
69
+ end
@@ -17,6 +17,10 @@ module HTTPX
17
17
  def current_context?: () -> boolish
18
18
 
19
19
  def send: (request request) -> void
20
+
21
+ private
22
+
23
+ def backlog?: () -> bool
20
24
  end
21
25
 
22
26
  module HTTP1Methods
@@ -0,0 +1,36 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module NTLMV2Auth
4
+ class Authenticator
5
+ @user: String
6
+ @password: String
7
+ @domain: String?
8
+
9
+ def can_authenticate?: (String? www_authenticate) -> boolish
10
+
11
+ def authenticate: (Request request, String authenticate) -> String
12
+
13
+ def negotiate: () -> String
14
+
15
+ private
16
+
17
+ def initialize: (string user, string password, ?domain: String?) -> void
18
+ end
19
+
20
+ interface _NTLMV2Options
21
+ def ntlm: () -> Authentication?
22
+ end
23
+
24
+ def self.extra_options: (Options) -> (Options & _NTLMV2Options)
25
+
26
+ def self.load_dependencies: (singleton(Session) klass) -> void
27
+
28
+ module InstanceMethods
29
+ def ntlm_auth: (string user, string password, ?string? domain) -> instance
30
+ end
31
+
32
+ end
33
+
34
+ type sessionNTLMV2Auth = sessionAuth & NTLMV2Auth::InstanceMethods
35
+ end
36
+ end
@@ -5,72 +5,47 @@ module HTTPX
5
5
  CACHEABLE_STATUS_CODES: Array[Integer]
6
6
  SUPPORTED_VARY_HEADERS: Array[String]
7
7
 
8
- def self?.cacheable_response?: (::HTTPX::ErrorResponse | cacheResponse response) -> bool
8
+ def self?.cacheable_response?: (::HTTPX::ErrorResponse | responseCacheResponse response) -> bool
9
9
 
10
10
  def self?.not_modified?: (response response) -> bool
11
11
 
12
12
  interface _ResponseCacheOptions
13
- def response_cache_store: () -> Store
14
-
15
13
  def supported_vary_headers: () -> Array[String]
16
14
  end
17
15
 
18
- interface _ResponseCacheStore
19
- def get: (cacheRequest request) -> cacheResponse?
20
-
21
- def set: (cacheRequest request, cacheResponse response) -> void
22
-
23
- def clear: () -> void
24
- end
25
-
26
16
  module InstanceMethods
27
- @response_cache: Store
28
-
29
- def clear_response_cache: () -> void
30
-
31
17
  private
32
18
 
33
- def prepare_cache: (cacheRequest request) -> void
34
-
35
- def cacheable_request?: (cacheRequest request) -> bool
36
-
37
- def match_by_vary?: (cacheRequest request, cacheResponse response) -> bool
19
+ def match_by_vary?: (responseCacheRequest request, responseCacheResponse response) -> bool
38
20
  end
39
21
 
40
22
  module RequestMethods
41
- attr_accessor cached_response: cacheResponse?
42
- attr_reader options: cacheOptions
23
+ attr_accessor cached_response: responseCacheResponse?
24
+ attr_reader options: responseCacheOptions
43
25
 
44
26
  @response_cache_key: String
45
27
 
46
- def response_cache_key: () -> String
28
+ private
47
29
 
48
30
  def cacheable_verb?: () -> bool
49
31
  end
50
32
 
51
33
  module ResponseMethods
52
- attr_writer original_request: cacheRequest
53
-
54
34
  attr_writer revalidated_at: Time
55
35
 
56
- @cached: bool
57
36
  @cache_control: Array[String]?
58
- @vary: Array[String]?
59
- @date: Time?
60
-
61
- def original_request: () -> cacheRequest?
62
37
 
63
- def cached?: () -> bool
38
+ @vary: Array[String]?
64
39
 
65
- def mark_as_cached!: () -> void
40
+ @date: Time?
66
41
 
67
42
  def copy_from_cached!: () -> void
68
43
 
69
44
  def fresh?: () -> bool
70
45
 
71
- %a{pure} def cache_control: () -> Array[String]?
46
+ %a{pure} def cache_control: () -> Array[String]?
72
47
 
73
- %a{pure} def vary: () -> Array[String]?
48
+ %a{pure} def vary: () -> Array[String]?
74
49
 
75
50
  private
76
51
 
@@ -80,13 +55,13 @@ module HTTPX
80
55
  end
81
56
 
82
57
 
83
- type cacheOptions = Options & _ResponseCacheOptions
58
+ type responseCacheOptions = Options & Cache::_CacheOptions & _ResponseCacheOptions
84
59
 
85
- type cacheRequest = Request & RequestMethods
60
+ type responseCacheRequest = Request & Cache::RequestMethods & RequestMethods
86
61
 
87
- type cacheResponse = Response & ResponseMethods
62
+ type responseCacheResponse = Response & Cache::ResponseMethods & ResponseMethods
88
63
  end
89
64
 
90
- type sessionResponseCache = Session & ResponseCache::InstanceMethods
65
+ type sessionResponseCache = Session & Cache::InstanceMethods & ResponseCache::InstanceMethods
91
66
  end
92
67
  end
@@ -5,21 +5,21 @@ module HTTPX
5
5
  IDEMPOTENT_METHODS: Array[String]
6
6
  RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
7
7
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
8
- DEFAULT_JITTER: ^(Numeric) -> Numeric
8
+ DEFAULT_JITTER: ^(interval) -> interval
9
9
  BACKOFF_ALGORITHMS: Array[Symbol]
10
10
 
11
- def self?.retry_after_polynomial_backoff: (retriesRequest request, retriesResponse response) -> Numeric
11
+ def self?.retry_after_polynomial_backoff: (retriesRequest request, retriesResponse response) -> interval
12
12
 
13
- def self?.retry_after_exponential_backoff: (retriesRequest request, retriesResponse response) -> Numeric
13
+ def self?.retry_after_exponential_backoff: (retriesRequest request, retriesResponse response) -> interval
14
14
 
15
15
  interface _RetryCallback
16
16
  def call: (retriesResponse response) -> bool?
17
17
  end
18
18
 
19
19
  interface _RetriesOptions
20
- def retry_after: () -> (^(retriesRequest request, retriesResponse response) -> Numeric | Numeric)?
20
+ def retry_after: () -> (^(retriesRequest request, retriesResponse response) -> interval | interval)?
21
21
 
22
- def retry_jitter: () -> ^(Numeric jitter) -> Numeric
22
+ def retry_jitter: () -> ^(interval jitter) -> interval
23
23
 
24
24
  def max_retries: () -> Integer
25
25