httpx 0.16.1 → 0.18.2

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/doc/release_notes/0_17_0.md +49 -0
  4. data/doc/release_notes/0_18_0.md +69 -0
  5. data/doc/release_notes/0_18_1.md +12 -0
  6. data/doc/release_notes/0_18_2.md +10 -0
  7. data/lib/httpx/adapters/datadog.rb +1 -1
  8. data/lib/httpx/adapters/faraday.rb +5 -3
  9. data/lib/httpx/adapters/webmock.rb +9 -3
  10. data/lib/httpx/altsvc.rb +2 -2
  11. data/lib/httpx/chainable.rb +4 -4
  12. data/lib/httpx/connection/http1.rb +23 -14
  13. data/lib/httpx/connection/http2.rb +35 -17
  14. data/lib/httpx/connection.rb +74 -76
  15. data/lib/httpx/domain_name.rb +1 -1
  16. data/lib/httpx/extensions.rb +50 -4
  17. data/lib/httpx/headers.rb +1 -1
  18. data/lib/httpx/io/ssl.rb +5 -1
  19. data/lib/httpx/io/tls.rb +7 -7
  20. data/lib/httpx/loggable.rb +5 -5
  21. data/lib/httpx/options.rb +35 -13
  22. data/lib/httpx/parser/http1.rb +10 -6
  23. data/lib/httpx/plugins/aws_sdk_authentication.rb +42 -18
  24. data/lib/httpx/plugins/aws_sigv4.rb +9 -11
  25. data/lib/httpx/plugins/compression.rb +5 -3
  26. data/lib/httpx/plugins/cookies/jar.rb +1 -1
  27. data/lib/httpx/plugins/digest_authentication.rb +4 -4
  28. data/lib/httpx/plugins/expect.rb +7 -3
  29. data/lib/httpx/plugins/grpc/message.rb +2 -2
  30. data/lib/httpx/plugins/grpc.rb +3 -3
  31. data/lib/httpx/plugins/h2c.rb +7 -3
  32. data/lib/httpx/plugins/internal_telemetry.rb +8 -8
  33. data/lib/httpx/plugins/multipart/decoder.rb +187 -0
  34. data/lib/httpx/plugins/multipart/mime_type_detector.rb +3 -3
  35. data/lib/httpx/plugins/multipart/part.rb +2 -2
  36. data/lib/httpx/plugins/multipart.rb +16 -2
  37. data/lib/httpx/plugins/ntlm_authentication.rb +4 -4
  38. data/lib/httpx/plugins/proxy/ssh.rb +11 -4
  39. data/lib/httpx/plugins/proxy.rb +6 -4
  40. data/lib/httpx/plugins/response_cache/store.rb +55 -0
  41. data/lib/httpx/plugins/response_cache.rb +88 -0
  42. data/lib/httpx/plugins/retries.rb +36 -14
  43. data/lib/httpx/plugins/stream.rb +3 -4
  44. data/lib/httpx/pool.rb +39 -13
  45. data/lib/httpx/registry.rb +1 -1
  46. data/lib/httpx/request.rb +12 -13
  47. data/lib/httpx/resolver/https.rb +5 -7
  48. data/lib/httpx/resolver/native.rb +4 -2
  49. data/lib/httpx/resolver/resolver_mixin.rb +2 -1
  50. data/lib/httpx/resolver/system.rb +2 -0
  51. data/lib/httpx/resolver.rb +2 -2
  52. data/lib/httpx/response.rb +60 -44
  53. data/lib/httpx/selector.rb +16 -19
  54. data/lib/httpx/session.rb +22 -15
  55. data/lib/httpx/session2.rb +1 -1
  56. data/lib/httpx/timers.rb +84 -0
  57. data/lib/httpx/transcoder/body.rb +2 -1
  58. data/lib/httpx/transcoder/form.rb +20 -0
  59. data/lib/httpx/transcoder/json.rb +12 -0
  60. data/lib/httpx/transcoder.rb +62 -1
  61. data/lib/httpx/utils.rb +10 -2
  62. data/lib/httpx/version.rb +1 -1
  63. data/lib/httpx.rb +1 -0
  64. data/sig/buffer.rbs +2 -2
  65. data/sig/chainable.rbs +7 -1
  66. data/sig/connection/http1.rbs +15 -4
  67. data/sig/connection/http2.rbs +19 -5
  68. data/sig/connection.rbs +15 -9
  69. data/sig/headers.rbs +19 -18
  70. data/sig/options.rbs +13 -5
  71. data/sig/parser/http1.rbs +3 -3
  72. data/sig/plugins/aws_sdk_authentication.rbs +22 -4
  73. data/sig/plugins/aws_sigv4.rbs +12 -3
  74. data/sig/plugins/basic_authentication.rbs +1 -1
  75. data/sig/plugins/multipart.rbs +64 -8
  76. data/sig/plugins/proxy.rbs +6 -6
  77. data/sig/plugins/response_cache.rbs +35 -0
  78. data/sig/plugins/retries.rbs +3 -0
  79. data/sig/pool.rbs +6 -0
  80. data/sig/request.rbs +11 -8
  81. data/sig/resolver/native.rbs +2 -1
  82. data/sig/resolver/resolver_mixin.rbs +1 -1
  83. data/sig/resolver/system.rbs +3 -1
  84. data/sig/response.rbs +11 -4
  85. data/sig/selector.rbs +8 -6
  86. data/sig/session.rbs +8 -14
  87. data/sig/timers.rbs +32 -0
  88. data/sig/transcoder/form.rbs +1 -0
  89. data/sig/transcoder/json.rbs +1 -0
  90. data/sig/transcoder.rbs +5 -4
  91. data/sig/utils.rbs +4 -0
  92. metadata +18 -17
