httpx 1.7.2 → 1.7.6

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/doc/release_notes/1_7_3.md +29 -0
  4. data/doc/release_notes/1_7_4.md +42 -0
  5. data/doc/release_notes/1_7_5.md +10 -0
  6. data/doc/release_notes/1_7_6.md +24 -0
  7. data/lib/httpx/adapters/datadog.rb +37 -64
  8. data/lib/httpx/adapters/webmock.rb +3 -4
  9. data/lib/httpx/altsvc.rb +4 -2
  10. data/lib/httpx/connection/http1.rb +26 -18
  11. data/lib/httpx/connection/http2.rb +53 -33
  12. data/lib/httpx/connection.rb +152 -63
  13. data/lib/httpx/io/ssl.rb +20 -8
  14. data/lib/httpx/io/tcp.rb +18 -12
  15. data/lib/httpx/io/unix.rb +13 -9
  16. data/lib/httpx/options.rb +23 -7
  17. data/lib/httpx/parser/http1.rb +14 -4
  18. data/lib/httpx/plugins/auth/digest.rb +2 -1
  19. data/lib/httpx/plugins/auth.rb +23 -9
  20. data/lib/httpx/plugins/brotli.rb +33 -5
  21. data/lib/httpx/plugins/cookies/cookie.rb +34 -11
  22. data/lib/httpx/plugins/cookies/jar.rb +93 -18
  23. data/lib/httpx/plugins/cookies.rb +7 -3
  24. data/lib/httpx/plugins/expect.rb +33 -3
  25. data/lib/httpx/plugins/fiber_concurrency.rb +2 -4
  26. data/lib/httpx/plugins/follow_redirects.rb +7 -1
  27. data/lib/httpx/plugins/h2c.rb +1 -1
  28. data/lib/httpx/plugins/proxy/http.rb +15 -8
  29. data/lib/httpx/plugins/proxy.rb +10 -2
  30. data/lib/httpx/plugins/rate_limiter.rb +19 -19
  31. data/lib/httpx/plugins/retries.rb +17 -9
  32. data/lib/httpx/plugins/ssrf_filter.rb +1 -0
  33. data/lib/httpx/plugins/stream_bidi.rb +6 -0
  34. data/lib/httpx/plugins/tracing.rb +137 -0
  35. data/lib/httpx/pool.rb +7 -9
  36. data/lib/httpx/request.rb +15 -3
  37. data/lib/httpx/resolver/multi.rb +1 -8
  38. data/lib/httpx/resolver/native.rb +2 -2
  39. data/lib/httpx/resolver/resolver.rb +21 -2
  40. data/lib/httpx/resolver/system.rb +3 -1
  41. data/lib/httpx/response.rb +5 -1
  42. data/lib/httpx/selector.rb +19 -16
  43. data/lib/httpx/session.rb +34 -44
  44. data/lib/httpx/timers.rb +4 -0
  45. data/lib/httpx/version.rb +1 -1
  46. data/sig/altsvc.rbs +2 -0
  47. data/sig/chainable.rbs +2 -1
  48. data/sig/connection/http1.rbs +3 -1
  49. data/sig/connection/http2.rbs +11 -4
  50. data/sig/connection.rbs +16 -2
  51. data/sig/io/ssl.rbs +1 -0
  52. data/sig/io/tcp.rbs +2 -2
  53. data/sig/options.rbs +8 -3
  54. data/sig/parser/http1.rbs +1 -1
  55. data/sig/plugins/auth.rbs +5 -2
  56. data/sig/plugins/brotli.rbs +11 -6
  57. data/sig/plugins/cookies/cookie.rbs +3 -2
  58. data/sig/plugins/cookies/jar.rbs +11 -0
  59. data/sig/plugins/cookies.rbs +2 -0
  60. data/sig/plugins/expect.rbs +21 -2
  61. data/sig/plugins/fiber_concurrency.rbs +2 -2
  62. data/sig/plugins/proxy/socks4.rbs +4 -0
  63. data/sig/plugins/rate_limiter.rbs +2 -2
  64. data/sig/plugins/response_cache.rbs +3 -3
  65. data/sig/plugins/retries.rbs +17 -13
  66. data/sig/plugins/tracing.rbs +41 -0
  67. data/sig/pool.rbs +1 -1
  68. data/sig/request.rbs +4 -0
  69. data/sig/resolver/native.rbs +2 -0
  70. data/sig/resolver/resolver.rbs +4 -2
  71. data/sig/resolver/system.rbs +0 -2
  72. data/sig/response/body.rbs +1 -1
  73. data/sig/selector.rbs +7 -2
  74. data/sig/session.rbs +2 -0
  75. data/sig/timers.rbs +2 -0
  76. data/sig/transcoder/gzip.rbs +1 -1
  77. data/sig/transcoder.rbs +0 -2
  78. metadata +13 -3
