httpx 0.15.4 → 0.18.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/0_16_0.md +93 -0
- data/doc/release_notes/0_16_1.md +5 -0
- data/doc/release_notes/0_17_0.md +49 -0
- data/doc/release_notes/0_18_0.md +69 -0
- data/lib/httpx/adapters/datadog.rb +1 -1
- data/lib/httpx/adapters/faraday.rb +8 -14
- data/lib/httpx/adapters/webmock.rb +9 -3
- data/lib/httpx/altsvc.rb +2 -2
- data/lib/httpx/buffer.rb +1 -1
- data/lib/httpx/callbacks.rb +1 -1
- data/lib/httpx/chainable.rb +18 -11
- data/lib/httpx/connection/http1.rb +21 -13
- data/lib/httpx/connection/http2.rb +20 -25
- data/lib/httpx/connection.rb +73 -77
- data/lib/httpx/domain_name.rb +1 -1
- data/lib/httpx/errors.rb +11 -11
- data/lib/httpx/extensions.rb +50 -4
- data/lib/httpx/headers.rb +1 -1
- data/lib/httpx/io/ssl.rb +3 -3
- data/lib/httpx/io/tls.rb +8 -8
- data/lib/httpx/loggable.rb +5 -5
- data/lib/httpx/options.rb +108 -81
- data/lib/httpx/parser/http1.rb +11 -7
- data/lib/httpx/plugins/aws_sdk_authentication.rb +42 -18
- data/lib/httpx/plugins/aws_sigv4.rb +19 -20
- data/lib/httpx/plugins/compression.rb +17 -14
- data/lib/httpx/plugins/cookies/cookie.rb +4 -2
- data/lib/httpx/plugins/cookies/jar.rb +21 -2
- data/lib/httpx/plugins/cookies.rb +20 -7
- data/lib/httpx/plugins/digest_authentication.rb +19 -15
- data/lib/httpx/plugins/expect.rb +26 -18
- data/lib/httpx/plugins/follow_redirects.rb +9 -9
- data/lib/httpx/plugins/grpc/call.rb +4 -1
- data/lib/httpx/plugins/grpc/message.rb +2 -2
- data/lib/httpx/plugins/grpc.rb +72 -46
- data/lib/httpx/plugins/h2c.rb +7 -3
- data/lib/httpx/plugins/internal_telemetry.rb +8 -8
- data/lib/httpx/plugins/multipart/decoder.rb +187 -0
- data/lib/httpx/plugins/multipart/mime_type_detector.rb +3 -3
- data/lib/httpx/plugins/multipart/part.rb +2 -2
- data/lib/httpx/plugins/multipart.rb +16 -2
- data/lib/httpx/plugins/ntlm_authentication.rb +12 -10
- data/lib/httpx/plugins/proxy/socks4.rb +2 -1
- data/lib/httpx/plugins/proxy/socks5.rb +2 -1
- data/lib/httpx/plugins/proxy/ssh.rb +20 -13
- data/lib/httpx/plugins/proxy.rb +10 -10
- data/lib/httpx/plugins/response_cache/store.rb +55 -0
- data/lib/httpx/plugins/response_cache.rb +88 -0
- data/lib/httpx/plugins/retries.rb +46 -23
- data/lib/httpx/plugins/stream.rb +3 -4
- data/lib/httpx/plugins/upgrade.rb +7 -6
- data/lib/httpx/pool.rb +39 -13
- data/lib/httpx/registry.rb +2 -2
- data/lib/httpx/request.rb +16 -25
- data/lib/httpx/resolver/https.rb +4 -8
- data/lib/httpx/resolver/native.rb +19 -5
- data/lib/httpx/resolver/resolver_mixin.rb +2 -1
- data/lib/httpx/resolver/system.rb +2 -0
- data/lib/httpx/resolver.rb +2 -2
- data/lib/httpx/response.rb +91 -48
- data/lib/httpx/selector.rb +11 -24
- data/lib/httpx/session.rb +41 -23
- data/lib/httpx/session2.rb +23 -0
- data/lib/httpx/timers.rb +84 -0
- data/lib/httpx/transcoder/body.rb +3 -2
- data/lib/httpx/transcoder/chunker.rb +2 -1
- data/lib/httpx/transcoder/form.rb +20 -0
- data/lib/httpx/transcoder/json.rb +12 -0
- data/lib/httpx/transcoder.rb +62 -1
- data/lib/httpx/utils.rb +10 -2
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +7 -3
- data/sig/buffer.rbs +3 -1
- data/sig/chainable.rbs +31 -29
- data/sig/connection/http1.rbs +11 -5
- data/sig/connection/http2.rbs +16 -5
- data/sig/connection.rbs +31 -13
- data/sig/errors.rbs +35 -1
- data/sig/headers.rbs +20 -19
- data/sig/httpx.rbs +4 -1
- data/sig/loggable.rbs +3 -1
- data/sig/options.rbs +45 -34
- data/sig/parser/http1.rbs +3 -3
- data/sig/plugins/authentication.rbs +1 -1
- data/sig/plugins/aws_sdk_authentication.rbs +25 -3
- data/sig/plugins/aws_sigv4.rbs +13 -5
- data/sig/plugins/basic_authentication.rbs +1 -1
- data/sig/plugins/compression.rbs +4 -6
- data/sig/plugins/cookies/cookie.rbs +5 -7
- data/sig/plugins/cookies/jar.rbs +9 -10
- data/sig/plugins/cookies.rbs +4 -5
- data/sig/plugins/digest_authentication.rbs +2 -3
- data/sig/plugins/expect.rbs +2 -4
- data/sig/plugins/follow_redirects.rbs +3 -5
- data/sig/plugins/grpc.rbs +4 -7
- data/sig/plugins/h2c.rbs +0 -2
- data/sig/plugins/multipart.rbs +64 -10
- data/sig/plugins/ntlm_authentication.rbs +2 -3
- data/sig/plugins/persistent.rbs +3 -8
- data/sig/plugins/proxy/ssh.rbs +4 -4
- data/sig/plugins/proxy.rbs +13 -13
- data/sig/plugins/push_promise.rbs +0 -2
- data/sig/plugins/response_cache.rbs +35 -0
- data/sig/plugins/retries.rbs +7 -8
- data/sig/plugins/stream.rbs +1 -1
- data/sig/plugins/upgrade.rbs +2 -3
- data/sig/pool.rbs +7 -2
- data/sig/registry.rbs +1 -1
- data/sig/request.rbs +11 -8
- data/sig/resolver/native.rbs +10 -5
- data/sig/resolver/resolver_mixin.rbs +4 -5
- data/sig/resolver/system.rbs +4 -0
- data/sig/resolver.rbs +7 -0
- data/sig/response.rbs +26 -13
- data/sig/selector.rbs +11 -9
- data/sig/session.rbs +22 -23
- data/sig/timers.rbs +32 -0
- data/sig/transcoder/body.rbs +6 -1
- data/sig/transcoder/chunker.rbs +8 -2
- data/sig/transcoder/form.rbs +3 -1
- data/sig/transcoder/json.rbs +2 -0
- data/sig/transcoder.rbs +13 -5
- data/sig/utils.rbs +6 -0
- metadata +18 -18
- data/lib/httpx/request2.rb +0 -14
data/sig/plugins/cookies/jar.rbs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
module Plugins::Cookies
|
|
3
3
|
class Jar
|
|
4
|
-
type cookie = Cookie | Array[String, String, cookie_attributes] | Array[String, String] | cookie_attributes
|
|
4
|
+
type cookie = Cookie | Array[[String, String, cookie_attributes]] | Array[[String, String]] | cookie_attributes
|
|
5
5
|
|
|
6
6
|
include Enumerable[Cookie]
|
|
7
7
|
|
|
8
8
|
@cookies: Array[Cookie]
|
|
9
9
|
|
|
10
|
-
def parse: (String) -> void
|
|
10
|
+
def parse: (String set_cookie) -> void
|
|
11
11
|
|
|
12
|
-
def add: (Cookie) -> void
|
|
13
|
-
| (Cookie, String) -> void
|
|
12
|
+
def add: (Cookie name, ?String path) -> void
|
|
14
13
|
|
|
15
14
|
def []: (uri) -> Array[Cookie]
|
|
16
15
|
|
|
17
|
-
def each: (uri) { (Cookie) -> void } -> void
|
|
18
|
-
| (uri) -> Enumerable[Cookie]
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
def each: (?uri) { (Cookie) -> void } -> void
|
|
17
|
+
| (?uri) -> Enumerable[Cookie]
|
|
18
|
+
|
|
19
|
+
def merge: (_Each[cookie] cookies) -> instance
|
|
20
|
+
|
|
21
21
|
private
|
|
22
22
|
|
|
23
|
-
def initialize: () ->
|
|
24
|
-
| (_Each[cookie]) -> untyped
|
|
23
|
+
def initialize: (?_Each[cookie] cookies) -> untyped
|
|
25
24
|
end
|
|
26
25
|
end
|
|
27
26
|
end
|
data/sig/plugins/cookies.rbs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
module Plugins
|
|
3
3
|
module Cookies
|
|
4
|
-
type jar = Jar | _Each[
|
|
4
|
+
type jar = Jar | _Each[Jar::cookie]
|
|
5
5
|
|
|
6
6
|
interface _CookieOptions
|
|
7
7
|
def cookies: () -> Jar?
|
|
8
|
-
def cookies=: (jar) -> Jar
|
|
9
8
|
end
|
|
10
|
-
|
|
9
|
+
|
|
11
10
|
def self.extra_options: (Options) -> (Options & _CookieOptions)
|
|
12
11
|
|
|
13
12
|
module InstanceMethods
|
|
@@ -19,7 +18,7 @@ module HTTPX
|
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
type sessionCookies = Session &
|
|
23
|
-
type headersCookies = Headers &
|
|
21
|
+
type sessionCookies = Session & Cookies::InstanceMethods
|
|
22
|
+
type headersCookies = Headers & Cookies::HeadersMethods
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -5,9 +5,8 @@ module HTTPX
|
|
|
5
5
|
|
|
6
6
|
interface _DigestOptions
|
|
7
7
|
def digest: () -> Digest?
|
|
8
|
-
def digest=: (Digest) -> Digest
|
|
9
8
|
end
|
|
10
|
-
|
|
9
|
+
|
|
11
10
|
def self.extra_options: (Options) -> (Options & _DigestOptions)
|
|
12
11
|
|
|
13
12
|
def self.load_dependencies: (*untyped) -> void
|
|
@@ -27,6 +26,6 @@ module HTTPX
|
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
30
|
-
type sessionDigestAuthentication =
|
|
29
|
+
type sessionDigestAuthentication = sessionAuthentication & DigestAuthentication::InstanceMethods
|
|
31
30
|
end
|
|
32
31
|
end
|
data/sig/plugins/expect.rbs
CHANGED
|
@@ -2,15 +2,13 @@ module HTTPX
|
|
|
2
2
|
module Plugins
|
|
3
3
|
module Expect
|
|
4
4
|
EXPECT_TIMEOUT: Integer
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
interface _ExpectOptions
|
|
7
7
|
def expect_timeout: () -> Integer?
|
|
8
|
-
def expect_timeout=: (int) -> Integer
|
|
9
8
|
|
|
10
9
|
def expect_threshold_size: () -> Integer?
|
|
11
|
-
def expect_threshold_size=: (int) -> Integer
|
|
12
10
|
end
|
|
13
|
-
|
|
11
|
+
|
|
14
12
|
def self.extra_options: (Options) -> (Options & _ExpectOptions)
|
|
15
13
|
end
|
|
16
14
|
end
|
|
@@ -5,15 +5,13 @@ module HTTPX
|
|
|
5
5
|
module FollowRedirects
|
|
6
6
|
MAX_REDIRECTS: Integer
|
|
7
7
|
REDIRECT_STATUS: Range[Integer]
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
interface _FollowRedirectsOptions
|
|
10
10
|
def max_redirects: () -> Integer?
|
|
11
|
-
def max_redirects=: (int) -> Integer
|
|
12
11
|
|
|
13
12
|
def follow_insecure_redirects: () -> bool?
|
|
14
|
-
def follow_insecure_redirects=: (bool) -> bool
|
|
15
13
|
end
|
|
16
|
-
|
|
14
|
+
|
|
17
15
|
def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
|
|
18
16
|
|
|
19
17
|
module InstanceMethods
|
|
@@ -30,6 +28,6 @@ module HTTPX
|
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
type sessionFollowRedirects = Session &
|
|
31
|
+
type sessionFollowRedirects = Session & FollowRedirects::InstanceMethods
|
|
34
32
|
end
|
|
35
33
|
end
|
data/sig/plugins/grpc.rbs
CHANGED
|
@@ -15,6 +15,8 @@ module HTTPX
|
|
|
15
15
|
type grpc_request = untyped | _Each[untyped]
|
|
16
16
|
type grpc_response = untyped | _Each[untyped]
|
|
17
17
|
|
|
18
|
+
type credentials = Proc
|
|
19
|
+
|
|
18
20
|
class Call
|
|
19
21
|
attr_writer decoder: _Callable
|
|
20
22
|
|
|
@@ -39,7 +41,7 @@ module HTTPX
|
|
|
39
41
|
|
|
40
42
|
def self?.decode: (String message, encodings: Array[String], encoders: Compression::encodings_registry) -> String
|
|
41
43
|
| (String message, encodings: Array[String], encoders: Compression::encodings_registry) { (String) -> void } -> void
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
def self?.cancel: (Request) -> void
|
|
44
46
|
|
|
45
47
|
def self?.verify_status: (StreamResponse | response) -> void
|
|
@@ -47,19 +49,14 @@ module HTTPX
|
|
|
47
49
|
|
|
48
50
|
interface _GRPCOptions
|
|
49
51
|
def grpc_service: () -> String?
|
|
50
|
-
def grpc_service=: (string) -> String
|
|
51
52
|
|
|
52
53
|
def grpc_compression: () -> compression_option?
|
|
53
|
-
def grpc_compression=: (compression_option) -> compression_option
|
|
54
54
|
|
|
55
55
|
def grpc_rpcs: () -> Hash[String, rpc_def]?
|
|
56
|
-
def grpc_rpcs=: (Hash[String, rpc_def]) -> Hash[String, rpc_def]
|
|
57
56
|
|
|
58
57
|
def grpc_deadline: () -> Integer?
|
|
59
|
-
def grpc_deadline=: (Integer) -> Integer
|
|
60
58
|
|
|
61
59
|
def call_credentials: () -> credentials?
|
|
62
|
-
def call_credentials=: (credentials) -> credentials
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
def self.extra_options: (Options) -> (Options & _GRPCOptions)
|
|
@@ -88,6 +85,6 @@ module HTTPX
|
|
|
88
85
|
end
|
|
89
86
|
end
|
|
90
87
|
|
|
91
|
-
type grpcSession = Session &
|
|
88
|
+
type grpcSession = Session & GRPC::InstanceMethods
|
|
92
89
|
end
|
|
93
90
|
end
|
data/sig/plugins/h2c.rbs
CHANGED
data/sig/plugins/multipart.rbs
CHANGED
|
@@ -1,43 +1,97 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
module Plugins
|
|
3
3
|
module Multipart
|
|
4
|
+
interface _MultipartInput
|
|
5
|
+
def filename: () -> String
|
|
6
|
+
def content_type: () -> String
|
|
7
|
+
def read: (?int? length, ?string? output) -> String?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
|
|
11
|
+
|
|
4
12
|
def self.load_dependencies: (singleton(Session)) -> void
|
|
5
13
|
def self.configure: (*untyped) -> void
|
|
6
14
|
def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
|
|
15
|
+
def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
|
|
16
|
+
|
|
17
|
+
def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> U } -> U
|
|
7
18
|
|
|
8
19
|
type multipart_value = string | Pathname | File | _Reader
|
|
9
20
|
|
|
10
|
-
type record_multipart_value = multipart_value |
|
|
11
|
-
{ content_type: String, filename: String, body: multipart_value } |
|
|
21
|
+
type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
|
|
12
22
|
{ content_type: String, body: multipart_value }
|
|
13
23
|
|
|
14
24
|
type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
|
|
15
25
|
|
|
16
|
-
type multipart_input = Enumerable[[string, multipart_value], untyped]
|
|
17
|
-
|
|
18
26
|
class Encoder
|
|
19
27
|
include Transcoder::_Encoder
|
|
20
|
-
|
|
28
|
+
|
|
29
|
+
@boundary: String
|
|
30
|
+
@part_index: Integer
|
|
31
|
+
@buffer: String
|
|
32
|
+
|
|
33
|
+
@form: Enumerable[[Symbol | string, multipart_nested_value]]
|
|
34
|
+
@parts: Array[_Reader]
|
|
21
35
|
|
|
22
36
|
def content_type: () -> String
|
|
23
37
|
|
|
38
|
+
def read: (?int? length, ?string? buffer) -> String?
|
|
39
|
+
|
|
40
|
+
def rewind: () -> void
|
|
41
|
+
|
|
24
42
|
private
|
|
25
43
|
|
|
26
|
-
def
|
|
44
|
+
def to_parts: (Enumerable[[Symbol | string, multipart_nested_value]] multipart_data) -> Array[_Reader]
|
|
45
|
+
|
|
46
|
+
def initialize: (Enumerable[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
|
|
27
47
|
|
|
28
48
|
def header_part: (string key, String content_type, String? filename) -> StringIO
|
|
29
49
|
|
|
30
|
-
def read_chunks: (String buffer, Integer? length) -> void
|
|
50
|
+
def read_chunks: (String buffer, ?Integer? length) -> void
|
|
51
|
+
|
|
52
|
+
def read_from_part: (?Integer? max_length) -> String?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class Decoder
|
|
56
|
+
BOUNDARY_RE: Regexp
|
|
57
|
+
|
|
58
|
+
@state: :idle | :part_header | :part_body | :parse_boundary | :done
|
|
59
|
+
@buffer: String
|
|
60
|
+
@parts: Hash[String, untyped]
|
|
61
|
+
@boundary: String
|
|
62
|
+
@intermediate_boundary: String
|
|
63
|
+
|
|
64
|
+
def call: (Response response, untyped) -> Hash[String, untyped]
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def initialize: (Response response) -> void
|
|
69
|
+
|
|
70
|
+
def parse: () -> void
|
|
31
71
|
|
|
32
|
-
def
|
|
72
|
+
def get_filename: (String head) -> String?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class FilePart # < SimpleDelegator
|
|
76
|
+
attr_reader original_filename: String
|
|
77
|
+
attr_reader content_type: String
|
|
78
|
+
|
|
79
|
+
# @file: Tempfile
|
|
80
|
+
|
|
81
|
+
# private
|
|
82
|
+
|
|
83
|
+
def initialize: (String filename, String content_type) -> void
|
|
33
84
|
end
|
|
34
85
|
|
|
35
86
|
module Part
|
|
36
|
-
def self?.call: (
|
|
87
|
+
def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
|
|
88
|
+
| (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
|
|
37
89
|
end
|
|
38
90
|
|
|
39
91
|
module MimeTypeDetector
|
|
40
|
-
|
|
92
|
+
DEFAULT_MIMETYPE: String
|
|
93
|
+
|
|
94
|
+
def self?.call: (::IO file, String filename) -> String?
|
|
41
95
|
end
|
|
42
96
|
end
|
|
43
97
|
end
|
|
@@ -4,9 +4,8 @@ module HTTPX
|
|
|
4
4
|
|
|
5
5
|
interface _NTLMOptions
|
|
6
6
|
def ntlm: () -> NTLMParams?
|
|
7
|
-
def ntlm=: (NTLMParams) -> NTLMParams
|
|
8
7
|
end
|
|
9
|
-
|
|
8
|
+
|
|
10
9
|
def self.extra_options: (Options) -> (Options & _NTLMOptions)
|
|
11
10
|
|
|
12
11
|
def self.load_dependencies: (*untyped) -> void
|
|
@@ -22,6 +21,6 @@ module HTTPX
|
|
|
22
21
|
end
|
|
23
22
|
end
|
|
24
23
|
|
|
25
|
-
type sessionNTLMAuthentication =
|
|
24
|
+
type sessionNTLMAuthentication = sessionAuthentication & NTLMAuthentication::InstanceMethods
|
|
26
25
|
end
|
|
27
26
|
end
|
data/sig/plugins/persistent.rbs
CHANGED
|
@@ -2,15 +2,10 @@ module HTTPX
|
|
|
2
2
|
module Plugins
|
|
3
3
|
module Persistent
|
|
4
4
|
def self.load_dependencies: (singleton(Session)) -> void
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def persistent: () -> bool?
|
|
8
|
-
def persistent=: (bool) -> bool
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.extra_options: (Options) -> (Options & _PersistentOptions)
|
|
5
|
+
|
|
6
|
+
def self.extra_options: (Options) -> (Options)
|
|
12
7
|
end
|
|
13
|
-
|
|
8
|
+
|
|
14
9
|
type sessionPersistent = sessionFollowRedirects
|
|
15
10
|
end
|
|
16
11
|
end
|
data/sig/plugins/proxy/ssh.rbs
CHANGED
|
@@ -3,16 +3,16 @@ module HTTPX
|
|
|
3
3
|
module Proxy
|
|
4
4
|
module SSH
|
|
5
5
|
def self.load_dependencies: (singleton(Session)) -> void
|
|
6
|
-
|
|
7
|
-
module
|
|
6
|
+
|
|
7
|
+
module InstanceMethods
|
|
8
8
|
private
|
|
9
9
|
|
|
10
|
-
def build_gateway_socket: (int, URI::
|
|
10
|
+
def build_gateway_socket: (int, URI::HTTP | URI::HTTPS, Options) -> _ToIO
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
type sessionSSHProxy =
|
|
16
|
+
type sessionSSHProxy = Proxy::InstanceMethods & Proxy::SSH::InstanceMethods
|
|
17
17
|
end
|
|
18
18
|
end
|
data/sig/plugins/proxy.rbs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module HTTPX
|
|
2
|
-
HTTPProxyError
|
|
2
|
+
class HTTPProxyError < Error
|
|
3
|
+
end
|
|
3
4
|
|
|
4
5
|
module Plugins
|
|
5
6
|
module Proxy
|
|
@@ -8,8 +9,8 @@ module HTTPX
|
|
|
8
9
|
|
|
9
10
|
class Parameters
|
|
10
11
|
attr_reader uri: URI::Generic
|
|
11
|
-
attr_reader username:
|
|
12
|
-
attr_reader password:
|
|
12
|
+
attr_reader username: String?
|
|
13
|
+
attr_reader password: String?
|
|
13
14
|
|
|
14
15
|
def authenticated?: () -> boolish
|
|
15
16
|
def token_authentication: () -> String?
|
|
@@ -18,29 +19,28 @@ module HTTPX
|
|
|
18
19
|
|
|
19
20
|
private
|
|
20
21
|
|
|
21
|
-
def initialize: (uri: generic_uri, ?username:
|
|
22
|
+
def initialize: (uri: generic_uri, ?username: String, ?password: String) -> untyped
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
def self.configure: (singleton(Session)) -> void
|
|
25
|
-
|
|
26
|
-
type proxyParam = Parameters | Hash
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
type proxyParam = Parameters | Hash[Symbol, untyped]
|
|
28
|
+
|
|
28
29
|
interface _ProxyOptions
|
|
29
30
|
def proxy: () -> proxyParam?
|
|
30
|
-
def proxy=: (Parameters | _ToHash) -> proxyParam
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def self.extra_options: (Options) -> (Options & _ProxyOptions)
|
|
34
34
|
|
|
35
35
|
module InstanceMethods
|
|
36
36
|
private
|
|
37
37
|
|
|
38
|
-
def proxy_uris: (
|
|
39
|
-
| (
|
|
40
|
-
| (
|
|
38
|
+
def proxy_uris: (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri, username: String, password: String }
|
|
39
|
+
| (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri }
|
|
40
|
+
| (generic_uri, Options & _ProxyOptions) -> nil
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
type sessionProxy = Session &
|
|
44
|
+
type sessionProxy = Session & Proxy::InstanceMethods
|
|
45
45
|
end
|
|
46
46
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module HTTPX
|
|
2
|
+
module Plugins
|
|
3
|
+
module ResponseCache
|
|
4
|
+
CACHEABLE_VERBS: Array[Symbol]
|
|
5
|
+
|
|
6
|
+
def self?.cacheable_request?: (Request request) -> bool
|
|
7
|
+
def self?.cacheable_response?: (response response) -> bool
|
|
8
|
+
def self?.cached_response?: (response response) -> bool
|
|
9
|
+
|
|
10
|
+
class Store
|
|
11
|
+
@store: Hash[URI::Generic, Response]
|
|
12
|
+
|
|
13
|
+
def lookup: (URI::Generic uri) -> Response?
|
|
14
|
+
|
|
15
|
+
def cached?: (URI::Generic uri) -> bool
|
|
16
|
+
|
|
17
|
+
def cache: (URI::Generic uri, Response response) -> void
|
|
18
|
+
|
|
19
|
+
def prepare: (Request request) -> void
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module InstanceMethods
|
|
23
|
+
@response_cache: Store
|
|
24
|
+
|
|
25
|
+
def clear_response_cache: () -> void
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
module ResponseMethods
|
|
29
|
+
def copy_from_cached: (Response other) -> void
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
type sessionResponseCache = Session & ResponseCache::InstanceMethods
|
|
34
|
+
end
|
|
35
|
+
end
|
data/sig/plugins/retries.rbs
CHANGED
|
@@ -4,25 +4,24 @@ module HTTPX
|
|
|
4
4
|
MAX_RETRIES: Integer
|
|
5
5
|
IDEMPOTENT_METHODS: Array[verb]
|
|
6
6
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
|
7
|
-
|
|
7
|
+
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
|
8
|
+
|
|
8
9
|
interface _RetryCallback
|
|
9
10
|
def call: (response) -> bool?
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
interface _RetriesOptions
|
|
13
14
|
def retry_after: () -> Numeric?
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
def retry_jitter: () -> ^(Numeric) -> Numeric
|
|
15
17
|
|
|
16
18
|
def max_retries: () -> Integer?
|
|
17
|
-
def max_retries=: (int) -> Integer
|
|
18
19
|
|
|
19
|
-
def retry_change_requests: () ->
|
|
20
|
-
def retry_change_requests=: (bool) -> bool
|
|
20
|
+
def retry_change_requests: () -> boolish
|
|
21
21
|
|
|
22
22
|
def retry_on: () -> _RetryCallback?
|
|
23
|
-
def retry_on=: (_RetryCallback) -> _RetryCallback
|
|
24
23
|
end
|
|
25
|
-
|
|
24
|
+
|
|
26
25
|
def self.extra_options: (Options) -> (Options & _RetriesOptions)
|
|
27
26
|
|
|
28
27
|
module InstanceMethods
|
|
@@ -39,6 +38,6 @@ module HTTPX
|
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
40
|
|
|
42
|
-
type sessionRetries = Session &
|
|
41
|
+
type sessionRetries = Session & Retries::InstanceMethods
|
|
43
42
|
end
|
|
44
43
|
end
|
data/sig/plugins/stream.rbs
CHANGED
data/sig/plugins/upgrade.rbs
CHANGED
|
@@ -7,9 +7,8 @@ module HTTPX
|
|
|
7
7
|
|
|
8
8
|
interface _UpgradeOptions
|
|
9
9
|
def upgrade_handlers: () -> handlers_registry?
|
|
10
|
-
def upgrade_handlers=: (handlers_registry) -> handlers_registry
|
|
11
10
|
end
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
def self.extra_options: (Options) -> (Options & _UpgradeOptions)
|
|
14
13
|
|
|
15
14
|
module ConnectionMethods
|
|
@@ -18,6 +17,6 @@ module HTTPX
|
|
|
18
17
|
|
|
19
18
|
def hijack_io: () -> void
|
|
20
19
|
end
|
|
21
|
-
end
|
|
20
|
+
end
|
|
22
21
|
end
|
|
23
22
|
end
|
data/sig/pool.rbs
CHANGED
|
@@ -4,13 +4,14 @@ module HTTPX
|
|
|
4
4
|
|
|
5
5
|
def next_tick: () -> void
|
|
6
6
|
|
|
7
|
-
def close: (Array[Connection]) -> void
|
|
8
|
-
| () -> void
|
|
7
|
+
def close: (*Array[Connection]) -> void
|
|
9
8
|
|
|
10
9
|
def init_connection: (Connection, Options) -> void
|
|
11
10
|
|
|
12
11
|
def find_connection: (generic_uri, Options) -> Connection?
|
|
13
12
|
|
|
13
|
+
def deactivate: (*Array[Connection]) -> void
|
|
14
|
+
|
|
14
15
|
private
|
|
15
16
|
|
|
16
17
|
def initialize: () -> untyped
|
|
@@ -27,6 +28,10 @@ module HTTPX
|
|
|
27
28
|
|
|
28
29
|
def unregister_connection: (Connection) -> void
|
|
29
30
|
|
|
31
|
+
def select_connection: (resolver | Connection connection) -> void
|
|
32
|
+
|
|
33
|
+
def deselect_connection: (resolver | Connection connection) -> void
|
|
34
|
+
|
|
30
35
|
def coalesce_connections: (Connection, Connection) -> void
|
|
31
36
|
|
|
32
37
|
def next_timeout: () -> Numeric?
|
data/sig/registry.rbs
CHANGED
data/sig/request.rbs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
class Request
|
|
3
|
+
extend Forwardable
|
|
3
4
|
include Callbacks
|
|
4
5
|
|
|
5
|
-
METHODS: Array[
|
|
6
|
+
METHODS: Array[Symbol]
|
|
6
7
|
USER_AGENT: String
|
|
7
8
|
|
|
8
|
-
attr_reader verb:
|
|
9
|
-
attr_reader uri: URI::
|
|
9
|
+
attr_reader verb: Symbol
|
|
10
|
+
attr_reader uri: URI::Generic
|
|
10
11
|
attr_reader headers: Headers
|
|
11
12
|
attr_reader body: Body
|
|
12
13
|
attr_reader state: Symbol
|
|
@@ -14,13 +15,13 @@ module HTTPX
|
|
|
14
15
|
attr_reader response: response?
|
|
15
16
|
attr_reader drain_error: StandardError?
|
|
16
17
|
|
|
17
|
-
def initialize: (
|
|
18
|
+
def initialize: (Symbol | String, generic_uri, ?options) -> untyped
|
|
18
19
|
|
|
19
20
|
def interests: () -> (:r | :w)
|
|
20
21
|
|
|
21
|
-
def merge_headers: (
|
|
22
|
+
def merge_headers: (_Each[[String, headers_value]]) -> void
|
|
22
23
|
|
|
23
|
-
def scheme: () ->
|
|
24
|
+
def scheme: () -> String
|
|
24
25
|
|
|
25
26
|
def response=: (response) -> void
|
|
26
27
|
|
|
@@ -49,6 +50,7 @@ module HTTPX
|
|
|
49
50
|
def each: () { (String) -> void } -> void
|
|
50
51
|
| () -> Enumerable[String]
|
|
51
52
|
|
|
53
|
+
def rewind: () -> void
|
|
52
54
|
def empty?: () -> bool
|
|
53
55
|
def bytesize: () -> Numeric
|
|
54
56
|
def stream: (Transcoder::_Encoder) -> bodyIO
|
|
@@ -59,8 +61,9 @@ module HTTPX
|
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
class ProcIO
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
def initialize: (^(String) -> void) -> untyped
|
|
65
|
+
|
|
66
|
+
def write: (String data) -> Integer
|
|
64
67
|
end
|
|
65
68
|
end
|
|
66
69
|
end
|
data/sig/resolver/native.rbs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
module Resolver
|
|
3
3
|
class Native
|
|
4
|
+
extend Forwardable
|
|
4
5
|
include ResolverMixin
|
|
5
6
|
include _ToIO
|
|
6
7
|
|
|
8
|
+
DEFAULTS: Hash[Symbol, untyped]
|
|
9
|
+
DNS_PORT: Integer
|
|
10
|
+
|
|
7
11
|
@options: Options
|
|
8
12
|
@ns_index: Integer
|
|
9
13
|
@resolver_options: Hash[Symbol, untyped]
|
|
@@ -15,7 +19,8 @@ module HTTPX
|
|
|
15
19
|
@queries: Hash[String, Connection]
|
|
16
20
|
@read_buffer: String
|
|
17
21
|
@write_buffer: Buffer
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
attr_reader state: Symbol
|
|
19
24
|
|
|
20
25
|
def closed?: () -> bool
|
|
21
26
|
|
|
@@ -35,6 +40,8 @@ module HTTPX
|
|
|
35
40
|
|
|
36
41
|
def initialize: (options) -> untyped
|
|
37
42
|
|
|
43
|
+
def calculate_interests: () -> (:r | :w)
|
|
44
|
+
|
|
38
45
|
def consume: () -> void
|
|
39
46
|
|
|
40
47
|
def do_retry: () -> void
|
|
@@ -46,15 +53,13 @@ module HTTPX
|
|
|
46
53
|
|
|
47
54
|
def parse: (String) -> void
|
|
48
55
|
|
|
49
|
-
def resolve: (Connection, String hostname) -> void
|
|
50
|
-
| (Connection) -> void
|
|
51
|
-
| () -> void
|
|
56
|
+
def resolve: (?Connection connection, ?String hostname) -> void
|
|
52
57
|
|
|
53
58
|
def build_socket: () -> void
|
|
54
59
|
|
|
55
60
|
def transition: (Symbol nextstate) -> void
|
|
56
61
|
|
|
57
|
-
def handle_error: (StandardError) -> void
|
|
62
|
+
def handle_error: (NativeResolveError | StandardError) -> void
|
|
58
63
|
end
|
|
59
64
|
end
|
|
60
65
|
end
|