httpx 1.4.4 → 1.5.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/doc/release_notes/1_5_0.md +126 -0
- data/lib/httpx/adapters/datadog.rb +24 -3
- data/lib/httpx/adapters/webmock.rb +1 -0
- data/lib/httpx/buffer.rb +16 -5
- data/lib/httpx/connection/http1.rb +8 -9
- data/lib/httpx/connection/http2.rb +48 -24
- data/lib/httpx/connection.rb +36 -19
- data/lib/httpx/errors.rb +2 -11
- data/lib/httpx/headers.rb +24 -23
- data/lib/httpx/io/ssl.rb +2 -1
- data/lib/httpx/io/tcp.rb +9 -7
- data/lib/httpx/io/unix.rb +1 -1
- data/lib/httpx/loggable.rb +13 -1
- data/lib/httpx/options.rb +63 -48
- data/lib/httpx/parser/http1.rb +1 -1
- data/lib/httpx/plugins/aws_sigv4.rb +1 -0
- data/lib/httpx/plugins/callbacks.rb +19 -6
- data/lib/httpx/plugins/circuit_breaker.rb +4 -3
- data/lib/httpx/plugins/cookies/jar.rb +0 -2
- data/lib/httpx/plugins/cookies/set_cookie_parser.rb +7 -4
- data/lib/httpx/plugins/cookies.rb +4 -4
- data/lib/httpx/plugins/follow_redirects.rb +4 -2
- data/lib/httpx/plugins/grpc/call.rb +1 -1
- data/lib/httpx/plugins/h2c.rb +7 -1
- data/lib/httpx/plugins/persistent.rb +22 -1
- data/lib/httpx/plugins/proxy/http.rb +3 -1
- data/lib/httpx/plugins/query.rb +35 -0
- data/lib/httpx/plugins/response_cache/file_store.rb +115 -15
- data/lib/httpx/plugins/response_cache/store.rb +7 -67
- data/lib/httpx/plugins/response_cache.rb +179 -29
- data/lib/httpx/plugins/retries.rb +26 -14
- data/lib/httpx/plugins/stream.rb +4 -2
- data/lib/httpx/plugins/stream_bidi.rb +315 -0
- data/lib/httpx/pool.rb +58 -5
- data/lib/httpx/request/body.rb +1 -1
- data/lib/httpx/request.rb +6 -2
- data/lib/httpx/resolver/https.rb +10 -4
- data/lib/httpx/resolver/native.rb +13 -13
- data/lib/httpx/resolver/resolver.rb +4 -0
- data/lib/httpx/resolver/system.rb +37 -14
- data/lib/httpx/resolver.rb +2 -2
- data/lib/httpx/response/body.rb +10 -21
- data/lib/httpx/response/buffer.rb +36 -12
- data/lib/httpx/response.rb +11 -1
- data/lib/httpx/selector.rb +16 -12
- data/lib/httpx/session.rb +79 -19
- data/lib/httpx/timers.rb +24 -16
- data/lib/httpx/transcoder/multipart/decoder.rb +4 -2
- data/lib/httpx/transcoder/multipart/encoder.rb +2 -1
- data/lib/httpx/version.rb +1 -1
- data/sig/buffer.rbs +1 -1
- data/sig/chainable.rbs +5 -2
- data/sig/connection/http2.rbs +11 -2
- data/sig/connection.rbs +4 -4
- data/sig/errors.rbs +0 -3
- data/sig/headers.rbs +15 -10
- data/sig/httpx.rbs +5 -1
- data/sig/io/tcp.rbs +6 -0
- data/sig/loggable.rbs +2 -0
- data/sig/options.rbs +7 -1
- data/sig/plugins/cookies/cookie.rbs +1 -3
- data/sig/plugins/cookies/jar.rbs +4 -4
- data/sig/plugins/cookies/set_cookie_parser.rbs +22 -0
- data/sig/plugins/cookies.rbs +2 -0
- data/sig/plugins/h2c.rbs +4 -0
- data/sig/plugins/proxy/http.rbs +3 -0
- data/sig/plugins/proxy.rbs +4 -0
- data/sig/plugins/query.rbs +18 -0
- data/sig/plugins/response_cache/file_store.rbs +19 -0
- data/sig/plugins/response_cache/store.rbs +13 -0
- data/sig/plugins/response_cache.rbs +41 -19
- data/sig/plugins/retries.rbs +4 -3
- data/sig/plugins/stream.rbs +5 -1
- data/sig/plugins/stream_bidi.rbs +68 -0
- data/sig/plugins/upgrade/h2.rbs +9 -0
- data/sig/plugins/upgrade.rbs +5 -0
- data/sig/pool.rbs +5 -0
- data/sig/punycode.rbs +5 -0
- data/sig/request.rbs +2 -0
- data/sig/resolver/https.rbs +3 -2
- data/sig/resolver/native.rbs +1 -2
- data/sig/resolver/resolver.rbs +11 -3
- data/sig/resolver/system.rbs +19 -2
- data/sig/resolver.rbs +11 -7
- data/sig/response/body.rbs +3 -4
- data/sig/response/buffer.rbs +2 -3
- data/sig/response.rbs +2 -2
- data/sig/selector.rbs +20 -10
- data/sig/session.rbs +14 -6
- data/sig/timers.rbs +5 -7
- data/sig/transcoder/multipart.rbs +4 -3
- metadata +13 -2
data/sig/buffer.rbs
CHANGED
data/sig/chainable.rbs
CHANGED
@@ -21,14 +21,16 @@ module HTTPX
|
|
21
21
|
| (:cookies, ?options) -> Plugins::sessionCookies
|
22
22
|
| (:expect, ?options) -> Session
|
23
23
|
| (:follow_redirects, ?options) -> Plugins::sessionFollowRedirects
|
24
|
-
| (:upgrade, ?options) ->
|
25
|
-
| (:h2c, ?options) ->
|
24
|
+
| (:upgrade, ?options) -> Plugins::sessionUpgrade
|
25
|
+
| (:h2c, ?options) -> Plugins::sessionUpgrade
|
26
|
+
| (:h2, ?options) -> Plugins::sessionUpgrade
|
26
27
|
| (:persistent, ?options) -> Plugins::sessionPersistent
|
27
28
|
| (:proxy, ?options) -> (Plugins::sessionProxy & Plugins::httpProxy)
|
28
29
|
| (:push_promise, ?options) -> Plugins::sessionPushPromise
|
29
30
|
| (:retries, ?options) -> Plugins::sessionRetries
|
30
31
|
| (:rate_limiter, ?options) -> Session
|
31
32
|
| (:stream, ?options) -> Plugins::sessionStream
|
33
|
+
| (:stream_bidi, ?options) -> Plugins::sessionStreamBidi
|
32
34
|
| (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
|
33
35
|
| (:grpc, ?options) -> Plugins::grpcSession
|
34
36
|
| (:response_cache, ?options) -> Plugins::sessionResponseCache
|
@@ -39,6 +41,7 @@ module HTTPX
|
|
39
41
|
| (:ssrf_filter, ?options) -> Plugins::sessionSsrf
|
40
42
|
| (:webdav, ?options) -> Plugins::sessionWebDav
|
41
43
|
| (:xml, ?options) -> Plugins::sessionXML
|
44
|
+
| (:query, ?options) -> Plugins::sessionQuery
|
42
45
|
| (Symbol | Module, ?options) { (Class) -> void } -> Session
|
43
46
|
| (Symbol | Module, ?options) -> Session
|
44
47
|
|
data/sig/connection/http2.rbs
CHANGED
@@ -16,6 +16,8 @@ module HTTPX
|
|
16
16
|
@drains: Hash[Request, String]
|
17
17
|
@pings: Array[String]
|
18
18
|
@buffer: Buffer
|
19
|
+
@handshake_completed: bool
|
20
|
+
@wait_for_handshake: bool
|
19
21
|
|
20
22
|
def interests: () -> io_interests?
|
21
23
|
|
@@ -27,8 +29,6 @@ module HTTPX
|
|
27
29
|
|
28
30
|
def <<: (string) -> void
|
29
31
|
|
30
|
-
def can_buffer_more_requests?: () -> bool
|
31
|
-
|
32
32
|
def send: (Request request, ?bool head) -> bool
|
33
33
|
|
34
34
|
def consume: () -> void
|
@@ -45,6 +45,8 @@ module HTTPX
|
|
45
45
|
|
46
46
|
def initialize: (Buffer buffer, Options options) -> untyped
|
47
47
|
|
48
|
+
def can_buffer_more_requests?: () -> bool
|
49
|
+
|
48
50
|
def send_pending: () -> void
|
49
51
|
|
50
52
|
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
@@ -63,6 +65,10 @@ module HTTPX
|
|
63
65
|
|
64
66
|
def join_body: (::HTTP2::Stream stream, Request request) -> void
|
65
67
|
|
68
|
+
def send_chunk: (Request request, ::HTTP2::Stream stream, String chunk, String? next_chunk) -> void
|
69
|
+
|
70
|
+
def end_stream?: (Request request, String? next_chunk) -> void
|
71
|
+
|
66
72
|
def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
|
67
73
|
|
68
74
|
def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
|
@@ -92,12 +98,15 @@ module HTTPX
|
|
92
98
|
def on_pong: (string ping) -> void
|
93
99
|
|
94
100
|
class Error < ::HTTPX::Error
|
101
|
+
def initialize: (Integer id, Symbol | StandardError error) -> void
|
95
102
|
end
|
96
103
|
|
97
104
|
class GoawayError < Error
|
105
|
+
def initialize: () -> void
|
98
106
|
end
|
99
107
|
|
100
108
|
class PingError < Error
|
109
|
+
def initialize: () -> void
|
101
110
|
end
|
102
111
|
end
|
103
112
|
end
|
data/sig/connection.rbs
CHANGED
@@ -20,6 +20,7 @@ module HTTPX
|
|
20
20
|
|
21
21
|
|
22
22
|
attr_reader type: io_type
|
23
|
+
attr_reader io: TCP | SSL | UNIX | nil
|
23
24
|
attr_reader origin: http_uri
|
24
25
|
attr_reader origins: Array[String]
|
25
26
|
attr_reader state: Symbol
|
@@ -39,7 +40,6 @@ module HTTPX
|
|
39
40
|
@keep_alive_timeout: Numeric?
|
40
41
|
@timeout: Numeric?
|
41
42
|
@current_timeout: Numeric?
|
42
|
-
@io: TCP | SSL | UNIX
|
43
43
|
@parser: Object & _Parser
|
44
44
|
@connected_at: Float
|
45
45
|
@response_received_at: Float
|
@@ -64,6 +64,8 @@ module HTTPX
|
|
64
64
|
|
65
65
|
def mergeable?: (Connection connection) -> bool
|
66
66
|
|
67
|
+
def coalesce!: (instance connection) -> void
|
68
|
+
|
67
69
|
def coalescable?: (Connection connection) -> bool
|
68
70
|
|
69
71
|
def create_idle: (?Hash[Symbol, untyped] options) -> instance
|
@@ -104,8 +106,6 @@ module HTTPX
|
|
104
106
|
|
105
107
|
def handle_socket_timeout: (Numeric interval) -> void
|
106
108
|
|
107
|
-
def coalesced_connection=: (instance connection) -> void
|
108
|
-
|
109
109
|
def sibling=: (instance? connection) -> void
|
110
110
|
|
111
111
|
def handle_connect_error: (StandardError error) -> void
|
@@ -164,6 +164,6 @@ module HTTPX
|
|
164
164
|
|
165
165
|
def set_request_timeout: (Symbol label, Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
|
166
166
|
|
167
|
-
def
|
167
|
+
def parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
|
168
168
|
end
|
169
169
|
end
|
data/sig/errors.rbs
CHANGED
data/sig/headers.rbs
CHANGED
@@ -2,7 +2,7 @@ module HTTPX
|
|
2
2
|
class Headers
|
3
3
|
include _ToS
|
4
4
|
|
5
|
-
@headers: Hash[String, Array[
|
5
|
+
@headers: Hash[String, Array[_ToS]]
|
6
6
|
|
7
7
|
def self.new: (?untyped headers) -> instance
|
8
8
|
|
@@ -11,34 +11,39 @@ module HTTPX
|
|
11
11
|
def []: (String field) -> String?
|
12
12
|
def []=: (String field, headers_value value) -> void
|
13
13
|
|
14
|
-
def add: (String field,
|
15
|
-
def delete: (String field) -> Array[
|
14
|
+
def add: (String field, String value) -> void
|
15
|
+
def delete: (String field) -> Array[_ToS]?
|
16
16
|
|
17
17
|
def each: (?_Each[[String, String]]? extra_headers) { (String k, String v) -> void } -> void
|
18
18
|
| (?_Each[[String, String]]? extra_headers) -> Enumerable[[String, String]]
|
19
19
|
|
20
|
-
def get: (String field) -> Array[
|
20
|
+
def get: (String field) -> Array[_ToS]
|
21
21
|
def key?: (String downcased_key) -> bool
|
22
22
|
|
23
23
|
def merge: (_Each[[String, headers_value]] other) -> Headers
|
24
24
|
|
25
|
-
def
|
25
|
+
def empty?: () -> bool
|
26
26
|
|
27
27
|
def to_a: () -> Array[[String, String]]
|
28
|
+
|
28
29
|
def to_hash: () -> Hash[String, String]
|
30
|
+
|
29
31
|
alias to_h to_hash
|
30
32
|
|
31
33
|
def inspect: () -> String
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
|
-
def initialize: (?
|
36
|
-
|
37
|
-
def
|
37
|
+
def initialize: (?(headers_input | instance)?) -> void
|
38
|
+
|
39
|
+
def array_value: (headers_value value) -> Array[_ToS]
|
40
|
+
|
41
|
+
def downcased: (header_field field) -> String
|
38
42
|
end
|
39
43
|
|
44
|
+
type header_field = string | _ToS
|
40
45
|
type headers_value = _ToS | Array[_ToS]
|
41
|
-
type headers_hash = Hash[
|
42
|
-
type headers_input = headers_hash | Array[[
|
46
|
+
type headers_hash = Hash[header_field, headers_value]
|
47
|
+
type headers_input = headers_hash | Array[[header_field, headers_value]]
|
43
48
|
type headers = Headers | headers_input
|
44
49
|
end
|
data/sig/httpx.rbs
CHANGED
@@ -2,6 +2,7 @@ module HTTPX
|
|
2
2
|
extend Chainable
|
3
3
|
|
4
4
|
EMPTY: Array[untyped]
|
5
|
+
EMPTY_HASH: Hash[untyped, untyped]
|
5
6
|
|
6
7
|
VERSION: String
|
7
8
|
|
@@ -16,7 +17,10 @@ module HTTPX
|
|
16
17
|
type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
|
17
18
|
|
18
19
|
module Plugins
|
19
|
-
|
20
|
+
self.@plugins: Hash[Symbol, Module]
|
21
|
+
self.@plugins_mutex: Thread::Mutex
|
22
|
+
|
23
|
+
def self?.load_plugin: (Symbol name) -> Module
|
20
24
|
|
21
25
|
def self?.register_plugin: (Symbol, Module) -> void
|
22
26
|
end
|
data/sig/io/tcp.rbs
CHANGED
@@ -14,6 +14,12 @@ module HTTPX
|
|
14
14
|
|
15
15
|
alias host ip
|
16
16
|
|
17
|
+
@hostname: String
|
18
|
+
|
19
|
+
@options: Options
|
20
|
+
|
21
|
+
@fallback_protocol: String
|
22
|
+
|
17
23
|
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
18
24
|
def initialize: (URI::Generic origin, Array[ipaddr]? addresses, Options options) ?{ (instance) -> void } -> void
|
19
25
|
|
data/sig/loggable.rbs
CHANGED
@@ -11,5 +11,7 @@ module HTTPX
|
|
11
11
|
def log: (?level: Integer?, ?color: Symbol?, ?debug_level: Integer, ?debug: _IOLogger?) { () -> String } -> void
|
12
12
|
|
13
13
|
def log_exception: (Exception error, ?level: Integer, ?color: Symbol, ?debug_level: Integer, ?debug: _IOLogger?) -> void
|
14
|
+
|
15
|
+
def log_redact: (_ToS text, ?bool should_redact) -> String
|
14
16
|
end
|
15
17
|
end
|
data/sig/options.rbs
CHANGED
@@ -13,6 +13,7 @@ module HTTPX
|
|
13
13
|
KEEP_ALIVE_TIMEOUT: Integer
|
14
14
|
SETTINGS_TIMEOUT: Integer
|
15
15
|
CLOSE_HANDSHAKE_TIMEOUT: Integer
|
16
|
+
SET_TEMPORARY_NAME: ^(Module mod, ?Symbol pl) -> void
|
16
17
|
DEFAULT_OPTIONS: Hash[Symbol, untyped]
|
17
18
|
REQUEST_BODY_IVARS: Array[Symbol]
|
18
19
|
|
@@ -25,7 +26,7 @@ module HTTPX
|
|
25
26
|
attr_reader uri: URI?
|
26
27
|
|
27
28
|
# headers
|
28
|
-
attr_reader headers:
|
29
|
+
attr_reader headers: headers?
|
29
30
|
|
30
31
|
# timeout
|
31
32
|
attr_reader timeout: timeout
|
@@ -89,6 +90,8 @@ module HTTPX
|
|
89
90
|
|
90
91
|
attr_reader response_body_class: singleton(Response::Body)
|
91
92
|
|
93
|
+
attr_reader options_class: singleton(Options)
|
94
|
+
|
92
95
|
attr_reader resolver_class: Symbol | Class
|
93
96
|
|
94
97
|
attr_reader ssl: Hash[Symbol, untyped]
|
@@ -109,6 +112,9 @@ module HTTPX
|
|
109
112
|
# persistent
|
110
113
|
attr_reader persistent: bool
|
111
114
|
|
115
|
+
# close_on_fork
|
116
|
+
attr_reader close_on_fork: bool
|
117
|
+
|
112
118
|
# resolver_options
|
113
119
|
attr_reader resolver_options: Hash[Symbol, untyped]
|
114
120
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Plugins::Cookies
|
3
|
-
type cookie_attributes = Hash[Symbol | String, top]
|
4
|
-
|
5
3
|
class Cookie
|
6
4
|
include Comparable
|
7
5
|
|
@@ -33,7 +31,7 @@ module HTTPX
|
|
33
31
|
def cookie_value: () -> String
|
34
32
|
alias to_s cookie_value
|
35
33
|
|
36
|
-
def valid_for_uri?: (uri) -> bool
|
34
|
+
def valid_for_uri?: (http_uri uri) -> bool
|
37
35
|
|
38
36
|
def self.new: (Cookie) -> instance
|
39
37
|
| (cookie_attributes) -> instance
|
data/sig/plugins/cookies/jar.rbs
CHANGED
@@ -11,12 +11,12 @@ module HTTPX
|
|
11
11
|
|
12
12
|
def add: (Cookie name, ?String path) -> void
|
13
13
|
|
14
|
-
def []: (
|
14
|
+
def []: (http_uri) -> Array[Cookie]
|
15
15
|
|
16
|
-
def each: (?
|
17
|
-
| (?
|
16
|
+
def each: (?http_uri?) { (Cookie) -> void } -> void
|
17
|
+
| (?http_uri?) -> Enumerable[Cookie]
|
18
18
|
|
19
|
-
def merge: (_Each[cookie] cookies) ->
|
19
|
+
def merge: (_Each[cookie] cookies) -> self
|
20
20
|
|
21
21
|
private
|
22
22
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins::Cookies
|
3
|
+
module SetCookieParser
|
4
|
+
RE_WSP: Regexp
|
5
|
+
|
6
|
+
RE_NAME: Regexp
|
7
|
+
|
8
|
+
RE_BAD_CHAR: Regexp
|
9
|
+
|
10
|
+
RE_COOKIE_COMMA: Regexp
|
11
|
+
|
12
|
+
def self?.call: (String set_cookie) { (String name, String value, cookie_attributes attrs) -> void } -> void
|
13
|
+
|
14
|
+
def self?.scan_dquoted: (StringScanner scanner) -> String
|
15
|
+
|
16
|
+
def self?.scan_value: (StringScanner scanner, ?bool comma_as_separator) -> String
|
17
|
+
|
18
|
+
def self?.scan_name_value: (StringScanner scanner, ?bool comma_as_separator) -> [String?, String?]
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/sig/plugins/cookies.rbs
CHANGED
data/sig/plugins/h2c.rbs
CHANGED
data/sig/plugins/proxy/http.rbs
CHANGED
data/sig/plugins/proxy.rbs
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
module Query
|
4
|
+
def self.subplugins: () -> Hash[Symbol, Module]
|
5
|
+
|
6
|
+
module InstanceMethods
|
7
|
+
def query: (uri | [uri], **untyped) -> response
|
8
|
+
| (_Each[uri | [uri, request_params]], **untyped) -> Array[response]
|
9
|
+
end
|
10
|
+
|
11
|
+
module QueryRetries
|
12
|
+
module InstanceMethods
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
type sessionQuery = Session & Query::InstanceMethods
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
module ResponseCache
|
4
|
+
class FileStore
|
5
|
+
@dir: Pathname
|
6
|
+
|
7
|
+
include _ResponseCacheStore
|
8
|
+
|
9
|
+
def initialize: (?path dir) -> void
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def file_path: (cacheRequest request) -> Pathname
|
14
|
+
|
15
|
+
def read_from_file: (cacheRequest request, File f) -> cacheResponse?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,47 +3,62 @@ module HTTPX
|
|
3
3
|
module ResponseCache
|
4
4
|
CACHEABLE_VERBS: Array[verb]
|
5
5
|
CACHEABLE_STATUS_CODES: Array[Integer]
|
6
|
+
SUPPORTED_VARY_HEADERS: Array[String]
|
6
7
|
|
7
|
-
def self?.
|
8
|
-
def self?.cacheable_response?: (::HTTPX::ErrorResponse | (Response & ResponseMethods) response) -> bool
|
9
|
-
def self?.cached_response?: (response response) -> bool
|
8
|
+
def self?.cacheable_response?: (::HTTPX::ErrorResponse | cacheResponse response) -> bool
|
10
9
|
|
11
|
-
|
12
|
-
@store: Hash[String, Array[Response]]
|
10
|
+
def self?.not_modified?: (response response) -> bool
|
13
11
|
|
14
|
-
|
12
|
+
interface _ResponseCacheOptions
|
13
|
+
def response_cache_store: () -> Store
|
15
14
|
|
16
|
-
def
|
17
|
-
|
18
|
-
def cached?: (Request request) -> boolish
|
19
|
-
|
20
|
-
def cache: (Request request, Response response) -> void
|
21
|
-
|
22
|
-
def prepare: (Request request) -> void
|
23
|
-
|
24
|
-
private
|
15
|
+
def supported_vary_headers: () -> Array[String]
|
16
|
+
end
|
25
17
|
|
26
|
-
|
18
|
+
interface _ResponseCacheStore
|
19
|
+
def get: (cacheRequest request) -> cacheResponse?
|
27
20
|
|
28
|
-
def
|
21
|
+
def set: (cacheRequest request, cacheResponse response) -> void
|
29
22
|
|
30
|
-
def
|
23
|
+
def clear: () -> void
|
31
24
|
end
|
32
25
|
|
33
26
|
module InstanceMethods
|
34
27
|
@response_cache: Store
|
35
28
|
|
36
29
|
def clear_response_cache: () -> void
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def prepare_cache: (cacheRequest request) -> void
|
34
|
+
|
35
|
+
def cacheable_request?: (cacheRequest request) -> bool
|
36
|
+
|
37
|
+
def match_by_vary?: (cacheRequest request, cacheResponse response) -> bool
|
37
38
|
end
|
38
39
|
|
39
40
|
module RequestMethods
|
41
|
+
attr_accessor cached_response: cacheResponse?
|
42
|
+
|
40
43
|
@response_cache_key: String
|
41
44
|
|
42
45
|
def response_cache_key: () -> String
|
46
|
+
|
47
|
+
def cacheable_verb?: () -> bool
|
43
48
|
end
|
44
49
|
|
45
50
|
module ResponseMethods
|
46
|
-
|
51
|
+
attr_writer original_request: cacheRequest
|
52
|
+
|
53
|
+
@cache: bool
|
54
|
+
|
55
|
+
def original_request: () -> cacheRequest?
|
56
|
+
|
57
|
+
def cached?: () -> bool
|
58
|
+
|
59
|
+
def mark_as_cached!: () -> void
|
60
|
+
|
61
|
+
def copy_from_cached!: () -> void
|
47
62
|
|
48
63
|
def fresh?: () -> bool
|
49
64
|
|
@@ -57,6 +72,13 @@ module HTTPX
|
|
57
72
|
|
58
73
|
def date: () -> Time
|
59
74
|
end
|
75
|
+
|
76
|
+
|
77
|
+
type cacheOptions = Options & _ResponseCacheOptions
|
78
|
+
|
79
|
+
type cacheRequest = Request & RequestMethods
|
80
|
+
|
81
|
+
type cacheResponse = Response & ResponseMethods
|
60
82
|
end
|
61
83
|
|
62
84
|
type sessionResponseCache = Session & ResponseCache::InstanceMethods
|
data/sig/plugins/retries.rbs
CHANGED
@@ -3,6 +3,7 @@ module HTTPX
|
|
3
3
|
module Retries
|
4
4
|
MAX_RETRIES: Integer
|
5
5
|
IDEMPOTENT_METHODS: Array[String]
|
6
|
+
RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
|
6
7
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
7
8
|
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
8
9
|
|
@@ -31,11 +32,11 @@ module HTTPX
|
|
31
32
|
|
32
33
|
def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> (retriesResponse | ErrorResponse)?
|
33
34
|
|
34
|
-
def
|
35
|
+
def repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
|
35
36
|
|
36
|
-
def
|
37
|
+
def retryable_error?: (_Exception error) -> bool
|
37
38
|
|
38
|
-
def
|
39
|
+
def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
|
39
40
|
|
40
41
|
end
|
41
42
|
|
data/sig/plugins/stream.rbs
CHANGED
@@ -16,6 +16,9 @@ module HTTPX
|
|
16
16
|
def stream: () -> StreamResponse?
|
17
17
|
end
|
18
18
|
|
19
|
+
module ResponseBodyMethods
|
20
|
+
@stream: StreamResponse?
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
type sessionStream = Session & Stream::InstanceMethods
|
@@ -26,8 +29,9 @@ module HTTPX
|
|
26
29
|
|
27
30
|
type streamRequest = Request & Plugins::Stream::RequestMethods
|
28
31
|
|
29
|
-
|
32
|
+
attr_reader request: streamRequest
|
30
33
|
@options: Options
|
34
|
+
|
31
35
|
@session: Plugins::sessionStream
|
32
36
|
@response_enum: Enumerator[String]?
|
33
37
|
@buffered_chunks: Array[String]
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
module StreamBidi
|
4
|
+
def self.load_dependencies: (singleton(Session)) -> void
|
5
|
+
|
6
|
+
def self.extra_options: (Options) -> (Options)
|
7
|
+
|
8
|
+
class HTTP2Bidi < Connection::HTTP2
|
9
|
+
@lock: Thread::Mutex
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def handle_stream: (::HTTP2::Stream stream, Request & RequestMethods request) -> void
|
14
|
+
|
15
|
+
def end_stream?: (Request & RequestMethods request, String? next_chunk) -> void
|
16
|
+
end
|
17
|
+
|
18
|
+
class BidiBuffer < Buffer
|
19
|
+
@parent_thread: Thread
|
20
|
+
@oob_mutex: Thread::Mutex
|
21
|
+
@oob_buffer: String
|
22
|
+
|
23
|
+
def rebuffer: () -> void
|
24
|
+
end
|
25
|
+
|
26
|
+
class Signal
|
27
|
+
@closed: bool
|
28
|
+
@pipe_read: ::IO
|
29
|
+
@pipe_write: ::IO
|
30
|
+
|
31
|
+
include _Selectable
|
32
|
+
|
33
|
+
def wakeup: () -> void
|
34
|
+
|
35
|
+
def mergeable?: () -> bool
|
36
|
+
|
37
|
+
def terminate: () -> void
|
38
|
+
end
|
39
|
+
|
40
|
+
module InstanceMethods
|
41
|
+
@signal: Signal
|
42
|
+
end
|
43
|
+
|
44
|
+
module RequestMethods
|
45
|
+
attr_accessor headers_sent: bool
|
46
|
+
|
47
|
+
@closed: bool
|
48
|
+
@mutex: Thread::Mutex
|
49
|
+
|
50
|
+
def closed?: () -> bool
|
51
|
+
end
|
52
|
+
|
53
|
+
module RequestBodyMethods
|
54
|
+
end
|
55
|
+
|
56
|
+
module ConnectionMethods
|
57
|
+
@write_buffer: BidiBuffer
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def parser_type: (String protocol) -> (singleton(Connection::HTTP1) | singleton(Connection::HTTP2) | singleton(HTTP2Bidi))
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
type sessionStreamBidi = Session & StreamBidi::InstanceMethods
|
67
|
+
end
|
68
|
+
end
|
data/sig/plugins/upgrade.rbs
CHANGED
@@ -13,6 +13,9 @@ module HTTPX
|
|
13
13
|
|
14
14
|
def self.extra_options: (Options) -> (Options & _UpgradeOptions)
|
15
15
|
|
16
|
+
module InstanceMethods
|
17
|
+
end
|
18
|
+
|
16
19
|
module ConnectionMethods
|
17
20
|
attr_reader upgrade_protocol: String?
|
18
21
|
attr_reader hijacked: boolish
|
@@ -20,5 +23,7 @@ module HTTPX
|
|
20
23
|
def hijack_io: () -> void
|
21
24
|
end
|
22
25
|
end
|
26
|
+
|
27
|
+
type sessionUpgrade = Session & Upgrade::InstanceMethods
|
23
28
|
end
|
24
29
|
end
|