data/lib/httpx/session.rb CHANGED
@@ -140,9 +140,10 @@ module HTTPX
140
140
  end
141
141
  selector.deregister(connection)
142
142
 
143
+ # do not check-in connections only created for Happy Eyeballs
143
144
  return if cloned
144
145
 
145
- return if @closing && connection.state == :closed
146
+ return if @closing && connection.state == :closed && !connection.used?
146
147
 
147
148
  connection.log(level: 2) { "check-in connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
148
149
  @pool.checkin_connection(connection)
@@ -177,16 +178,15 @@ module HTTPX
177
178
 
178
179
  # returns the HTTPX::Connection through which the +request+ should be sent through.
179
180
  def find_connection(request_uri, selector, options)
180
- log(level: 2) { "finding connection for #{request_uri}..." }
181
181
  if (connection = selector.find_connection(request_uri, options))
182
182
  connection.idling if connection.state == :closed
183
- connection.log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
183
+ log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in selector##{selector.object_id}" }
184
184
  return connection
185
185
  end
186
186
 
187
187
  connection = @pool.checkout_connection(request_uri, options)
188
188
 
189
- connection.log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
189
+ log(level: 2) { "found connection##{connection.object_id}(#{connection.state}) in pool##{@pool.object_id}" }
190
190
 
191
191
  case connection.state
192
192
  when :idle
@@ -240,7 +240,7 @@ module HTTPX
240
240
 
241
241
  return unless response && response.finished?
242
242
 
243
- log(level: 2) { "response fetched" }
243
+ log(level: 2) { "response##{response.object_id} fetched" }
244
244
 
245
245
  response
246
246
  end
@@ -249,6 +249,7 @@ module HTTPX
249
249
  def send_request(request, selector, options = request.options)
250
250
  error = begin
251
251
  catch(:resolve_error) do
252
+ log(level: 2) { "finding connection for request##{request.object_id}..." }
252
253
  connection = find_connection(request.uri, selector, options)
253
254
  connection.send(request)
254
255
  end
@@ -324,53 +325,34 @@ module HTTPX
324
325
 
325
326
  # returns the array of HTTPX::Response objects corresponding to the array of HTTPX::Request +requests+.
326
327
  def receive_requests(requests, selector)
327
- responses = [] # : Array[response]
328
-
329
- # guarantee ordered responses
330
- loop do
331
- request = requests.first
332
-
333
- return responses unless request
334
-
335
- catch(:coalesced) { selector.next_tick } until (response = fetch_response(request, selector, request.options))
336
- request.complete!(response)
337
-
338
- responses << response
339
- requests.shift
340
-
341
- break if requests.empty?
328
+ waiting = 0
329
+ responses = requests.map do |request|
330
+ fetch_response(request, selector, request.options).tap do |response|
331
+ waiting += 1 if response.nil?
332
+ end
333
+ end
342
334
 
343
- next unless selector.empty?
335
+ until waiting.zero? || selector.empty?
336
+ # loop on selector until at least one response has been received.
337
+ catch(:coalesced) { selector.next_tick }
344
338
 
345
- # in some cases, the pool of connections might have been drained because there was some
346
- # handshake error, and the error responses have already been emitted, but there was no
347
- # opportunity to traverse the requests, hence we're returning only a fraction of the errors
348
- # we were supposed to. This effectively fetches the existing responses and return them.
349
- exit_from_loop = true
339
+ responses.each_with_index do |response, idx|
340
+ next unless response.nil?
350
341
 
351
- requests_to_remove = [] # : Array[Request]
342
+ request = requests[idx]
352
343
 
353
- requests.each do |req|
354
- response = fetch_response(req, selector, request.options)
344
+ response = fetch_response(request, selector, request.options)
355
345
 
356
- if exit_from_loop && response
357
- req.complete!(response)
358
- responses << response
359
- requests_to_remove << req
360
- else
361
- # fetch_response may resend requests. when that happens, we need to go back to the initial
362
- # loop and process the selector. we still do a pass-through on the remainder of requests, so
363
- # that every request that need to be resent, is resent.
364
- exit_from_loop = false
346
+ next unless response
365
347
 
366
- raise Error, "something went wrong, responses not found and requests not resent" if selector.empty?
367
- end
348
+ request.complete!(response)
349
+ responses[idx] = response
350
+ waiting -= 1
368
351
  end
352
+ end
369
353
 
370
- break if exit_from_loop
354
+ raise Error, "something went wrong, responses not found and requests not resent" unless waiting.zero?
371
355
 
372
- requests -= requests_to_remove
373
- end
374
356
  responses
375
357
  end
376
358
 
@@ -391,7 +373,15 @@ module HTTPX
391
373
  resolver = find_resolver_for(connection, selector)
392
374
 
393
375
  pin(connection, selector)
394
- resolver.early_resolve(connection) || resolver.lazy_resolve(connection)
376
+ if early_resolve(resolver, connection)
377
+ @pool.checkin_resolver(resolver)
378
+ else
379
+ resolver.lazy_resolve(connection)
380
+ end
381
+ end
382
+
383
+ def early_resolve(resolver, connection)
384
+ resolver.early_resolve(connection)
395
385
  end
396
386
 
397
387
  def on_resolver_connection(connection, selector)
data/lib/httpx/timers.rb CHANGED
@@ -6,6 +6,10 @@ module HTTPX
6
6
  @intervals = []
7
7
  end
8
8
 
9
+ def empty?
10
+ @intervals.empty?
11
+ end
12
+
9
13
  def after(interval_in_secs, cb = nil, &blk)
10
14
  callback = cb || blk
11
15
 
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.2"
4
+ VERSION = "1.7.6"
5
5
  end
data/sig/altsvc.rbs CHANGED
@@ -3,6 +3,8 @@ module HTTPX
3
3
  module ConnectionMixin
4
4
  H2_ALTSVC_SCHEMES: Array[String]
5
5
 
6
+ ALTSVC_IGNORE_IVARS: Array[Symbol]
7
+
6
8
  def send: (Request request) -> void
7
9
 
8
10
  def match?: (http_uri uri, Options options) -> bool
data/sig/chainable.rbs CHANGED
@@ -29,7 +29,7 @@ module HTTPX
29
29
  | (:proxy, ?options) -> (Plugins::sessionProxy & Plugins::httpProxy)
30
30
  | (:push_promise, ?options) -> Plugins::sessionPushPromise
31
31
  | (:retries, ?options) -> Plugins::sessionRetries
32
- | (:rate_limiter, ?options) -> Session
32
+ | (:rate_limiter, ?options) -> Plugins::sessionRateLimiter
33
33
  | (:stream, ?options) -> Plugins::sessionStream
34
34
  | (:stream_bidi, ?options) -> Plugins::sessionStreamBidi
35
35
  | (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
@@ -43,6 +43,7 @@ module HTTPX
43
43
  | (:webdav, ?options) -> Plugins::sessionWebDav
44
44
  | (:xml, ?options) -> Plugins::sessionXML
45
45
  | (:query, ?options) -> Plugins::sessionQuery
46
+ | (:tracing, ?options) -> Plugins::sessionTracing
46
47
  | (Symbol | Module, ?options) { (Class) -> void } -> Session
47
48
  | (Symbol | Module, ?options) -> Session
48
49
 
@@ -26,6 +26,8 @@ module HTTPX
26
26
 
27
27
  def reset: () -> void
28
28
 
29
+ def reset_requests: () -> void
30
+
29
31
  def close: () -> void
30
32
 
31
33
  def empty?: () -> bool
@@ -50,7 +52,7 @@ module HTTPX
50
52
 
51
53
  def on_complete: () -> void
52
54
 
53
- def dispatch: () -> void
55
+ def dispatch: (Request request) -> void
54
56
 
55
57
  def ping: () -> void
56
58
 
@@ -6,6 +6,7 @@ module HTTPX
6
6
  MAX_CONCURRENT_REQUESTS: Integer
7
7
 
8
8
  attr_reader streams: Hash[Request, ::HTTP2::Stream]
9
+
9
10
  attr_reader pending: Array[Request]
10
11
 
11
12
  @connection: HTTP2::Client
@@ -43,6 +44,8 @@ module HTTPX
43
44
 
44
45
  def timeout: () -> Numeric?
45
46
 
47
+ def reset_requests: () -> void
48
+
46
49
  private
47
50
 
48
51
  def initialize: (Buffer buffer, Options options) -> untyped
@@ -79,6 +82,8 @@ module HTTPX
79
82
 
80
83
  def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
81
84
 
85
+ def on_stream_half_close: (::HTTP2::Stream stream, Request request) -> void
86
+
82
87
  def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
83
88
 
84
89
  def on_frame: (string bytes) -> void
@@ -87,13 +92,15 @@ module HTTPX
87
92
 
88
93
  def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
89
94
 
90
- def on_frame_sent: (::HTTP2::frame) -> void
95
+ def on_frame_sent: (::HTTP2::frame frame) -> void
96
+
97
+ def frame_with_extra_info: (::HTTP2::frame frame) -> Hash[Symbol, untyped]
91
98
 
92
- def on_frame_received: (::HTTP2::frame) -> void
99
+ def on_frame_received: (::HTTP2::frame frame) -> void
93
100
 
94
- def on_altsvc: (String origin, ::HTTP2::frame) -> void
101
+ def on_altsvc: (String origin, ::HTTP2::frame frame) -> void
95
102
 
96
- def on_promise: (::HTTP2::Stream) -> void
103
+ def on_promise: (::HTTP2::Stream stream) -> void
97
104
 
98
105
  def on_origin: (String) -> void
99
106
 
data/sig/connection.rbs CHANGED
@@ -37,6 +37,7 @@ module HTTPX
37
37
  @read_buffer: Buffer
38
38
  @write_buffer: Buffer
39
39
  @inflight: Integer
40
+ @max_concurrent_requests: Integer?
40
41
  @keep_alive_timeout: Numeric?
41
42
  @timeout: Numeric?
42
43
  @current_timeout: Numeric?
@@ -49,6 +50,7 @@ module HTTPX
49
50
  @altsvc_connection: instance?
50
51
  @sibling: instance?
51
52
  @main_sibling: bool
53
+ @no_more_requests_counter: Integer
52
54
 
53
55
 
54
56
  def addresses: () -> Array[Resolver::Entry]?
@@ -119,6 +121,10 @@ module HTTPX
119
121
 
120
122
  def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
121
123
 
124
+ def on_io_error: (IOError error) -> void
125
+
126
+ def on_connect_error: (Exception error) -> void
127
+
122
128
  private
123
129
 
124
130
  def initialize: (http_uri uri, Options options) -> void
@@ -151,8 +157,16 @@ module HTTPX
151
157
 
152
158
  def build_socket: (?Array[Resolver::Entry]? addrs) -> (TCP | SSL | UNIX)
153
159
 
160
+ def ping: () -> void
161
+
162
+ def pong: () -> void
163
+
164
+ def no_more_requests_loop_check: () -> void
165
+
154
166
  def handle_error: (StandardError error, ?Request? request) -> void
155
167
 
168
+ def force_purge: () -> void
169
+
156
170
  def close_sibling: () -> void
157
171
 
158
172
  def purge_after_closed: () -> void
@@ -165,9 +179,9 @@ module HTTPX
165
179
 
166
180
  def set_request_request_timeout: (Request request) -> void
167
181
 
168
- def write_timeout_callback: (Request request, Numeric write_timeout) -> void
182
+ def write_timeout_callback: (Request request, Numeric timeout) -> void
169
183
 
170
- def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
184
+ def read_timeout_callback: (Request request, Numeric timeout, ?singleton(RequestTimeoutError) error_type) -> void
171
185
 
172
186
  def set_request_timeout: (Symbol label, Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
173
187
 
data/sig/io/ssl.rbs CHANGED
@@ -8,6 +8,7 @@ module HTTPX
8
8
 
9
9
  @ctx: OpenSSL::SSL::SSLContext
10
10
  @verify_hostname: bool
11
+ @sni_hostname: String
11
12
 
12
13
  attr_writer ssl_session: OpenSSL::SSL::Session?
13
14
 
data/sig/io/tcp.rbs CHANGED
@@ -46,7 +46,7 @@ module HTTPX
46
46
 
47
47
  public
48
48
 
49
- def read: (Integer size, ?(Buffer | String) buffer) -> (0 | nil | untyped)
49
+ def read: (Integer size, Buffer | String buffer) -> (0 | nil | untyped)
50
50
 
51
51
  def write: (Buffer buffer) -> Integer?
52
52
 
@@ -67,6 +67,6 @@ module HTTPX
67
67
 
68
68
  def do_transition: (Symbol nextstate) -> void
69
69
 
70
- def log_transition_state: (Symbol nextstate) -> void
70
+ def log_transition_state: (Symbol nextstate) -> String
71
71
  end
72
72
  end
data/sig/options.rbs CHANGED
@@ -17,6 +17,7 @@ module HTTPX
17
17
 
18
18
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
19
19
  REQUEST_BODY_IVARS: Array[Symbol]
20
+ RESOLVER_IVARS: Array[Symbol]
20
21
  RESOLVER_TYPES: Array[Symbol]
21
22
  USER_AGENT: String
22
23
 
@@ -106,8 +107,10 @@ module HTTPX
106
107
 
107
108
  attr_reader ssl: Hash[Symbol, untyped]
108
109
 
109
- # io
110
- type io_option = _ToIO | Hash[String, _ToIO]
110
+ type external_io = TCPSocket | OpenSSL::SSL::SSLSocket | UNIXSocket
111
+
112
+ type io_option = external_io | Hash[String, external_io]
113
+
111
114
  attr_reader io: io_option?
112
115
 
113
116
  # fallback_protocol
@@ -142,7 +145,9 @@ module HTTPX
142
145
 
143
146
  def ==: (Options other) -> bool
144
147
 
145
- def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
148
+ def connection_options_match?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
149
+
150
+ def resolver_options_match?: (Options other) -> bool
146
151
 
147
152
  def merge: (Object & _ToHash[Symbol, untyped] other) -> (instance | self)
148
153
 
data/sig/parser/http1.rbs CHANGED
@@ -23,7 +23,7 @@ module HTTPX
23
23
 
24
24
  @observer: _HTTP1Events
25
25
  @state: Symbol
26
- @buffer: String
26
+ @buffer: String | Transcoder::Chunker::Decoder
27
27
  @content_type: String?
28
28
  @content_length: Integer
29
29
  @_has_trailers: bool
data/sig/plugins/auth.rbs CHANGED
@@ -10,7 +10,8 @@ module HTTPX
10
10
  end
11
11
 
12
12
  module InstanceMethods
13
- @auth_header_value: String
13
+ @auth_header_value: String?
14
+ @auth_header_value_mtx: Thread::Mutex
14
15
  @skip_auth_header_value: bool
15
16
 
16
17
  def authorization: (?string token, ?auth_header_type: string) ?{ (Request) -> string } -> instance
@@ -29,7 +30,9 @@ module HTTPX
29
30
  end
30
31
 
31
32
  module RequestMethods
32
- @auth_token_value: String?
33
+ attr_reader auth_token_value: String?
34
+
35
+ @auth_header_value: String?
33
36
 
34
37
  def authorized?: () -> bool
35
38
 
@@ -5,17 +5,22 @@ module HTTPX
5
5
 
6
6
  def self?.encode: (body_encoder body) -> Deflater
7
7
 
8
- def self?.decode: (HTTPX::Response response, ?bytesize: Integer) -> Transcoder::_Decoder
8
+ def self?.decode: (HTTPX::Response response, ?bytesize: Integer | Float) -> Inflater
9
9
 
10
- class Deflater < Transcoder::Deflater
10
+ class Error < ::HTTPX::Error
11
11
  end
12
12
 
13
- module RequestBodyClassMethods
14
- def initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
13
+ class Deflater < Transcoder::Deflater
14
+ @compressor: ::Brotli::Compressor
15
15
  end
16
16
 
17
- module ResponseBodyClassMethods
18
- def initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> (Transcoder::_Decoder | Transcoder::GZIP::Inflater)
17
+ class Inflater
18
+ @inflater: ::Brotli::Decompressor
19
+ @bytesize: Integer | Float
20
+
21
+ def initialize: (Integer | Float bytesize) -> void
22
+
23
+ def call: (String chunk) -> String
19
24
  end
20
25
  end
21
26
  end
@@ -31,6 +31,8 @@ module HTTPX
31
31
  def cookie_value: () -> String
32
32
  alias to_s cookie_value
33
33
 
34
+ def match?: (String | cookie_attributes name_or_options) -> bool
35
+
34
36
  def valid_for_uri?: (http_uri uri) -> bool
35
37
 
36
38
  def self.new: (Cookie) -> instance
@@ -41,8 +43,7 @@ module HTTPX
41
43
 
42
44
  private
43
45
 
44
- def initialize: (cookie_attributes) -> untyped
45
- | (_ToS, _ToS, ?cookie_attributes) -> untyped
46
+ def initialize: (_ToS name, _ToS value, ?cookie_attributes) -> void
46
47
 
47
48
  def acceptable_from_uri?: (uri) -> bool
48
49
 
@@ -6,11 +6,20 @@ module HTTPX
6
6
  include Enumerable[Cookie]
7
7
 
8
8
  @cookies: Array[Cookie]
9
+ @mtx: Thread::Mutex
9
10
 
10
11
  def parse: (String set_cookie) -> void
11
12
 
13
+ def get: (String | cookie_attributes name_or_options) -> Cookie?
14
+
15
+ def get_all: (String | cookie_attributes name_or_options) -> Array[Cookie]
16
+
17
+ def set: (_ToS | Cookie name, ?(cookie_attributes | _ToS) value_or_options) -> void
18
+
12
19
  def add: (Cookie name, ?String path) -> void
13
20
 
21
+ def delete: (String | Cookie | cookie_attributes name_or_options) -> void
22
+
14
23
  def []: (http_uri) -> Array[Cookie]
15
24
 
16
25
  def each: (?http_uri?) { (Cookie) -> void } -> void
@@ -21,6 +30,8 @@ module HTTPX
21
30
  private
22
31
 
23
32
  def initialize: (?_Each[cookie] cookies) -> untyped
33
+
34
+ def synchronize: [T] { () -> T } -> T
24
35
  end
25
36
  end
26
37
  end
@@ -15,6 +15,8 @@ module HTTPX
15
15
 
16
16
  module InstanceMethods
17
17
  def cookies: () -> Jar
18
+
19
+ def make_jar: (*untyped) -> Jar
18
20
  end
19
21
 
20
22
  module HeadersMethods
@@ -2,14 +2,33 @@ module HTTPX
2
2
  module Plugins
3
3
  module Expect
4
4
  EXPECT_TIMEOUT: Integer
5
+ NOEXPECT_STORE_MUTEX: Thread::Mutex
6
+
7
+ self.@no_expect_store: Store
8
+ def self.no_expect_store: () -> Store
9
+
10
+ def self.extra_options: (Options) -> (Options & _ExpectOptions)
11
+
12
+ class Store
13
+ @store: Array[String]
14
+ @mutex: Thread::Mutex
15
+
16
+ def include?: (String host) -> bool
17
+
18
+ def add: (String host) -> void
19
+
20
+ def delete: (String host) -> void
21
+ end
22
+
23
+ module RequestMethods
24
+ @informational_status: Integer?
25
+ end
5
26
 
6
27
  interface _ExpectOptions
7
28
  def expect_timeout: () -> Integer?
8
29
 
9
30
  def expect_threshold_size: () -> Integer?
10
31
  end
11
-
12
- def self.extra_options: (Options) -> (Options & _ExpectOptions)
13
32
  end
14
33
  end
15
34
  end
@@ -9,12 +9,12 @@ module HTTPX
9
9
 
10
10
  def set_context!: () -> void
11
11
 
12
- def current_context?: () -> bool
12
+ def current_context?: () -> boolish
13
13
  end
14
14
 
15
15
  module ConnectionMethods
16
16
 
17
- def current_context?: () -> bool
17
+ def current_context?: () -> boolish
18
18
 
19
19
  def send: (request request) -> void
20
20
  end
@@ -5,6 +5,10 @@ module HTTPX
5
5
  module Plugins
6
6
  module Proxy
7
7
  module Socks4
8
+ VERSION: Integer
9
+ CONNECT: Integer
10
+ GRANTED: Integer
11
+ PROTOCOLS: Array[String]
8
12
 
9
13
  module ConnectionMethods
10
14
  def __socks4_proxy_connect: () -> void
@@ -5,11 +5,11 @@ module HTTPX
5
5
 
6
6
  def self.load_dependencies: (singleton(Session)) -> void
7
7
 
8
- def self.retry_after_rate_limit: (untyped, response) -> Numeric?
9
-
10
8
  module InstanceMethods
11
9
  def rate_limit_error?: (response response) -> bool
12
10
  end
13
11
  end
12
+
13
+ type sessionRateLimiter = Session & RateLimiter::InstanceMethods
14
14
  end
15
15
  end
@@ -51,7 +51,7 @@ module HTTPX
51
51
  module ResponseMethods
52
52
  attr_writer original_request: cacheRequest
53
53
 
54
- @cache: bool
54
+ @cached: bool
55
55
  @cache_control: Array[String]?
56
56
  @vary: Array[String]?
57
57
  @date: Time?
@@ -66,9 +66,9 @@ module HTTPX
66
66
 
67
67
  def fresh?: () -> bool
68
68
 
69
- def cache_control: () -> Array[String]?
69
+ %a{pure} def cache_control: () -> Array[String]?
70
70
 
71
- def vary: () -> Array[String]?
71
+ %a{pure} def vary: () -> Array[String]?
72
72
 
73
73
  private
74
74
 
@@ -8,16 +8,16 @@ module HTTPX
8
8
  DEFAULT_JITTER: ^(Numeric) -> Numeric
9
9
  BACKOFF_ALGORITHMS: Array[Symbol]
10
10
 
11
- def self?.retry_after_polynomial_backoff: (retriesRequest request, response response) -> Numeric
11
+ def self?.retry_after_polynomial_backoff: (retriesRequest request, retriesResponse response) -> Numeric
12
12
 
13
- def self?.retry_after_exponential_backoff: (retriesRequest request, response response) -> Numeric
13
+ def self?.retry_after_exponential_backoff: (retriesRequest request, retriesResponse response) -> Numeric
14
14
 
15
15
  interface _RetryCallback
16
- def call: (response response) -> bool?
16
+ def call: (retriesResponse response) -> bool?
17
17
  end
18
18
 
19
19
  interface _RetriesOptions
20
- def retry_after: () -> (^(retriesRequest request, response response) -> Numeric | Numeric)?
20
+ def retry_after: () -> (^(retriesRequest request, retriesResponse response) -> Numeric | Numeric)?
21
21
 
22
22
  def retry_jitter: () -> ^(Numeric jitter) -> Numeric
23
23
 
@@ -35,17 +35,19 @@ module HTTPX
35
35
 
36
36
  private
37
37
 
38
- def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> (retriesResponse | ErrorResponse)?
38
+ def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> retriesResponse?
39
39
 
40
- def retryable_request?: (retriesRequest request, response response, retriesOptions options) -> boolish
40
+ def retryable_request?: (retriesRequest request, retriesResponse response, retriesOptions options) -> boolish
41
41
 
42
- def retryable_response?: (response response, retriesOptions options) -> boolish
42
+ def retryable_response?: (retriesResponse response, retriesOptions options) -> boolish
43
43
 
44
44
  def retryable_error?: (_Exception error, Options options) -> boolish
45
45
 
46
- def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
46
+ def try_partial_retry: (retriesRequest request, retriesResponse response) -> void
47
47
 
48
- def prepare_to_retry: (Request & RequestMethods request, response response) -> void
48
+ def prepare_to_retry: (Request & RequestMethods request, retriesResponse response) -> void
49
+
50
+ def when_to_retry: (Request & RequestMethods request, retriesResponse response, retriesOptions options) -> Numeric?
49
51
  end
50
52
 
51
53
  module RequestMethods
@@ -53,20 +55,22 @@ module HTTPX
53
55
 
54
56
  attr_accessor retries: Integer
55
57
 
56
- attr_writer partial_response: Response?
58
+ attr_writer partial_response: retriesResponse?
57
59
 
58
- def response=: (retriesResponse | ErrorResponse response) -> void
60
+ def response=: (retriesResponse response) -> void
59
61
  end
60
62
 
61
63
  module ResponseMethods
62
- def from_partial_response: (Response response) -> void
64
+ def from_partial_response: (retriesHTTPResponse response) -> void
63
65
  end
64
66
 
65
67
  type retriesOptions = Options & _RetriesOptions
66
68
 
67
69
  type retriesRequest = Request & RequestMethods
68
70
 
69
- type retriesResponse = Response & ResponseMethods
71
+ type retriesHTTPResponse = Response & ResponseMethods
72
+
73
+ type retriesResponse = retriesHTTPResponse | ErrorResponse
70
74
  end
71
75
 
72
76
  type sessionRetries = Session & Retries::InstanceMethods