httpx 0.21.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +0 -48
- data/README.md +54 -45
- data/doc/release_notes/0_10_0.md +2 -2
- data/doc/release_notes/0_11_0.md +3 -5
- data/doc/release_notes/0_12_0.md +5 -5
- data/doc/release_notes/0_13_0.md +4 -4
- data/doc/release_notes/0_14_0.md +2 -2
- data/doc/release_notes/0_16_0.md +3 -3
- data/doc/release_notes/0_17_0.md +1 -1
- data/doc/release_notes/0_18_0.md +4 -4
- data/doc/release_notes/0_18_2.md +1 -1
- data/doc/release_notes/0_19_0.md +1 -1
- data/doc/release_notes/0_20_0.md +1 -1
- data/doc/release_notes/0_21_0.md +7 -5
- data/doc/release_notes/0_21_1.md +12 -0
- data/doc/release_notes/0_22_0.md +13 -0
- data/doc/release_notes/0_22_1.md +11 -0
- data/doc/release_notes/0_22_2.md +5 -0
- data/doc/release_notes/0_22_3.md +55 -0
- data/doc/release_notes/0_22_4.md +6 -0
- data/doc/release_notes/0_22_5.md +6 -0
- data/doc/release_notes/0_23_0.md +42 -0
- data/doc/release_notes/0_23_1.md +5 -0
- data/doc/release_notes/0_23_2.md +5 -0
- data/doc/release_notes/0_23_3.md +6 -0
- data/doc/release_notes/0_23_4.md +5 -0
- data/doc/release_notes/0_24_0.md +48 -0
- data/doc/release_notes/0_24_1.md +12 -0
- data/doc/release_notes/0_24_2.md +12 -0
- data/doc/release_notes/0_24_3.md +12 -0
- data/doc/release_notes/0_24_4.md +18 -0
- data/doc/release_notes/0_24_5.md +6 -0
- data/doc/release_notes/0_24_6.md +5 -0
- data/doc/release_notes/0_24_7.md +10 -0
- data/doc/release_notes/1_0_0.md +60 -0
- data/doc/release_notes/1_0_1.md +5 -0
- data/doc/release_notes/1_0_2.md +7 -0
- data/doc/release_notes/1_1_0.md +32 -0
- data/doc/release_notes/1_1_1.md +17 -0
- data/doc/release_notes/1_1_2.md +12 -0
- data/doc/release_notes/1_1_3.md +18 -0
- data/doc/release_notes/1_1_4.md +6 -0
- data/doc/release_notes/1_1_5.md +12 -0
- data/doc/release_notes/1_2_0.md +49 -0
- data/doc/release_notes/1_2_1.md +6 -0
- data/lib/httpx/adapters/datadog.rb +100 -106
- data/lib/httpx/adapters/faraday.rb +143 -107
- data/lib/httpx/adapters/sentry.rb +26 -7
- data/lib/httpx/adapters/webmock.rb +33 -17
- data/lib/httpx/altsvc.rb +61 -24
- data/lib/httpx/base64.rb +27 -0
- data/lib/httpx/buffer.rb +12 -0
- data/lib/httpx/callbacks.rb +5 -3
- data/lib/httpx/chainable.rb +54 -39
- data/lib/httpx/connection/http1.rb +62 -37
- data/lib/httpx/connection/http2.rb +16 -27
- data/lib/httpx/connection.rb +213 -120
- data/lib/httpx/domain_name.rb +10 -13
- data/lib/httpx/errors.rb +34 -2
- data/lib/httpx/extensions.rb +4 -134
- data/lib/httpx/io/ssl.rb +77 -71
- data/lib/httpx/io/tcp.rb +46 -70
- data/lib/httpx/io/udp.rb +18 -52
- data/lib/httpx/io/unix.rb +6 -13
- data/lib/httpx/io.rb +3 -9
- data/lib/httpx/loggable.rb +4 -19
- data/lib/httpx/options.rb +168 -110
- data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
- data/lib/httpx/plugins/{authentication → auth}/digest.rb +13 -14
- data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
- data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
- data/lib/httpx/plugins/auth.rb +25 -0
- data/lib/httpx/plugins/aws_sdk_authentication.rb +1 -3
- data/lib/httpx/plugins/aws_sigv4.rb +5 -6
- data/lib/httpx/plugins/basic_auth.rb +29 -0
- data/lib/httpx/plugins/brotli.rb +50 -0
- data/lib/httpx/plugins/callbacks.rb +91 -0
- data/lib/httpx/plugins/circuit_breaker/circuit.rb +40 -16
- data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +14 -5
- data/lib/httpx/plugins/circuit_breaker.rb +30 -7
- data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
- data/lib/httpx/plugins/cookies.rb +20 -10
- data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +11 -12
- data/lib/httpx/plugins/expect.rb +15 -13
- data/lib/httpx/plugins/follow_redirects.rb +71 -29
- data/lib/httpx/plugins/grpc/call.rb +2 -3
- data/lib/httpx/plugins/grpc/grpc_encoding.rb +88 -0
- data/lib/httpx/plugins/grpc/message.rb +7 -37
- data/lib/httpx/plugins/grpc.rb +35 -29
- data/lib/httpx/plugins/h2c.rb +25 -18
- data/lib/httpx/plugins/internal_telemetry.rb +16 -0
- data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +7 -5
- data/lib/httpx/plugins/oauth.rb +170 -0
- data/lib/httpx/plugins/persistent.rb +1 -1
- data/lib/httpx/plugins/proxy/http.rb +15 -10
- data/lib/httpx/plugins/proxy/socks4.rb +8 -6
- data/lib/httpx/plugins/proxy/socks5.rb +10 -8
- data/lib/httpx/plugins/proxy.rb +69 -67
- data/lib/httpx/plugins/push_promise.rb +1 -1
- data/lib/httpx/plugins/rate_limiter.rb +3 -1
- data/lib/httpx/plugins/response_cache/file_store.rb +40 -0
- data/lib/httpx/plugins/response_cache/store.rb +34 -17
- data/lib/httpx/plugins/response_cache.rb +6 -6
- data/lib/httpx/plugins/retries.rb +61 -12
- data/lib/httpx/plugins/ssrf_filter.rb +142 -0
- data/lib/httpx/plugins/stream.rb +27 -32
- data/lib/httpx/plugins/upgrade/h2.rb +4 -4
- data/lib/httpx/plugins/upgrade.rb +8 -10
- data/lib/httpx/plugins/webdav.rb +10 -8
- data/lib/httpx/pool.rb +85 -23
- data/lib/httpx/punycode.rb +9 -291
- data/lib/httpx/request/body.rb +158 -0
- data/lib/httpx/request.rb +86 -121
- data/lib/httpx/resolver/https.rb +54 -17
- data/lib/httpx/resolver/multi.rb +8 -12
- data/lib/httpx/resolver/native.rb +163 -70
- data/lib/httpx/resolver/resolver.rb +28 -13
- data/lib/httpx/resolver/system.rb +15 -10
- data/lib/httpx/resolver.rb +38 -16
- data/lib/httpx/response/body.rb +242 -0
- data/lib/httpx/response/buffer.rb +96 -0
- data/lib/httpx/response.rb +113 -211
- data/lib/httpx/selector.rb +2 -4
- data/lib/httpx/session.rb +91 -64
- data/lib/httpx/session_extensions.rb +4 -1
- data/lib/httpx/timers.rb +28 -8
- data/lib/httpx/transcoder/body.rb +0 -2
- data/lib/httpx/transcoder/chunker.rb +0 -1
- data/lib/httpx/transcoder/deflate.rb +37 -0
- data/lib/httpx/transcoder/form.rb +52 -33
- data/lib/httpx/transcoder/gzip.rb +74 -0
- data/lib/httpx/transcoder/json.rb +2 -5
- data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
- data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +3 -3
- data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
- data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
- data/lib/httpx/transcoder/multipart.rb +17 -0
- data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
- data/lib/httpx/transcoder/utils/deflater.rb +72 -0
- data/lib/httpx/transcoder/utils/inflater.rb +19 -0
- data/lib/httpx/transcoder/xml.rb +0 -5
- data/lib/httpx/transcoder.rb +4 -6
- data/lib/httpx/utils.rb +36 -16
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +12 -14
- data/sig/altsvc.rbs +33 -0
- data/sig/buffer.rbs +1 -0
- data/sig/callbacks.rbs +3 -3
- data/sig/chainable.rbs +10 -9
- data/sig/connection/http1.rbs +5 -4
- data/sig/connection/http2.rbs +1 -1
- data/sig/connection.rbs +46 -24
- data/sig/errors.rbs +9 -3
- data/sig/httpx.rbs +5 -4
- data/sig/io/ssl.rbs +26 -0
- data/sig/io/tcp.rbs +60 -0
- data/sig/io/udp.rbs +20 -0
- data/sig/io/unix.rbs +10 -0
- data/sig/options.rbs +28 -12
- data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
- data/sig/plugins/{authentication → auth}/digest.rbs +2 -1
- data/sig/plugins/auth.rbs +13 -0
- data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
- data/sig/plugins/brotli.rbs +22 -0
- data/sig/plugins/callbacks.rbs +38 -0
- data/sig/plugins/circuit_breaker.rbs +13 -3
- data/sig/plugins/compression.rbs +6 -4
- data/sig/plugins/cookies/jar.rbs +2 -2
- data/sig/plugins/cookies.rbs +2 -0
- data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
- data/sig/plugins/follow_redirects.rbs +11 -2
- data/sig/plugins/grpc/call.rbs +19 -0
- data/sig/plugins/grpc/grpc_encoding.rbs +37 -0
- data/sig/plugins/grpc/message.rbs +17 -0
- data/sig/plugins/grpc.rbs +2 -32
- data/sig/plugins/h2c.rbs +1 -1
- data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
- data/sig/plugins/oauth.rbs +54 -0
- data/sig/plugins/proxy/socks4.rbs +4 -4
- data/sig/plugins/proxy/socks5.rbs +2 -2
- data/sig/plugins/proxy/ssh.rbs +1 -1
- data/sig/plugins/proxy.rbs +10 -4
- data/sig/plugins/response_cache.rbs +12 -3
- data/sig/plugins/retries.rbs +28 -8
- data/sig/plugins/stream.rbs +24 -17
- data/sig/plugins/upgrade.rbs +5 -3
- data/sig/pool.rbs +5 -4
- data/sig/request/body.rbs +40 -0
- data/sig/request.rbs +12 -28
- data/sig/resolver/https.rbs +7 -2
- data/sig/resolver/native.rbs +10 -4
- data/sig/resolver/resolver.rbs +6 -4
- data/sig/resolver/system.rbs +2 -0
- data/sig/resolver.rbs +9 -5
- data/sig/response/body.rbs +53 -0
- data/sig/response/buffer.rbs +24 -0
- data/sig/response.rbs +17 -38
- data/sig/session.rbs +24 -18
- data/sig/timers.rbs +17 -7
- data/sig/transcoder/body.rbs +4 -3
- data/sig/transcoder/deflate.rbs +11 -0
- data/sig/transcoder/form.rbs +5 -3
- data/sig/transcoder/gzip.rbs +24 -0
- data/sig/transcoder/json.rbs +4 -2
- data/sig/{plugins → transcoder}/multipart.rbs +3 -12
- data/sig/transcoder/utils/body_reader.rbs +15 -0
- data/sig/transcoder/utils/deflater.rbs +29 -0
- data/sig/transcoder/utils/inflater.rbs +12 -0
- data/sig/transcoder/xml.rbs +1 -1
- data/sig/transcoder.rbs +22 -7
- data/sig/utils.rbs +2 -0
- metadata +127 -40
- data/lib/httpx/plugins/authentication.rb +0 -20
- data/lib/httpx/plugins/basic_authentication.rb +0 -30
- data/lib/httpx/plugins/compression/brotli.rb +0 -54
- data/lib/httpx/plugins/compression/deflate.rb +0 -49
- data/lib/httpx/plugins/compression/gzip.rb +0 -88
- data/lib/httpx/plugins/compression.rb +0 -164
- data/lib/httpx/plugins/multipart/decoder.rb +0 -187
- data/lib/httpx/plugins/multipart.rb +0 -84
- data/lib/httpx/registry.rb +0 -85
- data/sig/plugins/authentication.rbs +0 -11
- data/sig/plugins/compression/brotli.rbs +0 -21
- data/sig/plugins/compression/deflate.rbs +0 -17
- data/sig/plugins/compression/gzip.rbs +0 -29
- data/sig/registry.rbs +0 -13
- /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
- /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
module GRPC
|
4
|
+
class Call
|
5
|
+
attr_writer decoder: _Callable
|
6
|
+
|
7
|
+
def metadata: () -> headers
|
8
|
+
|
9
|
+
def trailing_metadata: () -> headers?
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def initialize: (Response | StreamResponse response) -> untyped
|
14
|
+
|
15
|
+
def grpc_response: () -> grpc_response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Transcoder
|
3
|
+
module GRPCEncoding
|
4
|
+
|
5
|
+
def self?.encode: (body_encoder body, compressed: bool) -> Deflater
|
6
|
+
|
7
|
+
def self?.decode: (Response | StreamResponse response) -> Inflater
|
8
|
+
|
9
|
+
class Deflater
|
10
|
+
attr_reader content_type: String
|
11
|
+
|
12
|
+
@body: BodyReader
|
13
|
+
@compressed: bool
|
14
|
+
|
15
|
+
def initialize: (body_encoder body, compressed: bool) -> void
|
16
|
+
|
17
|
+
def bytesize: () -> (Integer | Float)
|
18
|
+
|
19
|
+
def read: (?int? length, ?string outbuf) -> String?
|
20
|
+
end
|
21
|
+
|
22
|
+
class Inflater
|
23
|
+
@response: Response
|
24
|
+
@grpc_encodings: Array[String]
|
25
|
+
|
26
|
+
def initialize: (Response | StreamResponse response) -> void
|
27
|
+
|
28
|
+
def call: (String message) ?{ (String) -> void } -> String
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def grpc_encodings: () -> Array[String]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module HTTPX
|
3
|
+
module Plugins
|
4
|
+
module GRPC
|
5
|
+
module Message
|
6
|
+
def self?.unary: (response) -> grpc_message
|
7
|
+
|
8
|
+
def self?.stream: (StreamResponse) { (String) -> void } -> void
|
9
|
+
| (StreamResponse) -> Enumerable[String]
|
10
|
+
|
11
|
+
def self?.cancel: (Request) -> void
|
12
|
+
|
13
|
+
def self?.verify_status: (StreamResponse | response) -> void
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/sig/plugins/grpc.rbs
CHANGED
@@ -17,36 +17,6 @@ module HTTPX
|
|
17
17
|
|
18
18
|
type credentials = Proc
|
19
19
|
|
20
|
-
class Call
|
21
|
-
attr_writer decoder: _Callable
|
22
|
-
|
23
|
-
def metadata: () -> headers
|
24
|
-
|
25
|
-
def trailing_metadata: () -> headers?
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def initialize: (Response | StreamResponse response) -> untyped
|
30
|
-
|
31
|
-
def grpc_response: () -> grpc_response
|
32
|
-
end
|
33
|
-
|
34
|
-
module Message
|
35
|
-
def self?.unary: (response) -> grpc_message
|
36
|
-
|
37
|
-
def self?.stream: (StreamResponse) { (String) -> void } -> void
|
38
|
-
| (StreamResponse) -> Enumerable[String]
|
39
|
-
|
40
|
-
def self?.encode: (String bytes, ?deflater: Compression::_Deflater?) -> String
|
41
|
-
|
42
|
-
def self?.decode: (String message, encodings: Array[String], encoders: Compression::encodings_registry) -> String
|
43
|
-
| (String message, encodings: Array[String], encoders: Compression::encodings_registry) { (String) -> void } -> void
|
44
|
-
|
45
|
-
def self?.cancel: (Request) -> void
|
46
|
-
|
47
|
-
def self?.verify_status: (StreamResponse | response) -> void
|
48
|
-
end
|
49
|
-
|
50
20
|
interface _GRPCOptions
|
51
21
|
def grpc_service: () -> String?
|
52
22
|
|
@@ -63,9 +33,9 @@ module HTTPX
|
|
63
33
|
def self.load_dependencies: (singleton(Session)) -> void
|
64
34
|
|
65
35
|
module ResponseMethods
|
66
|
-
|
36
|
+
attr_reader trailing_metadata: Hash[String, untyped]
|
67
37
|
|
68
|
-
def encoders: () ->
|
38
|
+
def encoders: () -> Array[String | Encoding]
|
69
39
|
end
|
70
40
|
|
71
41
|
module InstanceMethods
|
data/sig/plugins/h2c.rbs
CHANGED
@@ -11,11 +11,11 @@ module HTTPX
|
|
11
11
|
def self.load_dependencies: (*untyped) -> void
|
12
12
|
|
13
13
|
module InstanceMethods
|
14
|
-
def
|
14
|
+
def ntlm_auth: (string user, string password, ?string? domain) -> instance
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
type sessionNTLMAuth =
|
19
|
+
type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
#
|
4
|
+
# https://gitlab.com/os85/httpx/wikis/OAuth
|
5
|
+
#
|
6
|
+
module OAuth
|
7
|
+
def self.load_dependencies: (singleton(Session) klass) -> void
|
8
|
+
|
9
|
+
type grant_type = "client_credentials" | "refresh_token"
|
10
|
+
|
11
|
+
type token_auth_method = "client_secret_basic" | "client_secret_post"
|
12
|
+
|
13
|
+
SUPPORTED_GRANT_TYPES: ::Array[grant_type]
|
14
|
+
|
15
|
+
SUPPORTED_AUTH_METHODS: ::Array[token_auth_method]
|
16
|
+
|
17
|
+
class OAuthSession
|
18
|
+
attr_reader token_endpoint_auth_method: token_auth_method
|
19
|
+
|
20
|
+
attr_reader grant_type: grant_type
|
21
|
+
|
22
|
+
attr_reader client_id: String
|
23
|
+
|
24
|
+
attr_reader client_secret: String
|
25
|
+
|
26
|
+
attr_reader access_token: String?
|
27
|
+
|
28
|
+
attr_reader refresh_token: String?
|
29
|
+
|
30
|
+
attr_reader scope: Array[String]?
|
31
|
+
|
32
|
+
def initialize: (issuer: uri, client_id: String, client_secret: String, ?access_token: String?, ?refresh_token: String?, ?scope: (Array[String] | String)?, ?token_endpoint: String?, ?response_type: String?, ?grant_type: String?, ?token_endpoint_auth_method: ::String) -> void
|
33
|
+
|
34
|
+
def token_endpoint: () -> String
|
35
|
+
|
36
|
+
def load: (Session http) -> void
|
37
|
+
|
38
|
+
def merge: (instance | Hash[untyped, untyped] other) -> instance
|
39
|
+
end
|
40
|
+
|
41
|
+
interface _AwsSdkOptions
|
42
|
+
def oauth_session: () -> OAuthSession?
|
43
|
+
end
|
44
|
+
|
45
|
+
module InstanceMethods
|
46
|
+
def oauth_auth: (**untyped args) -> instance
|
47
|
+
|
48
|
+
def with_access_token: () -> instance
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
type sessionOAuth = Session & OAuth::InstanceMethods
|
53
|
+
end
|
54
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module HTTPX
|
2
|
-
Socks4Error
|
2
|
+
class Socks4Error < HTTPProxyError
|
3
|
+
end
|
3
4
|
|
4
5
|
module Plugins
|
5
6
|
module Proxy
|
6
7
|
module Socks4
|
7
|
-
|
8
|
+
|
8
9
|
module ConnectionMethods
|
9
10
|
def __socks4_proxy_connect: () -> void
|
10
11
|
def __socks4_on_packet: (String packet) -> void
|
11
12
|
def on_socks4_error: (string) -> void
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
class SocksParser
|
15
16
|
include Callbacks
|
16
17
|
|
17
|
-
def timeout: () -> Integer
|
18
18
|
def close: () -> void
|
19
19
|
def consume: (*untyped) -> void
|
20
20
|
def empty: () -> bool
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module HTTPX
|
2
|
-
Socks5Error
|
2
|
+
class Socks5Error < HTTPProxyError
|
3
|
+
end
|
3
4
|
|
4
5
|
module Plugins
|
5
6
|
module Proxy
|
@@ -16,7 +17,6 @@ module HTTPX
|
|
16
17
|
class SocksParser
|
17
18
|
include Callbacks
|
18
19
|
|
19
|
-
def timeout: () -> Integer
|
20
20
|
def close: () -> void
|
21
21
|
def consume: (*untyped) -> void
|
22
22
|
def empty: () -> bool
|
data/sig/plugins/proxy/ssh.rbs
CHANGED
data/sig/plugins/proxy.rbs
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module HTTPX
|
2
|
-
class HTTPProxyError <
|
2
|
+
class HTTPProxyError < ConnectionError
|
3
|
+
end
|
4
|
+
|
5
|
+
class ProxySSL < SSL
|
3
6
|
end
|
4
7
|
|
5
8
|
module Plugins
|
@@ -35,11 +38,14 @@ module HTTPX
|
|
35
38
|
def self.extra_options: (Options) -> (Options & _ProxyOptions)
|
36
39
|
|
37
40
|
module InstanceMethods
|
41
|
+
@__proxy_uris: Array[generic_uri]
|
42
|
+
|
38
43
|
private
|
39
44
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
45
|
+
def proxy_error?: (Request request, response) -> bool
|
46
|
+
end
|
47
|
+
|
48
|
+
module ConnectionMethods
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Plugins
|
3
3
|
module ResponseCache
|
4
|
-
CACHEABLE_VERBS: Array[
|
4
|
+
CACHEABLE_VERBS: Array[verb]
|
5
|
+
CACHEABLE_STATUS_CODES: Array[Integer]
|
5
6
|
|
6
|
-
def self?.cacheable_request?: (Request request) -> bool
|
7
|
-
def self?.cacheable_response?: (
|
7
|
+
def self?.cacheable_request?: (Request & RequestMethods request) -> bool
|
8
|
+
def self?.cacheable_response?: (::HTTPX::ErrorResponse | (Response & ResponseMethods) response) -> bool
|
8
9
|
def self?.cached_response?: (response response) -> bool
|
9
10
|
|
10
11
|
class Store
|
11
12
|
@store: Hash[String, Array[Response]]
|
12
13
|
|
14
|
+
@store_mutex: Thread::Mutex
|
15
|
+
|
13
16
|
def lookup: (Request request) -> Response?
|
14
17
|
|
15
18
|
def cached?: (Request request) -> boolish
|
@@ -21,6 +24,10 @@ module HTTPX
|
|
21
24
|
private
|
22
25
|
|
23
26
|
def match_by_vary?: (Request request, Response response) -> bool
|
27
|
+
|
28
|
+
def _get: (Request request) -> Array[Response]?
|
29
|
+
|
30
|
+
def _set: (Request request, Response response) -> void
|
24
31
|
end
|
25
32
|
|
26
33
|
module InstanceMethods
|
@@ -30,6 +37,8 @@ module HTTPX
|
|
30
37
|
end
|
31
38
|
|
32
39
|
module RequestMethods
|
40
|
+
@response_cache_key: String
|
41
|
+
|
33
42
|
def response_cache_key: () -> String
|
34
43
|
end
|
35
44
|
|
data/sig/plugins/retries.rbs
CHANGED
@@ -2,40 +2,60 @@ module HTTPX
|
|
2
2
|
module Plugins
|
3
3
|
module Retries
|
4
4
|
MAX_RETRIES: Integer
|
5
|
-
IDEMPOTENT_METHODS: Array[
|
5
|
+
IDEMPOTENT_METHODS: Array[String]
|
6
6
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
7
7
|
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
8
8
|
|
9
9
|
interface _RetryCallback
|
10
|
-
def call: (response) -> bool?
|
10
|
+
def call: (response response) -> bool?
|
11
11
|
end
|
12
12
|
|
13
13
|
interface _RetriesOptions
|
14
14
|
def retry_after: () -> Numeric?
|
15
15
|
|
16
|
-
def retry_jitter: () -> ^(Numeric) -> Numeric
|
16
|
+
def retry_jitter: () -> ^(Numeric jitter) -> Numeric
|
17
17
|
|
18
|
-
def max_retries: () -> Integer
|
18
|
+
def max_retries: () -> Integer
|
19
19
|
|
20
20
|
def retry_change_requests: () -> boolish
|
21
21
|
|
22
22
|
def retry_on: () -> _RetryCallback?
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.extra_options: (Options) ->
|
25
|
+
def self.extra_options: (Options options) -> retriesOptions
|
26
26
|
|
27
27
|
module InstanceMethods
|
28
28
|
def max_retries: (int) -> instance
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def __repeatable_request?: (
|
33
|
-
|
32
|
+
def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
|
33
|
+
|
34
|
+
def __retryable_error?: (_Exception error) -> bool
|
35
|
+
|
36
|
+
def __try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
|
37
|
+
|
34
38
|
end
|
35
39
|
|
36
40
|
module RequestMethods
|
37
|
-
|
41
|
+
@options: Options & _RetriesOptions
|
42
|
+
|
43
|
+
attr_accessor retries: Integer
|
44
|
+
|
45
|
+
attr_writer partial_response: Response?
|
46
|
+
|
47
|
+
def response=: (retriesResponse | ErrorResponse response) -> void
|
38
48
|
end
|
49
|
+
|
50
|
+
module ResponseMethods
|
51
|
+
def from_partial_response: (Response response) -> void
|
52
|
+
end
|
53
|
+
|
54
|
+
type retriesOptions = Options & _RetriesOptions
|
55
|
+
|
56
|
+
type retriesRequest = Request & RequestMethods
|
57
|
+
|
58
|
+
type retriesResponse = Response & ResponseMethods
|
39
59
|
end
|
40
60
|
|
41
61
|
type sessionRetries = Session & Retries::InstanceMethods
|
data/sig/plugins/stream.rbs
CHANGED
@@ -1,21 +1,4 @@
|
|
1
1
|
module HTTPX
|
2
|
-
class StreamResponse
|
3
|
-
include _ToS
|
4
|
-
|
5
|
-
def each: () { (String) -> void } -> void
|
6
|
-
| () -> Enumerable[String]
|
7
|
-
|
8
|
-
def each_line: () { (String) -> void } -> void
|
9
|
-
| () -> Enumerable[String]
|
10
|
-
|
11
|
-
def on_chunk: (string) -> void
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def response: () -> response
|
16
|
-
def initialize: (Request, Session, Array[Connection]) -> untyped
|
17
|
-
end
|
18
|
-
|
19
2
|
module Plugins
|
20
3
|
module Stream
|
21
4
|
module InstanceMethods
|
@@ -37,4 +20,28 @@ module HTTPX
|
|
37
20
|
|
38
21
|
type sessionStream = Session & Stream::InstanceMethods
|
39
22
|
end
|
23
|
+
|
24
|
+
class StreamResponse
|
25
|
+
include _ToS
|
26
|
+
|
27
|
+
type streamRequest = Request & Plugins::Stream::RequestMethods
|
28
|
+
|
29
|
+
@request: streamRequest
|
30
|
+
@session: Plugins::sessionStream
|
31
|
+
@on_chunk: ^(String) -> void | nil
|
32
|
+
|
33
|
+
def each: () { (String) -> void } -> void
|
34
|
+
| () -> Enumerable[String]
|
35
|
+
|
36
|
+
def each_line: () { (String) -> void } -> void
|
37
|
+
| () -> Enumerable[String]
|
38
|
+
|
39
|
+
def on_chunk: (string) -> void
|
40
|
+
|
41
|
+
def initialize: (streamRequest, Plugins::sessionStream) -> void
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def response: () -> response
|
46
|
+
end
|
40
47
|
end
|
data/sig/plugins/upgrade.rbs
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Plugins
|
3
3
|
module Upgrade
|
4
|
-
|
4
|
+
interface _Upgrader
|
5
|
+
def call: (Connection connection, Request request, Response response) -> void
|
6
|
+
end
|
5
7
|
|
6
8
|
def self.configure: (singleton(Session)) -> void
|
7
9
|
|
8
10
|
interface _UpgradeOptions
|
9
|
-
def upgrade_handlers: () ->
|
11
|
+
def upgrade_handlers: () -> Hash[String, _Upgrader]
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.extra_options: (Options) -> (Options & _UpgradeOptions)
|
13
15
|
|
14
16
|
module ConnectionMethods
|
15
|
-
attr_reader upgrade_protocol:
|
17
|
+
attr_reader upgrade_protocol: String?
|
16
18
|
attr_reader hijacked: boolish
|
17
19
|
|
18
20
|
def hijack_io: () -> void
|
data/sig/pool.rbs
CHANGED
@@ -6,7 +6,6 @@ module HTTPX
|
|
6
6
|
@timers: Timers
|
7
7
|
@selector: Selector
|
8
8
|
@connections: Array[Connection]
|
9
|
-
@connected_connections: Integer
|
10
9
|
|
11
10
|
def empty?: () -> void
|
12
11
|
|
@@ -22,7 +21,9 @@ module HTTPX
|
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
def initialize: () ->
|
24
|
+
def initialize: () -> void
|
25
|
+
|
26
|
+
def try_clone_connection: (Connection connection, Integer? family) -> Connection
|
26
27
|
|
27
28
|
def resolve_connection: (Connection) -> void
|
28
29
|
|
@@ -34,7 +35,7 @@ module HTTPX
|
|
34
35
|
|
35
36
|
def register_connection: (Connection) -> void
|
36
37
|
|
37
|
-
def unregister_connection: (Connection) -> void
|
38
|
+
def unregister_connection: (Connection, ?bool cleanup) -> void
|
38
39
|
|
39
40
|
def select_connection: (Selector::selectable) -> void
|
40
41
|
|
@@ -42,7 +43,7 @@ module HTTPX
|
|
42
43
|
|
43
44
|
def coalesce_connections: (Connection coalescable, Connection coalescing) -> void
|
44
45
|
|
45
|
-
def next_timeout: () ->
|
46
|
+
def next_timeout: () -> Numeric?
|
46
47
|
|
47
48
|
def find_resolver_for: (Connection) { (Resolver::Resolver resolver) -> void } -> resolver_manager
|
48
49
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class Request::Body
|
3
|
+
@headers: Headers
|
4
|
+
@body: body_encoder?
|
5
|
+
@unbounded_body: bool
|
6
|
+
|
7
|
+
def initialize: (Headers headers, Options options) -> void
|
8
|
+
|
9
|
+
def each: () { (String) -> void } -> void
|
10
|
+
| () -> Enumerable[String]
|
11
|
+
|
12
|
+
def rewind: () -> void
|
13
|
+
|
14
|
+
def empty?: () -> bool
|
15
|
+
|
16
|
+
def bytesize: () -> (Integer | Float)
|
17
|
+
|
18
|
+
def stream: (Transcoder::_Encoder) -> bodyIO
|
19
|
+
|
20
|
+
def unbounded_body?: () -> bool
|
21
|
+
|
22
|
+
def chunked?: () -> bool
|
23
|
+
|
24
|
+
def chunk!: () -> void
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def initialize_body: (Options options) -> void
|
29
|
+
|
30
|
+
def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
|
31
|
+
end
|
32
|
+
|
33
|
+
class ProcIO
|
34
|
+
@block: ^(String) -> void
|
35
|
+
|
36
|
+
def initialize: (^(String) -> void) -> untyped
|
37
|
+
|
38
|
+
def write: (String data) -> Integer
|
39
|
+
end
|
40
|
+
end
|
data/sig/request.rbs
CHANGED
@@ -6,8 +6,8 @@ module HTTPX
|
|
6
6
|
METHODS: Array[Symbol]
|
7
7
|
USER_AGENT: String
|
8
8
|
|
9
|
-
attr_reader verb:
|
10
|
-
attr_reader uri:
|
9
|
+
attr_reader verb: verb
|
10
|
+
attr_reader uri: http_uri
|
11
11
|
attr_reader headers: Headers
|
12
12
|
attr_reader body: Body
|
13
13
|
attr_reader state: Symbol
|
@@ -15,6 +15,10 @@ module HTTPX
|
|
15
15
|
attr_reader response: response?
|
16
16
|
attr_reader drain_error: StandardError?
|
17
17
|
|
18
|
+
attr_accessor peer_address: ipaddr?
|
19
|
+
|
20
|
+
attr_writer persistent: bool
|
21
|
+
|
18
22
|
@trailers: Headers?
|
19
23
|
@informational_status: Integer?
|
20
24
|
@query: String?
|
@@ -50,37 +54,17 @@ module HTTPX
|
|
50
54
|
|
51
55
|
def trailers?: () -> boolish
|
52
56
|
|
53
|
-
def
|
54
|
-
|
55
|
-
def write_timeout: () -> Numeric
|
56
|
-
|
57
|
-
def request_timeout: () -> Numeric
|
57
|
+
def persistent?: () -> bool
|
58
58
|
|
59
|
-
|
60
|
-
@headers: Headers
|
61
|
-
@body: body_encoder?
|
62
|
-
@unbounded_body: bool
|
59
|
+
def read_timeout: () -> Numeric?
|
63
60
|
|
64
|
-
|
65
|
-
def each: () { (String) -> void } -> void
|
66
|
-
| () -> Enumerable[String]
|
61
|
+
def write_timeout: () -> Numeric?
|
67
62
|
|
68
|
-
|
69
|
-
def empty?: () -> bool
|
70
|
-
def bytesize: () -> (Integer | Float)
|
71
|
-
def stream: (Transcoder::_Encoder) -> bodyIO
|
72
|
-
def unbounded_body?: () -> bool
|
73
|
-
def chunked?: () -> bool
|
74
|
-
def chunk!: () -> void
|
75
|
-
def inspect: () -> String
|
76
|
-
end
|
63
|
+
def request_timeout: () -> Numeric?
|
77
64
|
|
78
|
-
|
79
|
-
@block: ^(String) -> void
|
65
|
+
private
|
80
66
|
|
81
|
-
|
67
|
+
def initialize_body: (Options options) -> Transcoder::_Encoder?
|
82
68
|
|
83
|
-
def write: (String data) -> Integer
|
84
|
-
end
|
85
69
|
end
|
86
70
|
end
|
data/sig/resolver/https.rbs
CHANGED
@@ -6,7 +6,8 @@ module HTTPX
|
|
6
6
|
DEFAULTS: Hash[Symbol, untyped]
|
7
7
|
FAMILY_TYPES: Hash[singleton(Resolv::DNS::Resource), String]
|
8
8
|
|
9
|
-
|
9
|
+
attr_reader family: ip_family
|
10
|
+
|
10
11
|
@options: Options
|
11
12
|
@requests: Hash[Request, String]
|
12
13
|
@connections: Array[Connection]
|
@@ -31,9 +32,13 @@ module HTTPX
|
|
31
32
|
|
32
33
|
def parse: (Request request, Response response) -> void
|
33
34
|
|
35
|
+
def parse_addresses: (Array[dns_result] answers, Request request) -> void
|
36
|
+
|
34
37
|
def build_request: (String hostname) -> Request
|
35
38
|
|
36
|
-
def decode_response_body: (Response) ->
|
39
|
+
def decode_response_body: (Response) -> dns_decoding_response
|
40
|
+
|
41
|
+
def reset_hostname: (String hostname, ?reset_candidates: bool) -> Connection?
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
data/sig/resolver/native.rbs
CHANGED
@@ -7,10 +7,12 @@ module HTTPX
|
|
7
7
|
DEFAULTS: Hash[Symbol, untyped]
|
8
8
|
DNS_PORT: Integer
|
9
9
|
|
10
|
-
|
10
|
+
attr_reader family: ip_family
|
11
|
+
|
11
12
|
@options: Options
|
12
13
|
@ns_index: Integer
|
13
|
-
@nameserver: Array[String]
|
14
|
+
@nameserver: Array[String]
|
15
|
+
@socket_type: :udp | :tcp
|
14
16
|
@ndots: Integer
|
15
17
|
@start_timeout: Float?
|
16
18
|
@search: Array[String]
|
@@ -19,6 +21,8 @@ module HTTPX
|
|
19
21
|
@connections: Array[Connection]
|
20
22
|
@read_buffer: String
|
21
23
|
@write_buffer: Buffer
|
24
|
+
@large_packet: Buffer?
|
25
|
+
@io: UDP | TCP
|
22
26
|
|
23
27
|
attr_reader state: Symbol
|
24
28
|
|
@@ -30,7 +34,7 @@ module HTTPX
|
|
30
34
|
|
31
35
|
def timeout: () -> Numeric?
|
32
36
|
|
33
|
-
def
|
37
|
+
def handle_socket_timeout: (Numeric interval) -> void
|
34
38
|
|
35
39
|
private
|
36
40
|
|
@@ -53,11 +57,13 @@ module HTTPX
|
|
53
57
|
|
54
58
|
def generate_candidates: (String) -> Array[String]
|
55
59
|
|
56
|
-
def build_socket: () ->
|
60
|
+
def build_socket: () -> (UDP | TCP)
|
57
61
|
|
58
62
|
def transition: (Symbol nextstate) -> void
|
59
63
|
|
60
64
|
def handle_error: (NativeResolveError | StandardError) -> void
|
65
|
+
|
66
|
+
def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
|
61
67
|
end
|
62
68
|
end
|
63
69
|
end
|