http 5.3.1 → 6.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +241 -41
- data/LICENSE.txt +1 -1
- data/README.md +110 -13
- data/UPGRADING.md +491 -0
- data/http.gemspec +32 -29
- data/lib/http/base64.rb +11 -1
- data/lib/http/chainable/helpers.rb +62 -0
- data/lib/http/chainable/verbs.rb +136 -0
- data/lib/http/chainable.rb +232 -136
- data/lib/http/client.rb +158 -127
- data/lib/http/connection/internals.rb +141 -0
- data/lib/http/connection.rb +126 -97
- data/lib/http/content_type.rb +61 -6
- data/lib/http/errors.rb +25 -1
- data/lib/http/feature.rb +65 -5
- data/lib/http/features/auto_deflate.rb +124 -17
- data/lib/http/features/auto_inflate.rb +38 -15
- data/lib/http/features/caching/entry.rb +178 -0
- data/lib/http/features/caching/in_memory_store.rb +63 -0
- data/lib/http/features/caching.rb +216 -0
- data/lib/http/features/digest_auth.rb +234 -0
- data/lib/http/features/instrumentation.rb +97 -17
- data/lib/http/features/logging.rb +183 -5
- data/lib/http/features/normalize_uri.rb +17 -0
- data/lib/http/features/raise_error.rb +18 -3
- data/lib/http/form_data/composite_io.rb +106 -0
- data/lib/http/form_data/file.rb +95 -0
- data/lib/http/form_data/multipart/param.rb +62 -0
- data/lib/http/form_data/multipart.rb +106 -0
- data/lib/http/form_data/part.rb +52 -0
- data/lib/http/form_data/readable.rb +58 -0
- data/lib/http/form_data/urlencoded.rb +175 -0
- data/lib/http/form_data/version.rb +8 -0
- data/lib/http/form_data.rb +102 -0
- data/lib/http/headers/known.rb +3 -0
- data/lib/http/headers/normalizer.rb +17 -36
- data/lib/http/headers.rb +172 -65
- data/lib/http/mime_type/adapter.rb +24 -9
- data/lib/http/mime_type/json.rb +19 -4
- data/lib/http/mime_type.rb +21 -3
- data/lib/http/options/definitions.rb +189 -0
- data/lib/http/options.rb +172 -125
- data/lib/http/redirector.rb +80 -75
- data/lib/http/request/body.rb +87 -6
- data/lib/http/request/builder.rb +184 -0
- data/lib/http/request/proxy.rb +83 -0
- data/lib/http/request/writer.rb +76 -16
- data/lib/http/request.rb +214 -98
- data/lib/http/response/body.rb +103 -18
- data/lib/http/response/inflater.rb +35 -7
- data/lib/http/response/parser.rb +98 -4
- data/lib/http/response/status/reasons.rb +2 -4
- data/lib/http/response/status.rb +141 -31
- data/lib/http/response.rb +219 -61
- data/lib/http/retriable/delay_calculator.rb +38 -11
- data/lib/http/retriable/errors.rb +21 -0
- data/lib/http/retriable/performer.rb +82 -38
- data/lib/http/session.rb +280 -0
- data/lib/http/timeout/global.rb +147 -34
- data/lib/http/timeout/null.rb +155 -9
- data/lib/http/timeout/per_operation.rb +139 -18
- data/lib/http/uri/normalizer.rb +82 -0
- data/lib/http/uri/parsing.rb +182 -0
- data/lib/http/uri.rb +289 -124
- data/lib/http/version.rb +2 -1
- data/lib/http.rb +11 -2
- data/sig/deps.rbs +122 -0
- data/sig/http.rbs +1619 -0
- data/test/http/base64_test.rb +28 -0
- data/test/http/client_test.rb +739 -0
- data/test/http/connection_test.rb +1533 -0
- data/test/http/content_type_test.rb +190 -0
- data/test/http/errors_test.rb +28 -0
- data/test/http/feature_test.rb +49 -0
- data/test/http/features/auto_deflate_test.rb +317 -0
- data/test/http/features/auto_inflate_test.rb +213 -0
- data/test/http/features/caching_test.rb +942 -0
- data/test/http/features/digest_auth_test.rb +996 -0
- data/test/http/features/instrumentation_test.rb +246 -0
- data/test/http/features/logging_test.rb +654 -0
- data/test/http/features/normalize_uri_test.rb +41 -0
- data/test/http/features/raise_error_test.rb +77 -0
- data/test/http/form_data/composite_io_test.rb +215 -0
- data/test/http/form_data/file_test.rb +255 -0
- data/test/http/form_data/fixtures/the-http-gem.info +1 -0
- data/test/http/form_data/multipart_test.rb +303 -0
- data/test/http/form_data/part_test.rb +90 -0
- data/test/http/form_data/urlencoded_test.rb +164 -0
- data/test/http/form_data_test.rb +232 -0
- data/test/http/headers/normalizer_test.rb +93 -0
- data/test/http/headers_test.rb +888 -0
- data/test/http/mime_type/json_test.rb +39 -0
- data/test/http/mime_type_test.rb +150 -0
- data/test/http/options/base_uri_test.rb +148 -0
- data/test/http/options/body_test.rb +21 -0
- data/test/http/options/features_test.rb +38 -0
- data/test/http/options/form_test.rb +21 -0
- data/test/http/options/headers_test.rb +32 -0
- data/test/http/options/json_test.rb +21 -0
- data/test/http/options/merge_test.rb +78 -0
- data/test/http/options/new_test.rb +37 -0
- data/test/http/options/proxy_test.rb +32 -0
- data/test/http/options_test.rb +575 -0
- data/test/http/redirector_test.rb +639 -0
- data/test/http/request/body_test.rb +318 -0
- data/test/http/request/builder_test.rb +623 -0
- data/test/http/request/writer_test.rb +391 -0
- data/test/http/request_test.rb +1733 -0
- data/test/http/response/body_test.rb +292 -0
- data/test/http/response/parser_test.rb +105 -0
- data/test/http/response/status_test.rb +322 -0
- data/test/http/response_test.rb +502 -0
- data/test/http/retriable/delay_calculator_test.rb +194 -0
- data/test/http/retriable/errors_test.rb +71 -0
- data/test/http/retriable/performer_test.rb +551 -0
- data/test/http/session_test.rb +424 -0
- data/test/http/timeout/global_test.rb +239 -0
- data/test/http/timeout/null_test.rb +218 -0
- data/test/http/timeout/per_operation_test.rb +220 -0
- data/test/http/uri/normalizer_test.rb +89 -0
- data/test/http/uri_test.rb +1140 -0
- data/test/http/version_test.rb +15 -0
- data/test/http_test.rb +818 -0
- data/test/regression_tests.rb +27 -0
- data/test/support/dummy_server/encoding_routes.rb +47 -0
- data/test/support/dummy_server/routes.rb +201 -0
- data/test/support/dummy_server/servlet.rb +81 -0
- data/test/support/dummy_server.rb +200 -0
- data/{spec → test}/support/fakeio.rb +2 -2
- data/test/support/http_handling_shared/connection_reuse_tests.rb +97 -0
- data/test/support/http_handling_shared/timeout_tests.rb +134 -0
- data/test/support/http_handling_shared.rb +11 -0
- data/test/support/proxy_server.rb +207 -0
- data/test/support/servers/runner.rb +67 -0
- data/{spec → test}/support/simplecov.rb +11 -2
- data/test/support/ssl_helper.rb +108 -0
- data/test/test_helper.rb +38 -0
- metadata +108 -168
- data/.github/workflows/ci.yml +0 -67
- data/.gitignore +0 -15
- data/.rspec +0 -1
- data/.rubocop/layout.yml +0 -8
- data/.rubocop/metrics.yml +0 -4
- data/.rubocop/rspec.yml +0 -9
- data/.rubocop/style.yml +0 -32
- data/.rubocop.yml +0 -11
- data/.rubocop_todo.yml +0 -219
- data/.yardopts +0 -2
- data/CHANGES_OLD.md +0 -1002
- data/Gemfile +0 -51
- data/Guardfile +0 -18
- data/Rakefile +0 -64
- data/lib/http/headers/mixin.rb +0 -34
- data/lib/http/retriable/client.rb +0 -37
- data/logo.png +0 -0
- data/spec/lib/http/client_spec.rb +0 -556
- data/spec/lib/http/connection_spec.rb +0 -88
- data/spec/lib/http/content_type_spec.rb +0 -47
- data/spec/lib/http/features/auto_deflate_spec.rb +0 -77
- data/spec/lib/http/features/auto_inflate_spec.rb +0 -86
- data/spec/lib/http/features/instrumentation_spec.rb +0 -81
- data/spec/lib/http/features/logging_spec.rb +0 -65
- data/spec/lib/http/features/raise_error_spec.rb +0 -62
- data/spec/lib/http/headers/mixin_spec.rb +0 -36
- data/spec/lib/http/headers/normalizer_spec.rb +0 -52
- data/spec/lib/http/headers_spec.rb +0 -527
- data/spec/lib/http/options/body_spec.rb +0 -15
- data/spec/lib/http/options/features_spec.rb +0 -33
- data/spec/lib/http/options/form_spec.rb +0 -15
- data/spec/lib/http/options/headers_spec.rb +0 -24
- data/spec/lib/http/options/json_spec.rb +0 -15
- data/spec/lib/http/options/merge_spec.rb +0 -68
- data/spec/lib/http/options/new_spec.rb +0 -30
- data/spec/lib/http/options/proxy_spec.rb +0 -20
- data/spec/lib/http/options_spec.rb +0 -13
- data/spec/lib/http/redirector_spec.rb +0 -530
- data/spec/lib/http/request/body_spec.rb +0 -211
- data/spec/lib/http/request/writer_spec.rb +0 -121
- data/spec/lib/http/request_spec.rb +0 -234
- data/spec/lib/http/response/body_spec.rb +0 -85
- data/spec/lib/http/response/parser_spec.rb +0 -74
- data/spec/lib/http/response/status_spec.rb +0 -253
- data/spec/lib/http/response_spec.rb +0 -262
- data/spec/lib/http/retriable/delay_calculator_spec.rb +0 -69
- data/spec/lib/http/retriable/performer_spec.rb +0 -302
- data/spec/lib/http/uri/normalizer_spec.rb +0 -95
- data/spec/lib/http/uri_spec.rb +0 -71
- data/spec/lib/http_spec.rb +0 -535
- data/spec/regression_specs.rb +0 -24
- data/spec/spec_helper.rb +0 -89
- data/spec/support/black_hole.rb +0 -13
- data/spec/support/dummy_server/servlet.rb +0 -203
- data/spec/support/dummy_server.rb +0 -44
- data/spec/support/fuubar.rb +0 -21
- data/spec/support/http_handling_shared.rb +0 -190
- data/spec/support/proxy_server.rb +0 -39
- data/spec/support/servers/config.rb +0 -11
- data/spec/support/servers/runner.rb +0 -19
- data/spec/support/ssl_helper.rb +0 -104
- /data/{spec → test}/support/capture_warning.rb +0 -0
data/sig/http.rbs
ADDED
|
@@ -0,0 +1,1619 @@
|
|
|
1
|
+
# Type signatures for the http gem
|
|
2
|
+
|
|
3
|
+
module HTTP
|
|
4
|
+
VERSION: String
|
|
5
|
+
|
|
6
|
+
extend Chainable
|
|
7
|
+
|
|
8
|
+
def self.[]: (Hash[String | Symbol, String] headers) -> Session
|
|
9
|
+
|
|
10
|
+
module Base64
|
|
11
|
+
def self?.encode64: (String input) -> String
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Chainable
|
|
15
|
+
include Base64
|
|
16
|
+
include Chainable::Verbs
|
|
17
|
+
|
|
18
|
+
PROXY_ARG_MAP: Array[[Symbol, Integer, Class]]
|
|
19
|
+
|
|
20
|
+
@default_options: Options
|
|
21
|
+
|
|
22
|
+
module Verbs : _VerbsHost
|
|
23
|
+
interface _VerbsHost
|
|
24
|
+
def request: (verb verb, String | URI uri, **untyped) -> Response
|
|
25
|
+
| [T] (verb verb, String | URI uri, **untyped) { (Response) -> T } -> T
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def head: (String | URI uri, **untyped opts) -> Response
|
|
29
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
30
|
+
def get: (String | URI uri, **untyped opts) -> Response
|
|
31
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
32
|
+
def post: (String | URI uri, **untyped opts) -> Response
|
|
33
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
34
|
+
def put: (String | URI uri, **untyped opts) -> Response
|
|
35
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
36
|
+
def delete: (String | URI uri, **untyped opts) -> Response
|
|
37
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
38
|
+
def trace: (String | URI uri, **untyped opts) -> Response
|
|
39
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
40
|
+
def options: (String | URI uri, **untyped opts) -> Response
|
|
41
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
42
|
+
def connect: (String | URI uri, **untyped opts) -> Response
|
|
43
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
44
|
+
def patch: (String | URI uri, **untyped opts) -> Response
|
|
45
|
+
| [T] (String | URI uri, **untyped opts) { (Response) -> T } -> T
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def request: (
|
|
49
|
+
verb verb,
|
|
50
|
+
String | URI uri,
|
|
51
|
+
?response: Symbol,
|
|
52
|
+
?encoding: Encoding?,
|
|
53
|
+
?nodelay: bool,
|
|
54
|
+
?keep_alive_timeout: Integer,
|
|
55
|
+
?proxy: Hash[Symbol, untyped],
|
|
56
|
+
?ssl: Hash[Symbol, untyped],
|
|
57
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
58
|
+
?features: Hash[Symbol, untyped],
|
|
59
|
+
?timeout_class: Class,
|
|
60
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
61
|
+
?socket_class: Class,
|
|
62
|
+
?ssl_socket_class: Class,
|
|
63
|
+
?params: untyped,
|
|
64
|
+
?form: untyped,
|
|
65
|
+
?json: untyped,
|
|
66
|
+
?body: untyped,
|
|
67
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
68
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
69
|
+
?base_uri: String | URI?,
|
|
70
|
+
?persistent: String?,
|
|
71
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
72
|
+
) -> Response
|
|
73
|
+
| [T] (
|
|
74
|
+
verb verb,
|
|
75
|
+
String | URI uri,
|
|
76
|
+
?response: Symbol,
|
|
77
|
+
?encoding: Encoding?,
|
|
78
|
+
?nodelay: bool,
|
|
79
|
+
?keep_alive_timeout: Integer,
|
|
80
|
+
?proxy: Hash[Symbol, untyped],
|
|
81
|
+
?ssl: Hash[Symbol, untyped],
|
|
82
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
83
|
+
?features: Hash[Symbol, untyped],
|
|
84
|
+
?timeout_class: Class,
|
|
85
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
86
|
+
?socket_class: Class,
|
|
87
|
+
?ssl_socket_class: Class,
|
|
88
|
+
?params: untyped,
|
|
89
|
+
?form: untyped,
|
|
90
|
+
?json: untyped,
|
|
91
|
+
?body: untyped,
|
|
92
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
93
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
94
|
+
?base_uri: String | URI?,
|
|
95
|
+
?persistent: String?,
|
|
96
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
97
|
+
) { (Response) -> T } -> T
|
|
98
|
+
def timeout: (Numeric | Hash[Symbol, Numeric] | :null options) -> Session
|
|
99
|
+
def base_uri: (String | URI uri) -> Session
|
|
100
|
+
def persistent: (?String? host, ?timeout: Integer) -> Session
|
|
101
|
+
| [T] (?String? host, ?timeout: Integer) { (Session) -> T } -> T
|
|
102
|
+
def via: (*(String | Integer | Hash[String, String]) proxy) -> Session
|
|
103
|
+
alias through via
|
|
104
|
+
def follow: (?strict: bool, ?max_hops: Integer, ?on_redirect: (^(Response, Request) -> void)?) -> Session
|
|
105
|
+
def headers: (Hash[String | Symbol, untyped] headers) -> Session
|
|
106
|
+
def cookies: (Hash[String | Symbol, String] | Array[Cookie] cookies) -> Session
|
|
107
|
+
def encoding: (String | Encoding encoding) -> Session
|
|
108
|
+
def accept: (String | Symbol type) -> Session
|
|
109
|
+
def auth: (String value) -> Session
|
|
110
|
+
def basic_auth: (user: String, pass: String) -> Session
|
|
111
|
+
def digest_auth: (user: String, pass: String) -> Session
|
|
112
|
+
def default_options: () -> Options
|
|
113
|
+
def default_options=: (Hash[Symbol, untyped] | Options opts) -> Options
|
|
114
|
+
def nodelay: () -> Session
|
|
115
|
+
def use: (*(Symbol | Hash[Symbol, Hash[Symbol, untyped]]) features) -> Session
|
|
116
|
+
def retriable: (?tries: Integer?, ?delay: (Numeric | ^(Integer) -> Numeric)?, ?exceptions: Array[singleton(Exception)]?, ?retry_statuses: untyped, ?on_retry: (^(Request, Exception?, Response?) -> void)?, ?max_delay: Numeric?, ?should_retry: (^(Request, Exception?, Response?, Integer) -> bool)?) -> Session
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def branch: (Options options) -> Session
|
|
121
|
+
def make_client: (Options options) -> Client
|
|
122
|
+
def build_proxy_hash: (Array[String | Integer | Hash[String, String]] proxy) -> Hash[Symbol, String | Integer | Hash[String, String]]
|
|
123
|
+
def resolve_timeout_hash: (Hash[Symbol, Numeric] options) -> [Class, Hash[Symbol, Numeric]]
|
|
124
|
+
def resolve_global_only: (Numeric? global) -> [Class, Hash[Symbol, Numeric]]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class Client
|
|
128
|
+
extend Forwardable
|
|
129
|
+
include Chainable
|
|
130
|
+
|
|
131
|
+
@default_options: Options
|
|
132
|
+
@connection: untyped
|
|
133
|
+
@state: Symbol
|
|
134
|
+
|
|
135
|
+
def initialize: (?Options? default_options, **untyped) -> void
|
|
136
|
+
def request: (
|
|
137
|
+
verb verb,
|
|
138
|
+
String | URI uri,
|
|
139
|
+
?response: Symbol,
|
|
140
|
+
?encoding: Encoding?,
|
|
141
|
+
?nodelay: bool,
|
|
142
|
+
?keep_alive_timeout: Integer,
|
|
143
|
+
?proxy: Hash[Symbol, untyped],
|
|
144
|
+
?ssl: Hash[Symbol, untyped],
|
|
145
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
146
|
+
?features: Hash[Symbol, untyped],
|
|
147
|
+
?timeout_class: Class,
|
|
148
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
149
|
+
?socket_class: Class,
|
|
150
|
+
?ssl_socket_class: Class,
|
|
151
|
+
?params: untyped,
|
|
152
|
+
?form: untyped,
|
|
153
|
+
?json: untyped,
|
|
154
|
+
?body: untyped,
|
|
155
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
156
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
157
|
+
?base_uri: String | URI?,
|
|
158
|
+
?persistent: String?,
|
|
159
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
160
|
+
) -> Response
|
|
161
|
+
def persistent?: () -> bool
|
|
162
|
+
def perform: (Request req, Options options) -> Response
|
|
163
|
+
def close: () -> void
|
|
164
|
+
|
|
165
|
+
private
|
|
166
|
+
|
|
167
|
+
def perform_once: (Request req, Options options) -> Response
|
|
168
|
+
def perform_with_retry: (Request req, Options options) -> Response
|
|
169
|
+
def notify_features: (Request req, Options options) -> void
|
|
170
|
+
def perform_exchange: (Request req, Options options) -> Response
|
|
171
|
+
def around_request: (Request request, Options options) { (Request) -> Response } -> Response
|
|
172
|
+
def build_response: (Request req, Options options) -> Response
|
|
173
|
+
def build_wrapped_response: (Request req, Options options) -> Response
|
|
174
|
+
def send_request: (Request req, Options options) -> void
|
|
175
|
+
def verify_connection!: (URI uri) -> void
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
class Session
|
|
179
|
+
extend Forwardable
|
|
180
|
+
include Chainable
|
|
181
|
+
|
|
182
|
+
@default_options: Options
|
|
183
|
+
@clients: Hash[String, Client]
|
|
184
|
+
|
|
185
|
+
def initialize: (?Options? default_options, ?clients: Hash[String, Client]?, **untyped) -> void
|
|
186
|
+
def close: () -> void
|
|
187
|
+
def request: (
|
|
188
|
+
verb verb,
|
|
189
|
+
String | URI uri,
|
|
190
|
+
?response: Symbol,
|
|
191
|
+
?encoding: Encoding?,
|
|
192
|
+
?nodelay: bool,
|
|
193
|
+
?keep_alive_timeout: Integer,
|
|
194
|
+
?proxy: Hash[Symbol, untyped],
|
|
195
|
+
?ssl: Hash[Symbol, untyped],
|
|
196
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
197
|
+
?features: Hash[Symbol, untyped],
|
|
198
|
+
?timeout_class: Class,
|
|
199
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
200
|
+
?socket_class: Class,
|
|
201
|
+
?ssl_socket_class: Class,
|
|
202
|
+
?params: untyped,
|
|
203
|
+
?form: untyped,
|
|
204
|
+
?json: untyped,
|
|
205
|
+
?body: untyped,
|
|
206
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
207
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
208
|
+
?base_uri: String | URI?,
|
|
209
|
+
?persistent: String?,
|
|
210
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
211
|
+
) -> Response
|
|
212
|
+
| [T] (
|
|
213
|
+
verb verb,
|
|
214
|
+
String | URI uri,
|
|
215
|
+
?response: Symbol,
|
|
216
|
+
?encoding: Encoding?,
|
|
217
|
+
?nodelay: bool,
|
|
218
|
+
?keep_alive_timeout: Integer,
|
|
219
|
+
?proxy: Hash[Symbol, untyped],
|
|
220
|
+
?ssl: Hash[Symbol, untyped],
|
|
221
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
222
|
+
?features: Hash[Symbol, untyped],
|
|
223
|
+
?timeout_class: Class,
|
|
224
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
225
|
+
?socket_class: Class,
|
|
226
|
+
?ssl_socket_class: Class,
|
|
227
|
+
?params: untyped,
|
|
228
|
+
?form: untyped,
|
|
229
|
+
?json: untyped,
|
|
230
|
+
?body: untyped,
|
|
231
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
232
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
233
|
+
?base_uri: String | URI?,
|
|
234
|
+
?persistent: String?,
|
|
235
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
236
|
+
) { (Response) -> T } -> T
|
|
237
|
+
def persistent?: () -> bool
|
|
238
|
+
|
|
239
|
+
private
|
|
240
|
+
|
|
241
|
+
def branch: (Options options) -> Session
|
|
242
|
+
def perform_request: (Client? client, verb verb, untyped uri, Options merged) -> Response
|
|
243
|
+
def perform_redirects: (CookieJar jar, Client client, Request req, Response res, Options opts) -> Response
|
|
244
|
+
def redirect_client: (Client client, Request request) -> Client
|
|
245
|
+
def client_for_origin: (String origin) -> Client
|
|
246
|
+
def options_for_origin: (String origin) -> Options
|
|
247
|
+
def load_cookies: (CookieJar jar, Request request) -> void
|
|
248
|
+
def store_cookies: (CookieJar jar, Response response) -> void
|
|
249
|
+
def apply_cookies: (CookieJar jar, Request request) -> void
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
class Headers
|
|
253
|
+
extend Forwardable
|
|
254
|
+
include Enumerable[Array[String]]
|
|
255
|
+
|
|
256
|
+
ACCEPT: String
|
|
257
|
+
ACCEPT_ENCODING: String
|
|
258
|
+
AGE: String
|
|
259
|
+
AUTHORIZATION: String
|
|
260
|
+
CACHE_CONTROL: String
|
|
261
|
+
COOKIE: String
|
|
262
|
+
CONNECTION: String
|
|
263
|
+
CONTENT_LENGTH: String
|
|
264
|
+
CONTENT_TYPE: String
|
|
265
|
+
DATE: String
|
|
266
|
+
ETAG: String
|
|
267
|
+
EXPIRES: String
|
|
268
|
+
HOST: String
|
|
269
|
+
IF_MODIFIED_SINCE: String
|
|
270
|
+
IF_NONE_MATCH: String
|
|
271
|
+
LAST_MODIFIED: String
|
|
272
|
+
LOCATION: String
|
|
273
|
+
PROXY_AUTHORIZATION: String
|
|
274
|
+
SET_COOKIE: String
|
|
275
|
+
TRANSFER_ENCODING: String
|
|
276
|
+
CHUNKED: String
|
|
277
|
+
CONTENT_ENCODING: String
|
|
278
|
+
USER_AGENT: String
|
|
279
|
+
VARY: String
|
|
280
|
+
|
|
281
|
+
@pile: Array[untyped]
|
|
282
|
+
self.@normalizer: Normalizer
|
|
283
|
+
|
|
284
|
+
def self.coerce: (untyped object) -> Headers
|
|
285
|
+
def self.[]: (untyped object) -> Headers
|
|
286
|
+
def self.normalizer: () -> Headers::Normalizer
|
|
287
|
+
|
|
288
|
+
def initialize: () -> void
|
|
289
|
+
def set: (String | Symbol name, String | Array[String] value) -> void
|
|
290
|
+
alias []= set
|
|
291
|
+
def delete: (String | Symbol name) -> void
|
|
292
|
+
def add: (String | Symbol name, String | Array[String] value) -> void
|
|
293
|
+
def get: (String | Symbol name) -> Array[String]
|
|
294
|
+
def []: (String | Symbol name) -> (String | Array[String]?)
|
|
295
|
+
def include?: (String | Symbol name) -> bool
|
|
296
|
+
def to_h: () -> Hash[String, String | Array[String]?]
|
|
297
|
+
alias to_hash to_h
|
|
298
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, String | Array[String]?]
|
|
299
|
+
def to_a: () -> Array[Array[String]]
|
|
300
|
+
def inspect: () -> String
|
|
301
|
+
def keys: () -> Array[String]
|
|
302
|
+
def ==: (untyped other) -> bool
|
|
303
|
+
def each: () { (Array[String]) -> void } -> Headers
|
|
304
|
+
| () -> Enumerator[Array[String], Headers]
|
|
305
|
+
def empty?: () -> bool
|
|
306
|
+
def hash: () -> Integer
|
|
307
|
+
def initialize_copy: (self orig) -> void
|
|
308
|
+
def merge!: (untyped other) -> void
|
|
309
|
+
def merge: (untyped other) -> Headers
|
|
310
|
+
|
|
311
|
+
private
|
|
312
|
+
|
|
313
|
+
def wire_name_for: (String | Symbol name, String lookup_name) -> String
|
|
314
|
+
def normalize_header: (String | Symbol name) -> String
|
|
315
|
+
def validate_value: (String | Array[String] value) -> String
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
class Headers
|
|
319
|
+
class Normalizer
|
|
320
|
+
COMPLIANT_NAME_RE: Regexp
|
|
321
|
+
NAME_PARTS_SEPARATOR_RE: Regexp
|
|
322
|
+
CACHE_KEY: Symbol
|
|
323
|
+
|
|
324
|
+
def call: (String | Symbol name) -> String
|
|
325
|
+
|
|
326
|
+
private
|
|
327
|
+
|
|
328
|
+
def normalize_header: (String name) -> String
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
class ContentType
|
|
333
|
+
MIME_TYPE_RE: Regexp
|
|
334
|
+
CHARSET_RE: Regexp
|
|
335
|
+
|
|
336
|
+
attr_accessor mime_type: String?
|
|
337
|
+
attr_accessor charset: String?
|
|
338
|
+
|
|
339
|
+
def self.parse: (untyped str) -> ContentType
|
|
340
|
+
|
|
341
|
+
private
|
|
342
|
+
|
|
343
|
+
def self.mime_type: (untyped str) -> String?
|
|
344
|
+
def self.charset: (untyped str) -> String?
|
|
345
|
+
|
|
346
|
+
public
|
|
347
|
+
|
|
348
|
+
def initialize: (?String? mime_type, ?String? charset) -> void
|
|
349
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, String?]
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
class Feature
|
|
353
|
+
def wrap_request: (Request request) -> Request
|
|
354
|
+
def wrap_response: (Response response) -> Response
|
|
355
|
+
def on_request: (Request _request) -> nil
|
|
356
|
+
def around_request: (Request request) { (Request) -> Response } -> Response
|
|
357
|
+
def on_error: (Request _request, Exception _error) -> nil
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
module Features
|
|
361
|
+
class AutoDeflate < Feature
|
|
362
|
+
VALID_METHODS: Set[String]
|
|
363
|
+
|
|
364
|
+
attr_reader method: String
|
|
365
|
+
|
|
366
|
+
def initialize: (?method: String) -> void
|
|
367
|
+
def wrap_request: (Request request) -> Request
|
|
368
|
+
def deflated_body: (Request::Body body) -> CompressedBody?
|
|
369
|
+
|
|
370
|
+
private
|
|
371
|
+
|
|
372
|
+
def build_deflated_request: (Request request) -> Request
|
|
373
|
+
|
|
374
|
+
public
|
|
375
|
+
|
|
376
|
+
class CompressedBody < Request::Body
|
|
377
|
+
@body: Request::Body
|
|
378
|
+
@compressed: Tempfile?
|
|
379
|
+
|
|
380
|
+
def initialize: (Request::Body uncompressed_body) -> void
|
|
381
|
+
def size: () -> Integer
|
|
382
|
+
def each: () { (String) -> void } -> self
|
|
383
|
+
| () -> Enumerator[String, self]
|
|
384
|
+
def compress: () ?{ (String) -> void } -> void
|
|
385
|
+
|
|
386
|
+
private
|
|
387
|
+
|
|
388
|
+
def compressed_each: () { (String) -> void } -> void
|
|
389
|
+
def compress_all!: () -> void
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
class GzippedBody < CompressedBody
|
|
393
|
+
def compress: () ?{ (String) -> void } -> void
|
|
394
|
+
|
|
395
|
+
class BlockIO
|
|
396
|
+
@block: Proc
|
|
397
|
+
|
|
398
|
+
def initialize: (Proc block) -> void
|
|
399
|
+
def write: (String data) -> Integer
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
class DeflatedBody < CompressedBody
|
|
404
|
+
def compress: () ?{ (String) -> void } -> void
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
class AutoInflate < Feature
|
|
409
|
+
SUPPORTED_ENCODING: Set[String]
|
|
410
|
+
|
|
411
|
+
def wrap_response: (Response response) -> Response
|
|
412
|
+
def stream_for: (Connection? connection, ?encoding: Encoding) -> Response::Body
|
|
413
|
+
|
|
414
|
+
private
|
|
415
|
+
|
|
416
|
+
def inflated_response_options: (Response response) -> Hash[Symbol, untyped]
|
|
417
|
+
def supported_encoding?: (Response response) -> bool
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
class Caching < Feature
|
|
421
|
+
CACHEABLE_METHODS: Set[Symbol]
|
|
422
|
+
|
|
423
|
+
attr_reader store: untyped
|
|
424
|
+
|
|
425
|
+
def initialize: (?store: untyped) -> void
|
|
426
|
+
def around_request: (Request request) { (Request) -> Response } -> Response
|
|
427
|
+
def wrap_response: (Response response) -> Response
|
|
428
|
+
|
|
429
|
+
private
|
|
430
|
+
|
|
431
|
+
def revalidate_entry: (Entry entry, Response response, Request request) -> Response
|
|
432
|
+
def store_and_freeze_response: (Response response) -> Response
|
|
433
|
+
def build_entry: (Response response, String body_string) -> Entry
|
|
434
|
+
def cacheable_request?: (Request request) -> bool
|
|
435
|
+
def cacheable_response?: (Response response) -> bool
|
|
436
|
+
def freshness_info?: (Response response, Array[String] directives) -> bool
|
|
437
|
+
def parse_cache_control: (Headers headers) -> Array[String]
|
|
438
|
+
def add_conditional_headers: (Request request, Entry entry) -> Request
|
|
439
|
+
def build_cached_response: (Entry entry, Request request) -> Response
|
|
440
|
+
def now: () -> Time
|
|
441
|
+
|
|
442
|
+
public
|
|
443
|
+
|
|
444
|
+
class Entry
|
|
445
|
+
attr_reader status: Integer
|
|
446
|
+
attr_reader version: String
|
|
447
|
+
attr_reader headers: Headers
|
|
448
|
+
attr_reader proxy_headers: Headers
|
|
449
|
+
attr_reader body: String
|
|
450
|
+
attr_reader request_uri: URI
|
|
451
|
+
attr_reader stored_at: Time
|
|
452
|
+
|
|
453
|
+
def initialize: (status: Integer, version: String, headers: Headers, proxy_headers: Headers, body: String, request_uri: URI, stored_at: Time) -> void
|
|
454
|
+
def fresh?: () -> bool
|
|
455
|
+
def revalidate!: () -> Time
|
|
456
|
+
def update_headers!: (Headers response_headers) -> void
|
|
457
|
+
|
|
458
|
+
private
|
|
459
|
+
|
|
460
|
+
def age: () -> Float
|
|
461
|
+
def max_age: () -> Integer?
|
|
462
|
+
def expires_at: () -> Time?
|
|
463
|
+
def no_cache?: () -> bool
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
class InMemoryStore
|
|
467
|
+
@cache: Hash[String, Entry]
|
|
468
|
+
|
|
469
|
+
def initialize: () -> void
|
|
470
|
+
def lookup: (Request request) -> Entry?
|
|
471
|
+
def store: (Request request, Entry entry) -> Entry
|
|
472
|
+
|
|
473
|
+
private
|
|
474
|
+
|
|
475
|
+
def cache_key: (Request request) -> String
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
class Instrumentation < Feature
|
|
480
|
+
attr_reader instrumenter: untyped
|
|
481
|
+
attr_reader name: String
|
|
482
|
+
attr_reader error_name: String
|
|
483
|
+
|
|
484
|
+
def initialize: (?instrumenter: untyped, ?namespace: String) -> void
|
|
485
|
+
def around_request: (Request request) { (Request) -> Response } -> Response
|
|
486
|
+
def on_error: (Request request, Exception error) -> void
|
|
487
|
+
|
|
488
|
+
class NullInstrumenter
|
|
489
|
+
def instrument: (String name, ?Hash[Symbol, untyped] payload) ?{ (Hash[Symbol, untyped]) -> void } -> untyped
|
|
490
|
+
def start: (String _name, Hash[Symbol, untyped] _payload) -> nil
|
|
491
|
+
def finish: (String _name, Hash[Symbol, untyped] _payload) -> nil
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
class Logging < Feature
|
|
496
|
+
class NullLogger
|
|
497
|
+
def fatal: (*untyped _args) -> nil
|
|
498
|
+
def error: (*untyped _args) -> nil
|
|
499
|
+
def warn: (*untyped _args) -> nil
|
|
500
|
+
def info: (*untyped _args) -> nil
|
|
501
|
+
def debug: (*untyped _args) -> nil
|
|
502
|
+
def fatal?: () -> true
|
|
503
|
+
def error?: () -> true
|
|
504
|
+
def warn?: () -> true
|
|
505
|
+
def info?: () -> true
|
|
506
|
+
def debug?: () -> true
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
attr_reader logger: untyped
|
|
510
|
+
|
|
511
|
+
@binary_formatter: :stats | :base64 | ^(String) -> String
|
|
512
|
+
|
|
513
|
+
def initialize: (?logger: untyped, ?binary_formatter: :stats | :base64 | ^(String) -> String) -> void
|
|
514
|
+
def wrap_request: (Request request) -> Request
|
|
515
|
+
def wrap_response: (Response response) -> Response
|
|
516
|
+
|
|
517
|
+
private
|
|
518
|
+
|
|
519
|
+
def validate_binary_formatter!: (:stats | :base64 | ^(String) -> String formatter) -> (:stats | :base64 | ^(String) -> String)
|
|
520
|
+
def log_request_details: (Request request) -> void
|
|
521
|
+
def log_response_body_inline: (Response response) -> Response
|
|
522
|
+
def logged_response_options: (Response response) -> Hash[Symbol, untyped]
|
|
523
|
+
def logged_body: (Response::Body body) -> Response::Body
|
|
524
|
+
def format_binary: (String data) -> String
|
|
525
|
+
def stringify_headers: (Headers headers) -> String
|
|
526
|
+
|
|
527
|
+
class BodyLogger
|
|
528
|
+
attr_reader connection: untyped
|
|
529
|
+
|
|
530
|
+
@formatter: (^(String) -> String)?
|
|
531
|
+
|
|
532
|
+
def initialize: (untyped stream, untyped logger, ?formatter: (^(String) -> String)?) -> void
|
|
533
|
+
def readpartial: (?Integer size, ?String? outbuf) -> String
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
class NormalizeUri < Feature
|
|
538
|
+
attr_reader normalizer: ^(String | URI) -> URI
|
|
539
|
+
|
|
540
|
+
def initialize: (?normalizer: ^(String | URI) -> URI) -> void
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
class RaiseError < Feature
|
|
544
|
+
@ignore: Array[Integer]
|
|
545
|
+
|
|
546
|
+
def initialize: (?ignore: Array[Integer]) -> void
|
|
547
|
+
def wrap_response: (Response response) -> Response
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
class DigestAuth < Feature
|
|
551
|
+
ALGORITHMS: Hash[String, singleton(Digest::MD5) | singleton(Digest::SHA256)]
|
|
552
|
+
WWW_AUTHENTICATE: String
|
|
553
|
+
|
|
554
|
+
@user: String
|
|
555
|
+
@pass: String
|
|
556
|
+
|
|
557
|
+
def initialize: (user: String, pass: String) -> void
|
|
558
|
+
def around_request: (Request request) { (Request) -> Response } -> Response
|
|
559
|
+
|
|
560
|
+
private
|
|
561
|
+
|
|
562
|
+
def digest_challenge?: (Response response) -> bool
|
|
563
|
+
def authorize: (Request request, Response response) -> Request
|
|
564
|
+
def parse_challenge: (String header) -> Hash[String, String]
|
|
565
|
+
def build_auth: (Request request, Hash[String, String] challenge) -> String
|
|
566
|
+
def compute_auth_header: (algorithm: String, qop: String?, nonce: String, cnonce: String, nonce_count: String, uri: String, ha1: String, ha2: String, challenge: Hash[String, String]) -> String
|
|
567
|
+
def select_qop: (String? qop_str) -> String?
|
|
568
|
+
def compute_ha1: (String algorithm, String realm, String nonce, String cnonce) -> String
|
|
569
|
+
def compute_ha2: (String algorithm, String method, String uri) -> String
|
|
570
|
+
def compute_response: (String algorithm, String ha1, String ha2, nonce: String, nonce_count: String, cnonce: String, qop: String?) -> String
|
|
571
|
+
def hex_digest: (String algorithm, String data) -> String
|
|
572
|
+
def build_header: (username: String, realm: String, nonce: String, uri: String, qop: String?, nonce_count: String, cnonce: String, response: String, opaque: String?, algorithm: String) -> String
|
|
573
|
+
end
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
module MimeType
|
|
577
|
+
def self.register_adapter: (String | Symbol type, untyped adapter) -> void
|
|
578
|
+
def self.[]: (String | Symbol type) -> untyped
|
|
579
|
+
def self.register_alias: (String | Symbol type, String | Symbol shortcut) -> void
|
|
580
|
+
def self.normalize: (String | Symbol type) -> String
|
|
581
|
+
|
|
582
|
+
self.@adapters: Hash[String, untyped]
|
|
583
|
+
self.@aliases: Hash[String | Symbol, String]
|
|
584
|
+
|
|
585
|
+
private
|
|
586
|
+
|
|
587
|
+
def self.adapters: () -> Hash[String, untyped]
|
|
588
|
+
def self.aliases: () -> Hash[String | Symbol, String]
|
|
589
|
+
|
|
590
|
+
class Adapter
|
|
591
|
+
include Singleton
|
|
592
|
+
|
|
593
|
+
def self.encode: (untyped) -> String
|
|
594
|
+
def self.decode: (String) -> untyped
|
|
595
|
+
def encode: (untyped) -> String
|
|
596
|
+
def decode: (String) -> untyped
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
class JSON < Adapter
|
|
600
|
+
def encode: (untyped obj) -> String
|
|
601
|
+
def decode: (String str) -> untyped
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
class Options
|
|
606
|
+
self.@default_socket_class: Class
|
|
607
|
+
self.@default_ssl_socket_class: Class
|
|
608
|
+
self.@default_timeout_class: Class
|
|
609
|
+
self.@available_features: Hash[Symbol, Class]
|
|
610
|
+
self.@defined_options: Array[Symbol]
|
|
611
|
+
|
|
612
|
+
attr_accessor self.default_socket_class: Class
|
|
613
|
+
attr_accessor self.default_ssl_socket_class: Class
|
|
614
|
+
attr_accessor self.default_timeout_class: Class
|
|
615
|
+
attr_reader self.available_features: Hash[Symbol, Class]
|
|
616
|
+
|
|
617
|
+
def self.new: (?untyped? options, **untyped kwargs) -> Options
|
|
618
|
+
def self.defined_options: () -> Array[Symbol]
|
|
619
|
+
def self.register_feature: (Symbol name, Class impl) -> Class
|
|
620
|
+
|
|
621
|
+
private
|
|
622
|
+
|
|
623
|
+
def self.def_option: (String | Symbol name, ?reader_only: bool) ?{ (untyped) -> untyped } -> void
|
|
624
|
+
def self.def_option_accessor: (String | Symbol name, reader_only: bool) -> void
|
|
625
|
+
|
|
626
|
+
public
|
|
627
|
+
|
|
628
|
+
def initialize: (
|
|
629
|
+
?response: Symbol,
|
|
630
|
+
?encoding: Encoding?,
|
|
631
|
+
?nodelay: bool,
|
|
632
|
+
?keep_alive_timeout: Integer,
|
|
633
|
+
?proxy: Hash[Symbol, untyped],
|
|
634
|
+
?ssl: Hash[Symbol, untyped],
|
|
635
|
+
?headers: Hash[String | Symbol, untyped] | Headers,
|
|
636
|
+
?features: Hash[Symbol, untyped],
|
|
637
|
+
?timeout_class: Class,
|
|
638
|
+
?timeout_options: Hash[Symbol, Numeric],
|
|
639
|
+
?socket_class: Class,
|
|
640
|
+
?ssl_socket_class: Class,
|
|
641
|
+
?params: untyped,
|
|
642
|
+
?form: untyped,
|
|
643
|
+
?json: untyped,
|
|
644
|
+
?body: untyped,
|
|
645
|
+
?follow: bool | Hash[Symbol, untyped],
|
|
646
|
+
?retriable: bool | Hash[Symbol, untyped],
|
|
647
|
+
?base_uri: String | URI?,
|
|
648
|
+
?persistent: String?,
|
|
649
|
+
?ssl_context: OpenSSL::SSL::SSLContext?
|
|
650
|
+
) -> void
|
|
651
|
+
def features=: (Hash[Symbol, untyped] features) -> Hash[Symbol, Feature]
|
|
652
|
+
|
|
653
|
+
attr_reader features: Hash[Symbol, Feature]
|
|
654
|
+
|
|
655
|
+
def follow=: (bool value) -> void
|
|
656
|
+
def retriable=: (bool value) -> void
|
|
657
|
+
def base_uri=: (String | URI? value) -> void
|
|
658
|
+
def base_uri?: () -> bool
|
|
659
|
+
def persistent=: (String? value) -> String?
|
|
660
|
+
def persistent?: () -> bool
|
|
661
|
+
def merge: (Hash[Symbol, untyped] | Options other) -> Options
|
|
662
|
+
def to_hash: () -> Hash[Symbol, untyped]
|
|
663
|
+
def dup: () ?{ (Options) -> void } -> Options
|
|
664
|
+
def feature: (Symbol name) -> untyped
|
|
665
|
+
|
|
666
|
+
# Dynamic options generated by def_option
|
|
667
|
+
attr_accessor headers: Headers
|
|
668
|
+
attr_accessor proxy: Hash[Symbol, untyped]
|
|
669
|
+
attr_accessor params: untyped
|
|
670
|
+
attr_accessor form: untyped
|
|
671
|
+
attr_accessor json: untyped
|
|
672
|
+
attr_accessor body: untyped
|
|
673
|
+
attr_accessor response: Symbol
|
|
674
|
+
attr_accessor socket_class: Class
|
|
675
|
+
attr_accessor nodelay: bool
|
|
676
|
+
attr_accessor ssl_socket_class: Class
|
|
677
|
+
attr_accessor ssl_context: OpenSSL::SSL::SSLContext?
|
|
678
|
+
attr_accessor ssl: Hash[Symbol, untyped]
|
|
679
|
+
attr_accessor keep_alive_timeout: Integer
|
|
680
|
+
attr_accessor timeout_class: Class
|
|
681
|
+
attr_accessor timeout_options: Hash[Symbol, Numeric]
|
|
682
|
+
attr_accessor encoding: Encoding?
|
|
683
|
+
attr_reader follow: Hash[Symbol, untyped]?
|
|
684
|
+
attr_reader retriable: Hash[Symbol, untyped]?
|
|
685
|
+
attr_reader base_uri: URI?
|
|
686
|
+
attr_reader persistent: String?
|
|
687
|
+
|
|
688
|
+
def with_headers: (Hash[String | Symbol, untyped] | Headers value) -> Options
|
|
689
|
+
def with_encoding: (String | Encoding value) -> Options
|
|
690
|
+
def with_features: (Array[Symbol | Hash[Symbol, untyped]] value) -> Options
|
|
691
|
+
def with_follow: (Hash[Symbol, untyped] | bool value) -> Options
|
|
692
|
+
def with_retriable: (Hash[Symbol, untyped] | bool value) -> Options
|
|
693
|
+
def with_base_uri: (String | URI value) -> Options
|
|
694
|
+
def with_persistent: (String value) -> Options
|
|
695
|
+
def with_proxy: (Hash[Symbol, untyped] value) -> Options
|
|
696
|
+
def with_params: (Hash[String | Symbol, untyped] value) -> Options
|
|
697
|
+
def with_form: (untyped value) -> Options
|
|
698
|
+
def with_json: (untyped value) -> Options
|
|
699
|
+
def with_body: (untyped value) -> Options
|
|
700
|
+
def with_response: (Symbol value) -> Options
|
|
701
|
+
def with_socket_class: (Class value) -> Options
|
|
702
|
+
def with_nodelay: (bool value) -> Options
|
|
703
|
+
def with_ssl_socket_class: (Class value) -> Options
|
|
704
|
+
def with_ssl_context: (OpenSSL::SSL::SSLContext? value) -> Options
|
|
705
|
+
def with_ssl: (Hash[Symbol, untyped] value) -> Options
|
|
706
|
+
def with_keep_alive_timeout: (Integer value) -> Options
|
|
707
|
+
def with_timeout_class: (Class value) -> Options
|
|
708
|
+
def with_timeout_options: (Hash[Symbol, Numeric] value) -> Options
|
|
709
|
+
|
|
710
|
+
private
|
|
711
|
+
|
|
712
|
+
def assign_options: (Binding env) -> void
|
|
713
|
+
def argument_error!: (String message) -> bot
|
|
714
|
+
def parse_base_uri: (String | URI value) -> URI
|
|
715
|
+
def resolve_base_uri: (URI base, URI relative) -> URI
|
|
716
|
+
def validate_base_uri_and_persistent!: () -> void
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
class URI
|
|
720
|
+
class InvalidError < RequestError
|
|
721
|
+
end
|
|
722
|
+
|
|
723
|
+
@raw_host: String?
|
|
724
|
+
@hash: Integer
|
|
725
|
+
self.@addressable_loaded: bool
|
|
726
|
+
@scheme: String?
|
|
727
|
+
@user: String?
|
|
728
|
+
@password: String?
|
|
729
|
+
@host: String?
|
|
730
|
+
@normalized_host: String?
|
|
731
|
+
@port: Integer?
|
|
732
|
+
@path: String
|
|
733
|
+
@query: String?
|
|
734
|
+
@fragment: String?
|
|
735
|
+
|
|
736
|
+
attr_reader scheme: String?
|
|
737
|
+
attr_reader user: String?
|
|
738
|
+
attr_reader password: String?
|
|
739
|
+
attr_reader host: String?
|
|
740
|
+
attr_reader normalized_host: String?
|
|
741
|
+
attr_reader fragment: String?
|
|
742
|
+
attr_accessor path: String
|
|
743
|
+
attr_accessor query: String?
|
|
744
|
+
|
|
745
|
+
HTTP_SCHEME: String
|
|
746
|
+
HTTPS_SCHEME: String
|
|
747
|
+
PERCENT_ENCODE: Regexp
|
|
748
|
+
NEEDS_ADDRESSABLE: Regexp
|
|
749
|
+
DEFAULT_PORTS: Hash[String?, Integer]
|
|
750
|
+
NORMALIZER: ^(String | URI) -> URI
|
|
751
|
+
|
|
752
|
+
DOT_SEGMENTS: Array[String]
|
|
753
|
+
SINGLE_DOT_SEGMENT: Regexp
|
|
754
|
+
DOUBLE_DOT_SEGMENT: Regexp
|
|
755
|
+
LAST_SEGMENT: Regexp
|
|
756
|
+
FIRST_SEGMENT: Regexp
|
|
757
|
+
|
|
758
|
+
def self.remove_dot_segments: (String path) -> String
|
|
759
|
+
def self.reduce_dot_segment: (String input, String output) -> void
|
|
760
|
+
|
|
761
|
+
def self.parse: (untyped uri) -> URI
|
|
762
|
+
def self.form_encode: (untyped form_values, ?sort: bool) -> String
|
|
763
|
+
def self.percent_encode: (String string) -> String
|
|
764
|
+
| (String? string) -> String?
|
|
765
|
+
|
|
766
|
+
def initialize: (?scheme: String?, ?user: String?, ?password: String?, ?host: String?, ?port: Integer?, ?path: String?, ?query: String?, ?fragment: String?) -> void
|
|
767
|
+
def ==: (untyped other) -> bool
|
|
768
|
+
def eql?: (untyped other) -> bool
|
|
769
|
+
def hash: () -> Integer
|
|
770
|
+
def host=: (String? new_host) -> void
|
|
771
|
+
def port: () -> Integer?
|
|
772
|
+
def default_port: () -> Integer?
|
|
773
|
+
def origin: () -> String
|
|
774
|
+
def request_uri: () -> String
|
|
775
|
+
def omit: (*Symbol) -> URI
|
|
776
|
+
def join: (String | URI) -> URI
|
|
777
|
+
def normalize: () -> URI
|
|
778
|
+
def http?: () -> bool
|
|
779
|
+
def https?: () -> bool
|
|
780
|
+
def dup: () -> URI
|
|
781
|
+
def to_s: () -> String
|
|
782
|
+
alias to_str to_s
|
|
783
|
+
def inspect: () -> String
|
|
784
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, String? | Integer?]
|
|
785
|
+
|
|
786
|
+
private
|
|
787
|
+
|
|
788
|
+
def authority_string: () -> String
|
|
789
|
+
def process_ipv6_brackets: (untyped raw_host, ?brackets: bool) -> String?
|
|
790
|
+
def normalize_host: (String? host) -> String?
|
|
791
|
+
|
|
792
|
+
def self.parse_components: (String uri_string) -> Hash[Symbol, untyped]
|
|
793
|
+
def self.parse_with_stdlib: (String uri_string) -> Hash[Symbol, untyped]?
|
|
794
|
+
def self.parse_with_addressable: (String uri_string) -> Hash[Symbol, untyped]
|
|
795
|
+
def self.require_addressable: () -> void
|
|
796
|
+
def self.idna_to_ascii: (String host) -> String
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
# Supported HTTP method verbs
|
|
800
|
+
type verb = :options | :get | :head | :post | :put | :delete | :trace | :connect
|
|
801
|
+
| :propfind | :proppatch | :mkcol | :copy | :move | :lock | :unlock
|
|
802
|
+
| :orderpatch | :acl | :report | :patch | :search | :mkcalendar | :purge
|
|
803
|
+
|
|
804
|
+
class Request
|
|
805
|
+
extend Forwardable
|
|
806
|
+
include Base64
|
|
807
|
+
include Request::Proxy
|
|
808
|
+
|
|
809
|
+
class Builder
|
|
810
|
+
HTTP_OR_HTTPS_RE: Regexp
|
|
811
|
+
|
|
812
|
+
@options: Options
|
|
813
|
+
|
|
814
|
+
def initialize: (Options options) -> void
|
|
815
|
+
def build: (verb verb, String | URI uri) -> Request
|
|
816
|
+
def wrap: (Request request) -> Request
|
|
817
|
+
|
|
818
|
+
private
|
|
819
|
+
|
|
820
|
+
def make_request_uri: (String | URI uri) -> URI
|
|
821
|
+
def resolve_against_base: (String uri) -> String
|
|
822
|
+
def merge_query_params!: (URI uri) -> void
|
|
823
|
+
def make_request_headers: () -> Headers
|
|
824
|
+
def make_request_body: (Headers headers) -> untyped
|
|
825
|
+
def make_json_body: (untyped data, Headers headers) -> String
|
|
826
|
+
def make_form_data: (untyped form) -> untyped
|
|
827
|
+
end
|
|
828
|
+
|
|
829
|
+
class UnsupportedMethodError < RequestError
|
|
830
|
+
end
|
|
831
|
+
|
|
832
|
+
class UnsupportedSchemeError < RequestError
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
USER_AGENT: String
|
|
836
|
+
METHODS: Array[verb]
|
|
837
|
+
SCHEMES: Array[Symbol]
|
|
838
|
+
PORTS: Hash[Symbol, Integer]
|
|
839
|
+
|
|
840
|
+
attr_reader verb: verb
|
|
841
|
+
attr_reader scheme: Symbol
|
|
842
|
+
attr_reader uri_normalizer: ^(String | URI) -> URI
|
|
843
|
+
attr_reader uri: URI
|
|
844
|
+
attr_reader proxy: Hash[Symbol, untyped]
|
|
845
|
+
attr_reader body: Request::Body
|
|
846
|
+
attr_reader headers: Headers
|
|
847
|
+
attr_reader version: String
|
|
848
|
+
|
|
849
|
+
def initialize: (verb: String | Symbol, uri: String | URI, ?headers: Hash[String | Symbol, untyped] | Headers, ?proxy: Hash[Symbol, untyped], ?body: untyped, ?version: String, ?uri_normalizer: (^(String | URI) -> URI)?) -> void
|
|
850
|
+
def redirect: (String | URI uri, ?verb | Symbol verb) -> Request
|
|
851
|
+
def stream: (Timeout::Null socket) -> void
|
|
852
|
+
def using_proxy?: () -> bool
|
|
853
|
+
def using_authenticated_proxy?: () -> bool
|
|
854
|
+
def headline: () -> String
|
|
855
|
+
def socket_host: () -> String
|
|
856
|
+
def socket_port: () -> Integer
|
|
857
|
+
def inspect: () -> String
|
|
858
|
+
|
|
859
|
+
def host: () -> untyped
|
|
860
|
+
|
|
861
|
+
private
|
|
862
|
+
|
|
863
|
+
def port: () -> untyped
|
|
864
|
+
def default_host_header_value: () -> String
|
|
865
|
+
def redirect_headers: (URI redirect_uri, Symbol verb) -> Headers
|
|
866
|
+
def prepare_body: (untyped body) -> Request::Body
|
|
867
|
+
def prepare_headers: (untyped headers) -> Headers
|
|
868
|
+
def parse_uri!: (String | URI uri) -> void
|
|
869
|
+
def validate_method_and_scheme!: () -> void
|
|
870
|
+
|
|
871
|
+
module Proxy : _ProxyHost
|
|
872
|
+
interface _ProxyHost
|
|
873
|
+
def headers: () -> Headers
|
|
874
|
+
def proxy: () -> Hash[Symbol, untyped]
|
|
875
|
+
def host: () -> untyped
|
|
876
|
+
def version: () -> String
|
|
877
|
+
def using_authenticated_proxy?: () -> bool
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
def include_proxy_headers: () -> void
|
|
881
|
+
def include_proxy_authorization_header: () -> void
|
|
882
|
+
def proxy_authorization_header: () -> String
|
|
883
|
+
def connect_using_proxy: (Timeout::Null socket) -> void
|
|
884
|
+
def proxy_connect_header: () -> String
|
|
885
|
+
def proxy_connect_headers: () -> Headers
|
|
886
|
+
|
|
887
|
+
private
|
|
888
|
+
|
|
889
|
+
def encode64: (String input) -> String
|
|
890
|
+
def port: () -> untyped
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
class Body
|
|
894
|
+
@source: untyped
|
|
895
|
+
|
|
896
|
+
attr_reader source: untyped
|
|
897
|
+
|
|
898
|
+
def initialize: (untyped source) -> void
|
|
899
|
+
def empty?: () -> bool
|
|
900
|
+
def loggable?: () -> bool
|
|
901
|
+
def size: () -> Integer
|
|
902
|
+
def each: () { (String) -> void } -> self
|
|
903
|
+
| () -> Enumerator[String, self]
|
|
904
|
+
def ==: (untyped other) -> bool
|
|
905
|
+
|
|
906
|
+
private
|
|
907
|
+
|
|
908
|
+
def rewind: (untyped io) -> void
|
|
909
|
+
def validate_source_type!: () -> void
|
|
910
|
+
|
|
911
|
+
class ProcIO
|
|
912
|
+
@block: Proc
|
|
913
|
+
|
|
914
|
+
def initialize: (Proc block) -> void
|
|
915
|
+
def write: (String data) -> Integer
|
|
916
|
+
end
|
|
917
|
+
end
|
|
918
|
+
|
|
919
|
+
class Writer
|
|
920
|
+
CRLF: String
|
|
921
|
+
ZERO: String
|
|
922
|
+
CHUNKED_END: String
|
|
923
|
+
|
|
924
|
+
@body: Request::Body
|
|
925
|
+
@socket: Timeout::Null
|
|
926
|
+
@headers: Headers
|
|
927
|
+
@request_header: Array[String]
|
|
928
|
+
|
|
929
|
+
def initialize: (Timeout::Null socket, Request::Body? body, Headers headers, String headline) -> void
|
|
930
|
+
def add_headers: () -> void
|
|
931
|
+
def stream: () -> void
|
|
932
|
+
def connect_through_proxy: () -> void
|
|
933
|
+
def add_body_type_headers: () -> void
|
|
934
|
+
def join_headers: () -> String
|
|
935
|
+
def send_request: () -> void
|
|
936
|
+
def each_chunk: () { (String) -> void } -> void
|
|
937
|
+
def encode_chunk: (String chunk) -> String
|
|
938
|
+
def chunked?: () -> bool
|
|
939
|
+
|
|
940
|
+
private
|
|
941
|
+
|
|
942
|
+
def write: (String data) -> void
|
|
943
|
+
end
|
|
944
|
+
end
|
|
945
|
+
|
|
946
|
+
class Response
|
|
947
|
+
extend Forwardable
|
|
948
|
+
|
|
949
|
+
@content_type: ContentType
|
|
950
|
+
@cookies: Array[HTTP::Cookie]?
|
|
951
|
+
|
|
952
|
+
attr_reader status: Response::Status
|
|
953
|
+
attr_reader version: String
|
|
954
|
+
attr_reader headers: Headers
|
|
955
|
+
attr_reader body: Response::Body
|
|
956
|
+
attr_reader request: Request
|
|
957
|
+
attr_reader proxy_headers: Headers
|
|
958
|
+
|
|
959
|
+
def initialize: (status: Integer | Symbol, version: String, ?headers: Hash[String | Symbol, untyped] | Headers, ?proxy_headers: Hash[String | Symbol, untyped] | Headers, ?connection: Connection?, ?encoding: Encoding?, ?body: untyped, ?request: Request?, ?uri: URI?) -> void
|
|
960
|
+
def reason: () -> String?
|
|
961
|
+
def code: () -> Integer
|
|
962
|
+
def to_s: () -> String
|
|
963
|
+
alias to_str to_s
|
|
964
|
+
def readpartial: (?Integer size, ?String? outbuf) -> String
|
|
965
|
+
def connection: () -> Connection?
|
|
966
|
+
def uri: () -> URI
|
|
967
|
+
def to_a: () -> [Integer, Hash[String, String | Array[String]?], String]
|
|
968
|
+
alias deconstruct to_a
|
|
969
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, Status | String | Headers | Body | Request?]
|
|
970
|
+
def flush: () -> Response
|
|
971
|
+
def content_length: () -> Integer?
|
|
972
|
+
def content_type: () -> ContentType
|
|
973
|
+
def mime_type: () -> String?
|
|
974
|
+
def charset: () -> String?
|
|
975
|
+
def cookies: () -> Array[HTTP::Cookie]
|
|
976
|
+
def chunked?: () -> bool
|
|
977
|
+
def parse: (?untyped? type) -> untyped
|
|
978
|
+
def inspect: () -> String
|
|
979
|
+
|
|
980
|
+
private
|
|
981
|
+
|
|
982
|
+
def default_encoding: () -> Encoding
|
|
983
|
+
def init_request: (Request? request, URI? uri) -> Request?
|
|
984
|
+
def init_body: (Response::Body? body, Connection? connection, (String | Encoding)? encoding) -> Response::Body
|
|
985
|
+
|
|
986
|
+
class Status
|
|
987
|
+
include Comparable
|
|
988
|
+
extend Forwardable
|
|
989
|
+
|
|
990
|
+
REASONS: Hash[Integer, String]
|
|
991
|
+
SYMBOLS: Hash[Integer, Symbol]
|
|
992
|
+
SYMBOL_CODES: Hash[Symbol, Integer]
|
|
993
|
+
|
|
994
|
+
def self.coerce: (String | Symbol | Numeric object) -> Status
|
|
995
|
+
def self.[]: (String | Symbol | Numeric object) -> Status
|
|
996
|
+
|
|
997
|
+
private
|
|
998
|
+
|
|
999
|
+
def self.symbolize: (String str) -> Symbol
|
|
1000
|
+
|
|
1001
|
+
public
|
|
1002
|
+
|
|
1003
|
+
attr_reader code: Integer
|
|
1004
|
+
|
|
1005
|
+
def initialize: (untyped obj) -> void
|
|
1006
|
+
def to_i: () -> Integer
|
|
1007
|
+
def to_int: () -> Integer
|
|
1008
|
+
def <=>: (Numeric | Status other) -> Integer?
|
|
1009
|
+
def hash: () -> Integer
|
|
1010
|
+
def reason: () -> String?
|
|
1011
|
+
def to_s: () -> String
|
|
1012
|
+
def informational?: () -> bool
|
|
1013
|
+
def success?: () -> bool
|
|
1014
|
+
def redirect?: () -> bool
|
|
1015
|
+
def client_error?: () -> bool
|
|
1016
|
+
def server_error?: () -> bool
|
|
1017
|
+
def not_modified?: () -> bool
|
|
1018
|
+
def to_sym: () -> Symbol?
|
|
1019
|
+
def inspect: () -> String
|
|
1020
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, Integer | String?]
|
|
1021
|
+
end
|
|
1022
|
+
|
|
1023
|
+
class Body
|
|
1024
|
+
extend Forwardable
|
|
1025
|
+
|
|
1026
|
+
@stream: untyped
|
|
1027
|
+
@streaming: bool?
|
|
1028
|
+
@contents: String?
|
|
1029
|
+
@encoding: Encoding
|
|
1030
|
+
|
|
1031
|
+
attr_reader connection: untyped
|
|
1032
|
+
attr_reader encoding: Encoding
|
|
1033
|
+
|
|
1034
|
+
def initialize: (untyped stream, ?encoding: String | Encoding) -> void
|
|
1035
|
+
def readpartial: (?Integer size, ?String? outbuf) -> String
|
|
1036
|
+
def each: () { (String) -> void } -> void
|
|
1037
|
+
| () -> Enumerator[String, void]
|
|
1038
|
+
def to_s: () -> untyped
|
|
1039
|
+
alias to_str to_s
|
|
1040
|
+
def stream!: () -> untyped
|
|
1041
|
+
def loggable?: () -> bool
|
|
1042
|
+
def inspect: () -> String
|
|
1043
|
+
|
|
1044
|
+
private
|
|
1045
|
+
|
|
1046
|
+
def read_contents: () -> String
|
|
1047
|
+
def find_encoding: (String | Encoding encoding) -> untyped
|
|
1048
|
+
end
|
|
1049
|
+
|
|
1050
|
+
class Inflater
|
|
1051
|
+
@zstream: Zlib::Inflate?
|
|
1052
|
+
|
|
1053
|
+
attr_reader connection: untyped
|
|
1054
|
+
|
|
1055
|
+
def initialize: (untyped connection) -> void
|
|
1056
|
+
def readpartial: (?Integer size, ?String? outbuf) -> String
|
|
1057
|
+
|
|
1058
|
+
private
|
|
1059
|
+
|
|
1060
|
+
def zstream: () -> Zlib::Inflate
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
class Parser
|
|
1064
|
+
@handler: Handler
|
|
1065
|
+
@header_finished: bool
|
|
1066
|
+
@message_finished: bool
|
|
1067
|
+
@chunk: untyped
|
|
1068
|
+
|
|
1069
|
+
attr_reader parser: LLHttp::Parser
|
|
1070
|
+
attr_reader headers: Headers
|
|
1071
|
+
attr_reader status_code: Integer?
|
|
1072
|
+
attr_reader http_version: String?
|
|
1073
|
+
|
|
1074
|
+
def initialize: () -> void
|
|
1075
|
+
def reset: () -> void
|
|
1076
|
+
def reset_for_informational: () -> void
|
|
1077
|
+
def add: (String data) -> Parser
|
|
1078
|
+
alias << add
|
|
1079
|
+
def mark_header_finished: () -> void
|
|
1080
|
+
def headers?: () -> bool
|
|
1081
|
+
def add_header: (String name, String value) -> void
|
|
1082
|
+
def mark_message_finished: () -> void
|
|
1083
|
+
def finished?: () -> bool
|
|
1084
|
+
def add_body: (String chunk) -> void
|
|
1085
|
+
def read: (Integer size) -> String?
|
|
1086
|
+
|
|
1087
|
+
class Handler < LLHttp::Delegate
|
|
1088
|
+
@target: Parser
|
|
1089
|
+
@reading_header_value: bool
|
|
1090
|
+
@field_value: String
|
|
1091
|
+
@field: String
|
|
1092
|
+
|
|
1093
|
+
def initialize: (Parser target) -> void
|
|
1094
|
+
def reset: () -> void
|
|
1095
|
+
def on_header_field: (String field) -> void
|
|
1096
|
+
def on_header_value: (String value) -> void
|
|
1097
|
+
def on_headers_complete: () -> void
|
|
1098
|
+
def on_body: (String body) -> void
|
|
1099
|
+
def on_message_complete: () -> void
|
|
1100
|
+
|
|
1101
|
+
private
|
|
1102
|
+
|
|
1103
|
+
def append_header: () -> void
|
|
1104
|
+
end
|
|
1105
|
+
end
|
|
1106
|
+
end
|
|
1107
|
+
|
|
1108
|
+
class Connection
|
|
1109
|
+
extend Forwardable
|
|
1110
|
+
include Connection::Internals
|
|
1111
|
+
|
|
1112
|
+
BUFFER_SIZE: Integer
|
|
1113
|
+
MAX_FLUSH_SIZE: Integer
|
|
1114
|
+
KEEP_ALIVE: String
|
|
1115
|
+
CLOSE: String
|
|
1116
|
+
HTTP_1_0: String
|
|
1117
|
+
HTTP_1_1: String
|
|
1118
|
+
|
|
1119
|
+
@persistent: bool
|
|
1120
|
+
@keep_alive_timeout: Float
|
|
1121
|
+
@pending_request: bool
|
|
1122
|
+
@pending_response: bool | Response
|
|
1123
|
+
@failed_proxy_connect: bool
|
|
1124
|
+
@buffer: String
|
|
1125
|
+
@parser: Response::Parser
|
|
1126
|
+
@socket: untyped
|
|
1127
|
+
@keep_alive: bool
|
|
1128
|
+
@conn_expires_at: untyped
|
|
1129
|
+
|
|
1130
|
+
attr_reader proxy_response_headers: Headers?
|
|
1131
|
+
|
|
1132
|
+
def initialize: (Request req, Options options) -> void
|
|
1133
|
+
def failed_proxy_connect?: () -> bool
|
|
1134
|
+
def pending_response=: (bool | Response) -> void
|
|
1135
|
+
def send_request: (Request req) -> void
|
|
1136
|
+
def readpartial: (?Integer size, ?String? outbuf) -> String
|
|
1137
|
+
def read_headers!: () -> void
|
|
1138
|
+
def finish_response: () -> void
|
|
1139
|
+
def close: () -> void
|
|
1140
|
+
def finished_request?: () -> bool
|
|
1141
|
+
def keep_alive?: () -> bool
|
|
1142
|
+
def expired?: () -> bool
|
|
1143
|
+
def status_code: () -> Integer?
|
|
1144
|
+
def http_version: () -> String?
|
|
1145
|
+
def headers: () -> Headers
|
|
1146
|
+
|
|
1147
|
+
private
|
|
1148
|
+
|
|
1149
|
+
def init_state: (Options options) -> void
|
|
1150
|
+
def check_premature_eof: (bool eof) -> void
|
|
1151
|
+
def connect_socket: (Request req, Options options) -> void
|
|
1152
|
+
def start_tls: (Request req, Options options) -> void
|
|
1153
|
+
def send_proxy_connect_request: (Request req) -> void
|
|
1154
|
+
def handle_proxy_connect_response: () -> void
|
|
1155
|
+
def reset_timer: () -> void
|
|
1156
|
+
def set_keep_alive: () -> void
|
|
1157
|
+
def read_more: (Integer size) -> untyped
|
|
1158
|
+
|
|
1159
|
+
module Internals : _InternalsHost
|
|
1160
|
+
interface _InternalsHost
|
|
1161
|
+
def failed_proxy_connect?: () -> bool
|
|
1162
|
+
def read_headers!: () -> void
|
|
1163
|
+
def close: () -> void
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
private
|
|
1167
|
+
|
|
1168
|
+
def flush_pending_response: () -> void
|
|
1169
|
+
def flush_or_close_response: (Response response) -> void
|
|
1170
|
+
def start_tls: (Request req, Options options) -> void
|
|
1171
|
+
def send_proxy_connect_request: (Request req) -> void
|
|
1172
|
+
def handle_proxy_connect_response: () -> void
|
|
1173
|
+
def reset_timer: () -> void
|
|
1174
|
+
def set_keep_alive: () -> void
|
|
1175
|
+
def body_framed?: () -> bool
|
|
1176
|
+
def read_more: (Integer size) -> untyped
|
|
1177
|
+
end
|
|
1178
|
+
end
|
|
1179
|
+
|
|
1180
|
+
class Redirector
|
|
1181
|
+
class TooManyRedirectsError < ResponseError
|
|
1182
|
+
end
|
|
1183
|
+
|
|
1184
|
+
class EndlessRedirectError < TooManyRedirectsError
|
|
1185
|
+
end
|
|
1186
|
+
|
|
1187
|
+
REDIRECT_CODES: Set[Integer]
|
|
1188
|
+
STRICT_SENSITIVE_CODES: Set[Integer]
|
|
1189
|
+
UNSAFE_VERBS: Set[Symbol]
|
|
1190
|
+
SEE_OTHER_ALLOWED_VERBS: Set[Symbol]
|
|
1191
|
+
|
|
1192
|
+
@on_redirect: (^(Response, Request) -> void)?
|
|
1193
|
+
@request: Request
|
|
1194
|
+
@response: Response
|
|
1195
|
+
@visited: Array[String]
|
|
1196
|
+
|
|
1197
|
+
attr_reader strict: bool
|
|
1198
|
+
attr_reader max_hops: Integer
|
|
1199
|
+
|
|
1200
|
+
def initialize: (?strict: bool, ?max_hops: Integer, ?on_redirect: (^(Response, Request) -> void)?) -> void
|
|
1201
|
+
def perform: (Request request, Response response) { (Request) -> Response } -> Response
|
|
1202
|
+
|
|
1203
|
+
private
|
|
1204
|
+
|
|
1205
|
+
def follow_redirects: () { (Request) -> Response } -> void
|
|
1206
|
+
def too_many_hops?: () -> bool
|
|
1207
|
+
def endless_loop?: () -> bool
|
|
1208
|
+
def visit_key: () -> String
|
|
1209
|
+
def redirect_uri: () -> String?
|
|
1210
|
+
def redirect_to: (String? uri) -> Request
|
|
1211
|
+
end
|
|
1212
|
+
|
|
1213
|
+
class CookieJar
|
|
1214
|
+
include Enumerable[Cookie]
|
|
1215
|
+
|
|
1216
|
+
def initialize: () -> void
|
|
1217
|
+
def parse: (String, String) -> void
|
|
1218
|
+
def add: (Cookie) -> void
|
|
1219
|
+
def delete: (Cookie) -> void
|
|
1220
|
+
def each: () { (Cookie) -> void } -> void
|
|
1221
|
+
| () -> Enumerator[Cookie, void]
|
|
1222
|
+
def empty?: () -> bool
|
|
1223
|
+
def cookies: () -> Array[Cookie]
|
|
1224
|
+
end
|
|
1225
|
+
|
|
1226
|
+
class Cookie
|
|
1227
|
+
attr_reader name: String
|
|
1228
|
+
attr_reader value: String
|
|
1229
|
+
attr_reader cookie_value: String
|
|
1230
|
+
|
|
1231
|
+
def self.parse: (String, URI) -> Array[HTTP::Cookie]
|
|
1232
|
+
def self.cookie_value_to_hash: (String) -> Hash[String, String]
|
|
1233
|
+
def initialize: (String, String, **untyped) -> void
|
|
1234
|
+
end
|
|
1235
|
+
|
|
1236
|
+
module FormData
|
|
1237
|
+
CRLF: String
|
|
1238
|
+
|
|
1239
|
+
class Error < StandardError
|
|
1240
|
+
end
|
|
1241
|
+
|
|
1242
|
+
type formdata = Multipart | Urlencoded
|
|
1243
|
+
|
|
1244
|
+
# Selects encoder type based on given data
|
|
1245
|
+
def self.create: (untyped data, ?encoder: _Encoder?) -> formdata
|
|
1246
|
+
|
|
1247
|
+
# Coerces obj to Hash
|
|
1248
|
+
def self.ensure_hash: (untyped obj) -> Hash[untyped, untyped]
|
|
1249
|
+
|
|
1250
|
+
# Coerces obj to an Enumerable of key-value pairs
|
|
1251
|
+
def self.ensure_data: (untyped obj) -> untyped
|
|
1252
|
+
|
|
1253
|
+
private
|
|
1254
|
+
|
|
1255
|
+
# Checks if data contains multipart data
|
|
1256
|
+
def self.multipart?: (untyped data) -> bool
|
|
1257
|
+
|
|
1258
|
+
interface _Encoder
|
|
1259
|
+
def call: (untyped data) -> String
|
|
1260
|
+
end
|
|
1261
|
+
|
|
1262
|
+
module Readable
|
|
1263
|
+
@io: StringIO | CompositeIO
|
|
1264
|
+
|
|
1265
|
+
# Returns IO content as a String
|
|
1266
|
+
def to_s: () -> String
|
|
1267
|
+
|
|
1268
|
+
# Reads and returns part of IO content
|
|
1269
|
+
def read: (?Integer? length, ?String? outbuf) -> String?
|
|
1270
|
+
|
|
1271
|
+
# Returns IO size in bytes
|
|
1272
|
+
def size: () -> Integer
|
|
1273
|
+
|
|
1274
|
+
# Rewinds the IO to the beginning
|
|
1275
|
+
def rewind: () -> (Integer | void)
|
|
1276
|
+
end
|
|
1277
|
+
|
|
1278
|
+
class Part
|
|
1279
|
+
include Readable
|
|
1280
|
+
|
|
1281
|
+
# Returns the content type of this part
|
|
1282
|
+
attr_reader content_type: String?
|
|
1283
|
+
|
|
1284
|
+
# Returns the filename of this part
|
|
1285
|
+
attr_reader filename: String?
|
|
1286
|
+
|
|
1287
|
+
# Creates a new Part with the given body and options
|
|
1288
|
+
def initialize: (_ToS body, ?content_type: String?, ?filename: String?) -> void
|
|
1289
|
+
end
|
|
1290
|
+
|
|
1291
|
+
class File < Part
|
|
1292
|
+
DEFAULT_MIME: String
|
|
1293
|
+
|
|
1294
|
+
@autoclose: bool
|
|
1295
|
+
|
|
1296
|
+
# Creates a new File from a path or IO object
|
|
1297
|
+
def initialize: (String | Pathname | untyped path_or_io, ?Hash[Symbol, untyped]? opts) -> void
|
|
1298
|
+
|
|
1299
|
+
# Closes the underlying IO if it was opened by this instance
|
|
1300
|
+
def close: () -> void
|
|
1301
|
+
|
|
1302
|
+
private
|
|
1303
|
+
|
|
1304
|
+
# Wraps path_or_io into an IO object
|
|
1305
|
+
def make_io: (String | Pathname | untyped path_or_io) -> untyped
|
|
1306
|
+
|
|
1307
|
+
# Determines filename for the given IO
|
|
1308
|
+
def filename_for: (untyped io) -> String
|
|
1309
|
+
end
|
|
1310
|
+
|
|
1311
|
+
class CompositeIO
|
|
1312
|
+
@index: Integer
|
|
1313
|
+
@ios: Array[untyped]
|
|
1314
|
+
@size: Integer?
|
|
1315
|
+
|
|
1316
|
+
# Creates a new CompositeIO from an array of IO-like objects
|
|
1317
|
+
def initialize: (Array[untyped] ios) -> void
|
|
1318
|
+
|
|
1319
|
+
# Reads and returns content across multiple IO objects
|
|
1320
|
+
def read: (?Integer? length, ?String? outbuf) -> String?
|
|
1321
|
+
|
|
1322
|
+
# Returns sum of all IO sizes
|
|
1323
|
+
def size: () -> Integer
|
|
1324
|
+
|
|
1325
|
+
# Rewinds all IO objects and resets cursor
|
|
1326
|
+
def rewind: () -> void
|
|
1327
|
+
|
|
1328
|
+
private
|
|
1329
|
+
|
|
1330
|
+
# Yields chunks with total length up to `length`
|
|
1331
|
+
def read_chunks: (Integer? length) { (String chunk) -> void } -> void
|
|
1332
|
+
|
|
1333
|
+
# Reads chunk from current IO with length up to `max_length`
|
|
1334
|
+
def readpartial: (Integer? max_length) -> String?
|
|
1335
|
+
|
|
1336
|
+
# Advances cursor to the next IO object
|
|
1337
|
+
def advance_io: () -> void
|
|
1338
|
+
end
|
|
1339
|
+
|
|
1340
|
+
class Multipart
|
|
1341
|
+
include Readable
|
|
1342
|
+
|
|
1343
|
+
DEFAULT_CONTENT_TYPE: String
|
|
1344
|
+
|
|
1345
|
+
# Returns the multipart boundary string
|
|
1346
|
+
attr_reader boundary: String
|
|
1347
|
+
|
|
1348
|
+
@content_type: _ToS
|
|
1349
|
+
|
|
1350
|
+
# Creates a new Multipart form data instance
|
|
1351
|
+
def initialize: (untyped data, ?boundary: _ToS, ?content_type: _ToS) -> void
|
|
1352
|
+
|
|
1353
|
+
# Generates a boundary string for multipart form data
|
|
1354
|
+
def self.generate_boundary: () -> String
|
|
1355
|
+
|
|
1356
|
+
# Returns MIME type for the Content-Type header
|
|
1357
|
+
def content_type: () -> String
|
|
1358
|
+
|
|
1359
|
+
# Returns form data content size for Content-Length
|
|
1360
|
+
alias content_length size
|
|
1361
|
+
|
|
1362
|
+
private
|
|
1363
|
+
|
|
1364
|
+
@glue: String?
|
|
1365
|
+
@tail: String?
|
|
1366
|
+
|
|
1367
|
+
# Returns the boundary glue between parts
|
|
1368
|
+
def glue: () -> String
|
|
1369
|
+
|
|
1370
|
+
# Returns the closing boundary tail
|
|
1371
|
+
def tail: () -> String
|
|
1372
|
+
|
|
1373
|
+
# Coerces data into an array of Param objects
|
|
1374
|
+
def parts: (untyped data) -> Array[Param]
|
|
1375
|
+
|
|
1376
|
+
class Param
|
|
1377
|
+
include Readable
|
|
1378
|
+
|
|
1379
|
+
@name: String
|
|
1380
|
+
@part: Part
|
|
1381
|
+
|
|
1382
|
+
# Initializes body part with headers and data
|
|
1383
|
+
def initialize: (untyped name, untyped value) -> void
|
|
1384
|
+
|
|
1385
|
+
private
|
|
1386
|
+
|
|
1387
|
+
# Builds the MIME header for this part
|
|
1388
|
+
def header: () -> String
|
|
1389
|
+
|
|
1390
|
+
# Builds Content-Disposition parameters string
|
|
1391
|
+
def parameters: () -> String
|
|
1392
|
+
end
|
|
1393
|
+
end
|
|
1394
|
+
|
|
1395
|
+
class Urlencoded
|
|
1396
|
+
include Readable
|
|
1397
|
+
|
|
1398
|
+
self.@encoder: _Encoder?
|
|
1399
|
+
|
|
1400
|
+
# Sets custom form data encoder implementation
|
|
1401
|
+
def self.encoder=: (untyped implementation) -> void
|
|
1402
|
+
|
|
1403
|
+
# Returns form data encoder implementation
|
|
1404
|
+
def self.encoder: () -> _Encoder
|
|
1405
|
+
|
|
1406
|
+
# Default encoder for urlencoded form data
|
|
1407
|
+
module DefaultEncoder
|
|
1408
|
+
# Recursively encodes form data value
|
|
1409
|
+
def self.encode: (untyped value, ?String? prefix) -> String
|
|
1410
|
+
|
|
1411
|
+
alias self.call self.encode
|
|
1412
|
+
|
|
1413
|
+
private
|
|
1414
|
+
|
|
1415
|
+
# Encodes an Array value
|
|
1416
|
+
def self.encode_array: (Array[untyped] value, String? prefix) -> String
|
|
1417
|
+
|
|
1418
|
+
# Encodes an Array of key-value pairs
|
|
1419
|
+
def self.encode_pairs: (Array[untyped] pairs) -> String
|
|
1420
|
+
|
|
1421
|
+
# Encodes a Hash value
|
|
1422
|
+
def self.encode_hash: (Hash[untyped, untyped] hash, String? prefix) -> String
|
|
1423
|
+
|
|
1424
|
+
# URL-encodes a value
|
|
1425
|
+
def self.escape: (untyped value) -> String
|
|
1426
|
+
end
|
|
1427
|
+
|
|
1428
|
+
# Creates a new Urlencoded form data instance
|
|
1429
|
+
def initialize: (untyped data, ?encoder: _Encoder?) -> void
|
|
1430
|
+
|
|
1431
|
+
# Returns MIME type for the Content-Type header
|
|
1432
|
+
def content_type: () -> String
|
|
1433
|
+
|
|
1434
|
+
# Returns form data content size for Content-Length
|
|
1435
|
+
alias content_length size
|
|
1436
|
+
end
|
|
1437
|
+
|
|
1438
|
+
VERSION: String
|
|
1439
|
+
end
|
|
1440
|
+
|
|
1441
|
+
class Error < StandardError
|
|
1442
|
+
end
|
|
1443
|
+
|
|
1444
|
+
class ConnectionError < Error
|
|
1445
|
+
end
|
|
1446
|
+
|
|
1447
|
+
class ResponseHeaderError < ConnectionError
|
|
1448
|
+
end
|
|
1449
|
+
|
|
1450
|
+
class SocketReadError < ConnectionError
|
|
1451
|
+
end
|
|
1452
|
+
|
|
1453
|
+
class SocketWriteError < ConnectionError
|
|
1454
|
+
end
|
|
1455
|
+
|
|
1456
|
+
class RequestError < Error
|
|
1457
|
+
end
|
|
1458
|
+
|
|
1459
|
+
class ResponseError < Error
|
|
1460
|
+
end
|
|
1461
|
+
|
|
1462
|
+
class StateError < ResponseError
|
|
1463
|
+
end
|
|
1464
|
+
|
|
1465
|
+
class StatusError < ResponseError
|
|
1466
|
+
attr_reader response: Response
|
|
1467
|
+
def initialize: (Response response) -> void
|
|
1468
|
+
end
|
|
1469
|
+
|
|
1470
|
+
class ParseError < ResponseError
|
|
1471
|
+
end
|
|
1472
|
+
|
|
1473
|
+
class UnsupportedMimeTypeError < Error
|
|
1474
|
+
end
|
|
1475
|
+
|
|
1476
|
+
class TimeoutError < Error
|
|
1477
|
+
end
|
|
1478
|
+
|
|
1479
|
+
class ConnectTimeoutError < TimeoutError
|
|
1480
|
+
end
|
|
1481
|
+
|
|
1482
|
+
class HeaderError < Error
|
|
1483
|
+
end
|
|
1484
|
+
|
|
1485
|
+
class OutOfRetriesError < Error
|
|
1486
|
+
attr_accessor response: Response?
|
|
1487
|
+
attr_writer cause: Exception?
|
|
1488
|
+
def cause: () -> Exception?
|
|
1489
|
+
end
|
|
1490
|
+
|
|
1491
|
+
module Timeout
|
|
1492
|
+
class Null
|
|
1493
|
+
NATIVE_CONNECT_TIMEOUT: bool
|
|
1494
|
+
|
|
1495
|
+
attr_reader options: Hash[Symbol, Numeric]
|
|
1496
|
+
attr_reader socket: untyped
|
|
1497
|
+
|
|
1498
|
+
def initialize: (?read_timeout: Numeric?, ?write_timeout: Numeric?, ?connect_timeout: Numeric?, ?global_timeout: Numeric?) -> void
|
|
1499
|
+
def connect: (untyped socket_class, String host, Integer port, ?nodelay: bool) -> void
|
|
1500
|
+
def connect_ssl: () -> void
|
|
1501
|
+
def close: () -> void
|
|
1502
|
+
def closed?: () -> bool
|
|
1503
|
+
def start_tls: (String host, untyped ssl_socket_class, OpenSSL::SSL::SSLContext ssl_context) -> void
|
|
1504
|
+
def readpartial: (Integer size, ?String? buffer) -> (String | Symbol)
|
|
1505
|
+
def write: (String data) -> Integer
|
|
1506
|
+
def <<: (String data) -> Integer
|
|
1507
|
+
|
|
1508
|
+
private
|
|
1509
|
+
|
|
1510
|
+
def read_timeout: () -> Numeric?
|
|
1511
|
+
def write_timeout: () -> Numeric?
|
|
1512
|
+
def rescue_readable: (?Numeric? timeout) { () -> untyped } -> untyped
|
|
1513
|
+
def rescue_writable: (?Numeric? timeout) { () -> untyped } -> untyped
|
|
1514
|
+
def open_socket: (untyped socket_class, String host, Integer port, ?connect_timeout: Numeric?) -> untyped
|
|
1515
|
+
def open_with_timeout: (untyped socket_class, String host, Integer port, Numeric connect_timeout) -> untyped
|
|
1516
|
+
def native_timeout?: (untyped socket_class) -> bool
|
|
1517
|
+
end
|
|
1518
|
+
|
|
1519
|
+
class PerOperation < Null
|
|
1520
|
+
KEYS: Hash[Symbol, Symbol]
|
|
1521
|
+
WAIT_RESULTS: Array[Symbol]
|
|
1522
|
+
|
|
1523
|
+
def self.normalize_options: (Hash[Symbol, Numeric] options) -> Hash[Symbol, Numeric]
|
|
1524
|
+
|
|
1525
|
+
private
|
|
1526
|
+
|
|
1527
|
+
def self.extract_global_timeout!: (Hash[Symbol, Numeric] options) -> Numeric?
|
|
1528
|
+
def self.resolve_timeout_value!: (Hash[Symbol, Numeric] options, Symbol short, Symbol long) -> Numeric
|
|
1529
|
+
|
|
1530
|
+
attr_reader read_timeout: Numeric?
|
|
1531
|
+
attr_reader write_timeout: Numeric?
|
|
1532
|
+
attr_reader connect_timeout: Numeric?
|
|
1533
|
+
|
|
1534
|
+
def initialize: (?read_timeout: Numeric?, ?write_timeout: Numeric?, ?connect_timeout: Numeric?) -> void
|
|
1535
|
+
def connect: (untyped socket_class, String host, Integer port, ?nodelay: bool) -> void
|
|
1536
|
+
def readpartial: (Integer size, ?String? buffer) -> (String | Symbol)
|
|
1537
|
+
def write: (String data) -> Integer
|
|
1538
|
+
|
|
1539
|
+
private
|
|
1540
|
+
|
|
1541
|
+
def wait_for_io: (Symbol result, Numeric? timeout) -> untyped
|
|
1542
|
+
end
|
|
1543
|
+
|
|
1544
|
+
class Global < Null
|
|
1545
|
+
WAIT_RESULTS: Array[Symbol]
|
|
1546
|
+
|
|
1547
|
+
@timeout: Numeric
|
|
1548
|
+
@time_left: Numeric
|
|
1549
|
+
@started: Time
|
|
1550
|
+
@read_timeout: Numeric?
|
|
1551
|
+
@write_timeout: Numeric?
|
|
1552
|
+
@connect_timeout: Numeric?
|
|
1553
|
+
|
|
1554
|
+
def initialize: (global_timeout: Numeric, ?read_timeout: Numeric?, ?write_timeout: Numeric?, ?connect_timeout: Numeric?) -> void
|
|
1555
|
+
def reset_counter: () -> Numeric
|
|
1556
|
+
def connect: (untyped socket_class, String host, Integer port, ?nodelay: bool) -> void
|
|
1557
|
+
def readpartial: (Integer size, ?String? buffer) -> (String | Symbol)
|
|
1558
|
+
def write: (String data) -> (Integer | Symbol)
|
|
1559
|
+
|
|
1560
|
+
private
|
|
1561
|
+
|
|
1562
|
+
def read_nonblock: (Integer size, ?String? buffer) -> untyped
|
|
1563
|
+
def write_nonblock: (String data) -> untyped
|
|
1564
|
+
def perform_io: (?Numeric? per_op_timeout) { () -> untyped } -> untyped
|
|
1565
|
+
def handle_io_result: (untyped result) -> untyped
|
|
1566
|
+
def wait_for_io: (Symbol result, ?Numeric? per_op_timeout) -> void
|
|
1567
|
+
def wait_readable_or_timeout: (?Numeric? per_op) -> void
|
|
1568
|
+
def wait_writable_or_timeout: (?Numeric? per_op) -> void
|
|
1569
|
+
def effective_timeout: (Numeric? per_op_timeout) -> Numeric
|
|
1570
|
+
def reset_timer: () -> void
|
|
1571
|
+
def log_time: () -> void
|
|
1572
|
+
end
|
|
1573
|
+
end
|
|
1574
|
+
|
|
1575
|
+
module Retriable
|
|
1576
|
+
class Performer
|
|
1577
|
+
RETRIABLE_ERRORS: Array[singleton(Exception)]
|
|
1578
|
+
|
|
1579
|
+
@exception_classes: Array[singleton(Exception)]
|
|
1580
|
+
@retry_statuses: untyped
|
|
1581
|
+
@tries: Integer
|
|
1582
|
+
@on_retry: ^(Request, Exception?, Response?) -> void
|
|
1583
|
+
@should_retry_proc: untyped
|
|
1584
|
+
@delay_calculator: DelayCalculator
|
|
1585
|
+
|
|
1586
|
+
def initialize: (?tries: Integer, ?delay: (Numeric | ^(Integer) -> Numeric)?, ?exceptions: Array[singleton(Exception)], ?retry_statuses: untyped, ?on_retry: ^(Request, Exception?, Response?) -> void, ?max_delay: Numeric, ?should_retry: (^(Request, Exception?, Response?, Integer) -> bool)?) -> void
|
|
1587
|
+
def perform: (Client client, Request req) { () -> Response? } -> untyped
|
|
1588
|
+
def calculate_delay: (Integer iteration, Response? response) -> Float
|
|
1589
|
+
|
|
1590
|
+
private
|
|
1591
|
+
|
|
1592
|
+
def retry_attempt: (Client client, Request req, Exception? err, Response? res, Integer attempt) -> void
|
|
1593
|
+
def finish_attempt: (Client client, Exception err) -> void
|
|
1594
|
+
def try_request: () { () -> Response? } -> [Exception?, Response?]
|
|
1595
|
+
def retry_request?: (Request req, Exception? err, Response? res, Integer attempt) -> bool
|
|
1596
|
+
def retry_exception?: (Exception err) -> bool
|
|
1597
|
+
def retry_response?: (untyped res) -> bool
|
|
1598
|
+
def wait_for_retry_or_raise: (Request req, Exception? err, Response? res, Integer attempt) -> void
|
|
1599
|
+
def out_of_retries_error: (Request request, Response? response, Exception? exception) -> OutOfRetriesError
|
|
1600
|
+
end
|
|
1601
|
+
|
|
1602
|
+
class DelayCalculator
|
|
1603
|
+
RFC2822_DATE_REGEX: Regexp
|
|
1604
|
+
|
|
1605
|
+
@max_delay: Float
|
|
1606
|
+
@delay_proc: untyped
|
|
1607
|
+
@delay: Numeric?
|
|
1608
|
+
|
|
1609
|
+
def initialize: (?delay: (Numeric | ^(Integer) -> Numeric)?, ?max_delay: Numeric) -> void
|
|
1610
|
+
def call: (Integer iteration, Response? response) -> Float
|
|
1611
|
+
|
|
1612
|
+
private
|
|
1613
|
+
|
|
1614
|
+
def delay_from_retry_header: (String | Array[String] value) -> Numeric
|
|
1615
|
+
def calculate_delay_from_iteration: (Integer iteration) -> untyped
|
|
1616
|
+
def ensure_delay_in_bounds: (Numeric delay) -> Float
|
|
1617
|
+
end
|
|
1618
|
+
end
|
|
1619
|
+
end
|