data/sig/chainable.rbs CHANGED
@@ -1,6 +1,11 @@
1
1
  module HTTPX
2
2
  module Chainable
3
- def request: (*untyped, **untyped) -> (response | Array[response])
3
+ def request: (*Request, **untyped) -> Array[response]
4
+ | (Request, **untyped) -> response
5
+ | (verb | string, uri | [uri], **untyped) -> response
6
+ | (Array[[verb | string, uri] | [verb | string, uri, options]], **untyped) -> Array[response]
7
+ | (verb | string, _Each[uri | [uri, options]], **untyped) -> Array[response]
8
+
4
9
  def accept: (String) -> Session
5
10
  def wrap: () { (Session) -> void } -> void
6
11
 
@@ -27,6 +32,7 @@ module HTTPX
27
32
  | (:stream, ?options) -> Plugins::sessionStream
28
33
  | (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
29
34
  | (:grpc, ?options) -> Plugins::grpcSession
35
+ | (:response_cache, ?options) -> Plugins::sessionResponseCache
30
36
  | (Symbol | Module, ?options) { (Class) -> void } -> Session
31
37
  | (Symbol | Module, ?options) -> Session
32
38
 
@@ -3,6 +3,10 @@ module HTTPX
3
3
  include Callbacks
4
4
  include Loggable
5
5
 
6
+ UPCASED: Hash[String, String]
7
+ MAX_REQUESTS: Integer
8
+ CRLF: String
9
+
6
10
  attr_reader pending: Array[Request]
7
11
  attr_reader requests: Array[Request]
8
12
 
@@ -11,6 +15,11 @@ module HTTPX
11
15
  @max_requests: Integer
12
16
  @parser: Parser::HTTP1
13
17
  @buffer: Buffer
18
+ @version: [Integer, Integer]
19
+ @handshake_completed: bool
20
+ @pipelining: bool
21
+
22
+ @request: Request?
14
23
 
15
24
  def interests: () -> io_interests?
16
25
 
@@ -30,11 +39,13 @@ module HTTPX
30
39
 
31
40
  def handle_error: (StandardError ex) -> void
32
41
 
42
+ def on_start: () -> void
43
+
33
44
  def on_headers: (Hash[String, Array[String]] headers) -> void
34
45
 
35
46
  def on_trailers: (Hash[String, Array[String]] headers) -> void
36
47
 
37
- def on_data: (string chunk) -> void
48
+ def on_data: (String chunk) -> void
38
49
 
39
50
  def on_complete: () -> void
40
51
 
@@ -42,7 +53,7 @@ module HTTPX
42
53
 
43
54
  def ping: () -> void
44
55
 
45
- def timeout: () -> Integer
56
+ def timeout: () -> Numeric
46
57
 
47
58
  private
48
59
 
@@ -54,7 +65,7 @@ module HTTPX
54
65
 
55
66
  def disable_pipelining: () -> void
56
67
 
57
- def set_protocol_headers: (Request) -> _Each[[headers_key, String]]
68
+ def set_protocol_headers: (Request) -> _Each[[String, String]]
58
69
 
59
70
  def headline_uri: (Request) -> String
60
71
 
@@ -64,7 +75,7 @@ module HTTPX
64
75
 
65
76
  def join_trailers: (Request request) -> void
66
77
 
67
- def join_headers2: (_Each[[headers_key, String]] headers) -> void
78
+ def join_headers2: (_Each[[String, String]] headers) -> void
68
79
 
69
80
  def join_body: (Request request) -> void
70
81
 
@@ -3,10 +3,13 @@ module HTTPX
3
3
  include Callbacks
4
4
  include Loggable
5
5
 
6
+ MAX_CONCURRENT_REQUESTS: Integer
7
+
6
8
  attr_reader streams: Hash[Request, HTTP2Next::Stream]
7
9
  attr_reader pending: Array[Request]
8
10
 
9
11
  @options: Options
12
+ @settings: Hash[Symbol, Integer | bool]
10
13
  @max_concurrent_requests: Integer
11
14
  @max_requests: Integer
12
15
  @drains: Hash[Request, String]
@@ -23,7 +26,7 @@ module HTTPX
23
26
 
24
27
  def <<: (String) -> void
25
28
 
26
- def can_buffer_more_requests: () -> bool
29
+ def can_buffer_more_requests?: () -> bool
27
30
 
28
31
  def send: (Request) -> void
29
32
 
@@ -35,7 +38,7 @@ module HTTPX
35
38
 
36
39
  alias reset init_connection
37
40
 
38
- def timeout: () -> Integer
41
+ def timeout: () -> Numeric
39
42
 
40
43
  private
41
44
 
@@ -45,7 +48,7 @@ module HTTPX
45
48
 
46
49
  def headline_uri: (Request) -> String
47
50
 
48
- def set_protocol_headers: (Request) -> _Each[[headers_key, String]]
51
+ def set_protocol_headers: (Request) -> _Each[[String, String]]
49
52
 
50
53
  def handle: (Request request, HTTP2Next::Stream stream) -> void
51
54
 
@@ -61,9 +64,11 @@ module HTTPX
61
64
 
62
65
  def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
63
66
 
64
- def on_stream_trailers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
67
+ def on_stream_trailers: (HTTP2Next::Stream stream, Response response, Array[[String, String]] headers) -> void
68
+
69
+ def on_stream_data: (HTTP2Next::Stream stream, Request request, String data) -> void
65
70
 
66
- def on_stream_data: (HTTP2Next::Stream stream, Request request, string data) -> void
71
+ def on_stream_refuse: (HTTP2Next::Stream stream, Request request, StandardError error) -> void
67
72
 
68
73
  def on_stream_close: (HTTP2Next::Stream stream, Request request, (Symbol | StandardError)? error) -> void
69
74
 
@@ -74,12 +79,21 @@ module HTTPX
74
79
  def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
75
80
 
76
81
  def on_frame_sent: (HTTP2Next::frame) -> void
82
+
77
83
  def on_frame_received: (HTTP2Next::frame) -> void
78
84
 
85
+ def on_altsvc: (String origin, HTTP2Next::frame) -> void
86
+
79
87
  def on_promise: (HTTP2Next::Stream) -> void
80
88
 
81
89
  def on_origin: (String) -> void
82
90
 
83
91
  def on_pong: (string ping) -> void
92
+
93
+ class Error < ::HTTPX::Error
94
+ end
95
+
96
+ class GoawayError < Error
97
+ end
84
98
  end
85
99
  end
data/sig/connection.rbs CHANGED
@@ -1,6 +1,5 @@
1
1
  module HTTPX
2
2
  class Connection
3
-
4
3
  interface _Parser
5
4
 
6
5
  def on: (Symbol) { (*untyped) -> void } -> void
@@ -26,6 +25,15 @@ module HTTPX
26
25
  attr_reader state: Symbol
27
26
  attr_reader pending: Array[Request]
28
27
  attr_reader options: Options
28
+ attr_writer timers: Timers
29
+
30
+ @origins: Array[URI::Generic]
31
+ @window_size: Integer
32
+ @read_buffer: Buffer
33
+ @write_buffer: Buffer
34
+ @inflight: Integer
35
+ @keep_alive_timeout: Numeric?
36
+ @total_timeout: Numeric?
29
37
 
30
38
  def addresses: () -> Array[ipaddr]?
31
39
 
@@ -37,8 +45,7 @@ module HTTPX
37
45
 
38
46
  def coalescable?: (Connection) -> bool
39
47
 
40
- def create_idle: (options) -> Connection
41
- | () -> Connection
48
+ def create_idle: (?Hash[Symbol, untyped] options) -> Connection
42
49
 
43
50
  def merge: (Connection) -> void
44
51
 
@@ -47,11 +54,12 @@ module HTTPX
47
54
  def match_altsvcs?: (URI::Generic uri) -> bool
48
55
 
49
56
  def connecting?: () -> bool
57
+
50
58
  def inflight?: () -> boolish
51
59
 
52
60
  def interests: () -> io_interests?
53
61
 
54
- def to_io: () -> _ToIO
62
+ def to_io: () -> IO
55
63
 
56
64
  def call: () -> void
57
65
 
@@ -62,6 +70,7 @@ module HTTPX
62
70
 
63
71
  def timeout: () -> Numeric?
64
72
 
73
+ def deactivate: () -> void
65
74
  private
66
75
 
67
76
  def initialize: (String, URI::Generic, options) -> untyped
@@ -76,6 +85,8 @@ module HTTPX
76
85
 
77
86
  def parser: () -> _Parser
78
87
 
88
+ def send_request_to_parser: (Request request) -> void
89
+
79
90
  def build_parser: () -> _Parser
80
91
  | (String) -> _Parser
81
92
 
@@ -83,15 +94,10 @@ module HTTPX
83
94
 
84
95
  def transition: (Symbol) -> void
85
96
 
86
- def handle_response: () -> void
87
-
88
97
  def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
89
98
 
90
99
  def handle_error: (StandardError) -> void
91
100
 
92
- def total_timeout: () -> untyped?
93
- # def total_timeout: () -> Timers::Timer?
94
- #
95
101
  def purge_after_closed: () -> void
96
102
  end
97
103
  end
data/sig/headers.rbs CHANGED
@@ -2,44 +2,45 @@ module HTTPX
2
2
  class Headers
3
3
  include _ToS
4
4
 
5
- @headers: headers_hash
5
+ EMPTY: Array[untyped]
6
6
 
7
- def self.new: (?untyped headers) -> Headers
7
+ @headers: Hash[String, Array[String]]
8
+
9
+ def self.new: (?untyped headers) -> instance
8
10
 
9
11
  def ==: (untyped other) -> bool
10
12
 
11
- def []: (headers_key field) -> _ToS?
12
- def []=: (headers_key field, headers_value value) -> void
13
+ def []: (String field) -> String?
14
+ def []=: (String field, headers_value value) -> void
13
15
 
14
- def add: (headers_key field, string value) -> void
15
- def delete: (headers_key field) -> Array[String]?
16
+ def add: (String field, string value) -> void
17
+ def delete: (String field) -> Array[String]?
16
18
 
17
- def each: (?_Each[[headers_key, String]]? extra_headers) { (headers_key, String) -> void } -> void
18
- | (?_Each[[headers_key, String]]? extra_headers) -> Enumerable[[headers_key, String]]
19
+ def each: (?_Each[[String, String]]? extra_headers) { (String k, String v) -> void } -> void
20
+ | (?_Each[[String, String]]? extra_headers) -> Enumerable[[String, String]]
19
21
 
20
- def get: (headers_key field) -> Array[String]
21
- def key?: (headers_key downcased_key) -> bool
22
+ def get: (String field) -> Array[String]
23
+ def key?: (String downcased_key) -> bool
22
24
 
23
- def merge: (_Each[[headers_key, headers_value]] other) -> Headers
25
+ def merge: (_Each[[String, headers_value]] other) -> Headers
24
26
 
25
27
  def same_headers?: (untyped headers) -> bool
26
28
 
27
- def to_a: () -> Array[[headers_key, String]]
28
- def to_hash: () -> Hash[headers_key, String]
29
+ def to_a: () -> Array[[String, String]]
30
+ def to_hash: () -> Hash[String, String]
29
31
  alias to_h to_hash
30
32
 
31
33
  def inspect: () -> String
32
34
 
33
35
  private
34
36
 
35
- def initialize: (headers?) -> untyped
37
+ def initialize: (?headers?) -> untyped
36
38
  def array_value: (headers_value) -> Array[String]
37
- def downcased: (headers_key) -> String
39
+ def downcased: (_ToS field) -> String
38
40
  end
39
41
 
40
- type headers_key = String | Symbol
41
42
  type headers_value = _ToS | Array[_ToS]
42
- type headers_hash = Hash[headers_key, headers_value]
43
- type headers_input = headers_hash | Array[[headers_key, string]]
43
+ type headers_hash = Hash[_ToS, headers_value]
44
+ type headers_input = headers_hash | Array[[_ToS, string]]
44
45
  type headers = Headers | headers_input
45
46
  end
data/sig/options.rbs CHANGED
@@ -11,7 +11,7 @@ module HTTPX
11
11
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
12
12
 
13
13
  type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout
14
- type timeout = Hash[timeout_type, Numeric?]
14
+ type timeout = Hash[timeout_type, Numeric]
15
15
 
16
16
  def self.new: (?options) -> instance
17
17
 
@@ -26,6 +26,9 @@ module HTTPX
26
26
  # timeout
27
27
  attr_reader timeout: timeout
28
28
 
29
+ # http2_settings
30
+ attr_reader http2_settings: Hash[Symbol, Integer | bool]
31
+
29
32
  # max_concurrent_requests
30
33
  attr_reader max_concurrent_requests: Integer?
31
34
 
@@ -45,7 +48,7 @@ module HTTPX
45
48
  attr_reader transport_options: Hash[untyped, untyped]?
46
49
 
47
50
  # addresses
48
- attr_reader addresses: _ToAry[ipaddr]?
51
+ attr_reader addresses: Array[ipaddr]?
49
52
 
50
53
  # params
51
54
  attr_reader params: Transcoder::urlencoded_input?
@@ -59,6 +62,9 @@ module HTTPX
59
62
  # body
60
63
  attr_reader body: bodyIO?
61
64
 
65
+ # body
66
+ attr_reader origin: URI::Generic?
67
+
62
68
  # ssl
63
69
 
64
70
  # http2_settings
@@ -103,13 +109,15 @@ module HTTPX
103
109
  attr_reader resolver_options: Hash[Symbol, untyped]?
104
110
 
105
111
  def ==: (untyped other) -> bool
106
- def merge: (_ToHash[Symbol | String, untyped] other) -> instance
112
+ def merge: (_ToHash[Symbol, untyped] other) -> instance
107
113
  def to_hash: () -> Hash[Symbol, untyped]
108
114
 
109
115
  private
110
116
 
111
- def initialize: (?options) -> untyped
117
+ REQUEST_IVARS: Array[Symbol]
118
+
119
+ def initialize: (?options options) -> untyped
112
120
  end
113
121
 
114
- type options = Options | Hash[Symbol | String, untyped]
122
+ type options = Options | Hash[Symbol, untyped]
115
123
  end
data/sig/parser/http1.rbs CHANGED
@@ -5,9 +5,9 @@ module HTTPX
5
5
  interface _HTTP1Events
6
6
 
7
7
  def on_start: () -> void
8
- def on_headers: (parsed_headers) -> void
9
- def on_trailers: (parsed_headers) -> void
10
- def on_data: (String) -> void
8
+ def on_headers: (parsed_headers headers) -> void
9
+ def on_trailers: (parsed_headers trailers) -> void
10
+ def on_data: (String data) -> void
11
11
  def on_complete: () -> void
12
12
  end
13
13
 
@@ -1,25 +1,43 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module AwsSdkAuthentication
4
+ class Configuration
5
+ attr_reader profile: String?
6
+
7
+ private
8
+
9
+ def initialize: (String? profile) -> void
10
+ end
11
+
4
12
  class Credentials
13
+ @aws_credentials: untyped
14
+
5
15
  include _SigV4Credentials
6
16
 
7
17
  private
8
-
18
+
9
19
  def initialize: (untyped aws_credentials) -> untyped
10
20
  end
11
21
 
22
+ interface _AwsSdkOptions
23
+ def aws_profile: () -> String?
24
+ end
25
+
12
26
  def self.load_dependencies: (singleton(Session)) -> void
13
27
 
14
28
  def self.configure: (singleton(Session)) -> void
15
29
 
16
- def self.extra_options: (Options) -> (Options)
30
+ def self.extra_options: (Options) -> (Options & _AwsSdkOptions)
31
+
32
+ def self.credentials: (String? profile) -> Credentials
33
+
34
+ def self.region: (String? profile) -> String
17
35
 
18
36
  module InstanceMethods
19
- def aws_sdk_authentication: (**untyped) -> instance
37
+ def aws_sdk_authentication: (?credentials: Credentials, ?region: String, **untyped) -> instance
20
38
  end
21
39
  end
22
40
 
23
- type sessionAwsSdkAuthentication = Session & AwsSdkAuthentication::InstanceMethods
41
+ type sessionAwsSdkAuthentication = awsSigV4Session & AwsSdkAuthentication::InstanceMethods
24
42
  end
25
43
  end
@@ -9,13 +9,21 @@ module HTTPX
9
9
 
10
10
  module AWSSigV4
11
11
 
12
- Credentials: _SigV4Credentials
12
+ class Credentials < Struct[[String, String, String?]]
13
+ attr_reader username: String
14
+ attr_reader password: String
15
+ attr_reader security_token: String?
16
+ end
13
17
 
14
18
 
15
19
  class Signer
16
20
 
17
- def sign!: (Request) -> void
21
+ @unsigned_headers: Set[String]
22
+
23
+ def sign!: (Request & RequestMethods request) -> void
18
24
 
25
+ def self.new: (instance) -> instance
26
+ | (**untyped params) -> instance
19
27
  private
20
28
 
21
29
  def initialize: (
@@ -33,9 +41,10 @@ module HTTPX
33
41
  ) -> untyped
34
42
 
35
43
 
36
- def sha256_hexdigest: (bodyIO value) -> String
44
+ def hexdigest: (bodyIO value) -> String
37
45
 
38
46
  def hmac: (String key, String value) -> String
47
+
39
48
  def hexhmac: (String key, String value) -> String
40
49
  end
41
50
 
@@ -10,6 +10,6 @@ module HTTPX
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuthentication = sessionAuthentication & BasicAuthentication::InstanceMethods
13
+ type sessionBasicAuthentication = sessionAuthentication & Authentication::InstanceMethods & BasicAuthentication::InstanceMethods
14
14
  end
15
15
  end
@@ -1,41 +1,97 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Multipart
4
+ interface _MultipartInput
5
+ def filename: () -> String
6
+ def content_type: () -> String
7
+ def read: (?int? length, ?string? output) -> String?
8
+ end
9
+
10
+ MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
11
+
4
12
  def self.load_dependencies: (singleton(Session)) -> void
5
13
  def self.configure: (*untyped) -> void
6
14
  def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
15
+ def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
16
+
17
+ def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> U } -> U
7
18
 
8
19
  type multipart_value = string | Pathname | File | _Reader
9
20
 
10
- type record_multipart_value = multipart_value |
11
- { content_type: String, filename: String, body: multipart_value } |
21
+ type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
12
22
  { content_type: String, body: multipart_value }
13
23
 
14
24
  type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
15
25
 
16
26
  class Encoder
17
27
  include Transcoder::_Encoder
18
- include _Reader
28
+
29
+ @boundary: String
30
+ @part_index: Integer
31
+ @buffer: String
32
+
33
+ @form: Enumerable[[Symbol | string, multipart_nested_value]]
34
+ @parts: Array[_Reader]
19
35
 
20
36
  def content_type: () -> String
21
37
 
38
+ def read: (?int? length, ?string? buffer) -> String?
39
+
40
+ def rewind: () -> void
41
+
22
42
  private
23
43
 
24
- def initialize: (_Each[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
44
+ def to_parts: (Enumerable[[Symbol | string, multipart_nested_value]] multipart_data) -> Array[_Reader]
45
+
46
+ def initialize: (Enumerable[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
25
47
 
26
48
  def header_part: (string key, String content_type, String? filename) -> StringIO
27
49
 
28
- def read_chunks: (String buffer, Integer? length) -> void
50
+ def read_chunks: (String buffer, ?Integer? length) -> void
29
51
 
30
- def read_from_part: (Integer? max_length) -> void
52
+ def read_from_part: (?Integer? max_length) -> String?
53
+ end
54
+
55
+ class Decoder
56
+ BOUNDARY_RE: Regexp
57
+
58
+ @state: :idle | :part_header | :part_body | :parse_boundary | :done
59
+ @buffer: String
60
+ @parts: Hash[String, untyped]
61
+ @boundary: String
62
+ @intermediate_boundary: String
63
+
64
+ def call: (Response response, untyped) -> Hash[String, untyped]
65
+
66
+ private
67
+
68
+ def initialize: (Response response) -> void
69
+
70
+ def parse: () -> void
71
+
72
+ def get_filename: (String head) -> String?
73
+ end
74
+
75
+ class FilePart # < SimpleDelegator
76
+ attr_reader original_filename: String
77
+ attr_reader content_type: String
78
+
79
+ # @file: Tempfile
80
+
81
+ # private
82
+
83
+ def initialize: (String filename, String content_type) -> void
31
84
  end
32
85
 
33
86
  module Part
34
- def self?.call: (multipart_nested_value) -> ([_Reader, String, String?])
87
+ def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
88
+ | (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
35
89
  end
36
90
 
37
91
  module MimeTypeDetector
38
- def self?.call: (::IO file, ?String filename) -> String?
92
+ DEFAULT_MIMETYPE: String
93
+
94
+ def self?.call: (::IO file, String filename) -> String?
39
95
  end
40
96
  end
41
97
  end
@@ -9,8 +9,8 @@ module HTTPX
9
9
 
10
10
  class Parameters
11
11
  attr_reader uri: URI::Generic
12
- attr_reader username: string?
13
- attr_reader password: string?
12
+ attr_reader username: String?
13
+ attr_reader password: String?
14
14
 
15
15
  def authenticated?: () -> boolish
16
16
  def token_authentication: () -> String?
@@ -19,7 +19,7 @@ module HTTPX
19
19
 
20
20
  private
21
21
 
22
- def initialize: (uri: generic_uri, ?username: string, ?password: string) -> untyped
22
+ def initialize: (uri: generic_uri, ?username: String, ?password: String) -> untyped
23
23
  end
24
24
 
25
25
  def self.configure: (singleton(Session)) -> void
@@ -35,9 +35,9 @@ module HTTPX
35
35
  module InstanceMethods
36
36
  private
37
37
 
38
- def proxy_uris: (uri, Options & _ProxyOptions) -> { uri: (URI | string), username: string, password: string }
39
- | (uri, Options & _ProxyOptions) -> { uri: (URI | string) }
40
- | (uri, Options & _ProxyOptions) -> nil
38
+ def proxy_uris: (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri, username: String, password: String }
39
+ | (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri }
40
+ | (generic_uri, Options & _ProxyOptions) -> nil
41
41
  end
42
42
  end
43
43
 
@@ -0,0 +1,35 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module ResponseCache
4
+ CACHEABLE_VERBS: Array[Symbol]
5
+
6
+ def self?.cacheable_request?: (Request request) -> bool
7
+ def self?.cacheable_response?: (response response) -> bool
8
+ def self?.cached_response?: (response response) -> bool
9
+
10
+ class Store
11
+ @store: Hash[URI::Generic, Response]
12
+
13
+ def lookup: (URI::Generic uri) -> Response?
14
+
15
+ def cached?: (URI::Generic uri) -> bool
16
+
17
+ def cache: (URI::Generic uri, Response response) -> void
18
+
19
+ def prepare: (Request request) -> void
20
+ end
21
+
22
+ module InstanceMethods
23
+ @response_cache: Store
24
+
25
+ def clear_response_cache: () -> void
26
+ end
27
+
28
+ module ResponseMethods
29
+ def copy_from_cached: (Response other) -> void
30
+ end
31
+ end
32
+
33
+ type sessionResponseCache = Session & ResponseCache::InstanceMethods
34
+ end
35
+ end
@@ -4,6 +4,7 @@ module HTTPX
4
4
  MAX_RETRIES: Integer
5
5
  IDEMPOTENT_METHODS: Array[verb]
6
6
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
7
+ DEFAULT_JITTER: ^(Numeric) -> Numeric
7
8
 
8
9
  interface _RetryCallback
9
10
  def call: (response) -> bool?
@@ -12,6 +13,8 @@ module HTTPX
12
13
  interface _RetriesOptions
13
14
  def retry_after: () -> Numeric?
14
15
 
16
+ def retry_jitter: () -> ^(Numeric) -> Numeric
17
+
15
18
  def max_retries: () -> Integer?
16
19
 
17
20
  def retry_change_requests: () -> boolish
data/sig/pool.rbs CHANGED
@@ -10,6 +10,8 @@ module HTTPX
10
10
 
11
11
  def find_connection: (generic_uri, Options) -> Connection?
12
12
 
13
+ def deactivate: (*Array[Connection]) -> void
14
+
13
15
  private
14
16
 
15
17
  def initialize: () -> untyped
@@ -26,6 +28,10 @@ module HTTPX
26
28
 
27
29
  def unregister_connection: (Connection) -> void
28
30
 
31
+ def select_connection: (resolver | Connection connection) -> void
32
+
33
+ def deselect_connection: (resolver | Connection connection) -> void
34
+
29
35
  def coalesce_connections: (Connection, Connection) -> void
30
36
 
31
37
  def next_timeout: () -> Numeric?