httpx 0.15.3 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes/0_15_4.md +5 -0
- 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/lib/httpx/adapters/faraday.rb +3 -11
- data/lib/httpx/adapters/webmock.rb +2 -2
- data/lib/httpx/buffer.rb +1 -1
- data/lib/httpx/callbacks.rb +1 -1
- data/lib/httpx/chainable.rb +15 -8
- data/lib/httpx/connection/http1.rb +18 -10
- data/lib/httpx/connection/http2.rb +14 -21
- data/lib/httpx/connection.rb +6 -7
- data/lib/httpx/errors.rb +11 -11
- data/lib/httpx/headers.rb +1 -1
- data/lib/httpx/io/ssl.rb +2 -2
- data/lib/httpx/io/tls.rb +1 -1
- data/lib/httpx/options.rb +108 -81
- data/lib/httpx/parser/http1.rb +11 -7
- data/lib/httpx/plugins/aws_sigv4.rb +10 -9
- data/lib/httpx/plugins/compression.rb +12 -11
- data/lib/httpx/plugins/cookies/cookie.rb +4 -2
- data/lib/httpx/plugins/cookies/jar.rb +20 -1
- data/lib/httpx/plugins/cookies.rb +20 -7
- data/lib/httpx/plugins/digest_authentication.rb +19 -15
- data/lib/httpx/plugins/expect.rb +19 -15
- data/lib/httpx/plugins/follow_redirects.rb +9 -9
- data/lib/httpx/plugins/grpc/call.rb +4 -1
- data/lib/httpx/plugins/grpc.rb +73 -47
- data/lib/httpx/plugins/h2c.rb +7 -3
- 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 +14 -0
- 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/retries.rb +25 -21
- data/lib/httpx/plugins/stream.rb +2 -3
- data/lib/httpx/plugins/upgrade.rb +7 -6
- data/lib/httpx/registry.rb +2 -2
- data/lib/httpx/request.rb +10 -19
- data/lib/httpx/resolver/https.rb +0 -2
- data/lib/httpx/resolver/native.rb +15 -3
- data/lib/httpx/resolver/resolver_mixin.rb +2 -1
- data/lib/httpx/response.rb +72 -38
- data/lib/httpx/selector.rb +6 -7
- data/lib/httpx/session.rb +34 -21
- data/lib/httpx/session2.rb +23 -0
- data/lib/httpx/transcoder/body.rb +1 -1
- 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 +2 -2
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +6 -3
- data/sig/buffer.rbs +3 -1
- data/sig/chainable.rbs +30 -29
- data/sig/connection/http1.rbs +11 -5
- data/sig/connection/http2.rbs +16 -5
- data/sig/connection.rbs +23 -11
- 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 +5 -1
- 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/retries.rbs +4 -8
- data/sig/plugins/stream.rbs +1 -1
- data/sig/plugins/upgrade.rbs +2 -3
- data/sig/pool.rbs +1 -2
- data/sig/registry.rbs +1 -1
- data/sig/request.rbs +11 -8
- data/sig/resolver/native.rbs +12 -6
- data/sig/resolver/resolver_mixin.rbs +4 -5
- data/sig/resolver/system.rbs +2 -0
- data/sig/resolver.rbs +7 -0
- data/sig/response.rbs +24 -12
- data/sig/selector.rbs +11 -9
- data/sig/session.rbs +22 -23
- 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 +2 -0
- metadata +12 -2
@@ -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
|
data/sig/plugins/retries.rbs
CHANGED
@@ -4,25 +4,21 @@ module HTTPX
|
|
4
4
|
MAX_RETRIES: Integer
|
5
5
|
IDEMPOTENT_METHODS: Array[verb]
|
6
6
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
7
|
-
|
7
|
+
|
8
8
|
interface _RetryCallback
|
9
9
|
def call: (response) -> bool?
|
10
10
|
end
|
11
11
|
|
12
12
|
interface _RetriesOptions
|
13
13
|
def retry_after: () -> Numeric?
|
14
|
-
def retry_after=: (Numeric) -> Numeric
|
15
14
|
|
16
15
|
def max_retries: () -> Integer?
|
17
|
-
def max_retries=: (int) -> Integer
|
18
16
|
|
19
|
-
def retry_change_requests: () ->
|
20
|
-
def retry_change_requests=: (bool) -> bool
|
17
|
+
def retry_change_requests: () -> boolish
|
21
18
|
|
22
19
|
def retry_on: () -> _RetryCallback?
|
23
|
-
def retry_on=: (_RetryCallback) -> _RetryCallback
|
24
20
|
end
|
25
|
-
|
21
|
+
|
26
22
|
def self.extra_options: (Options) -> (Options & _RetriesOptions)
|
27
23
|
|
28
24
|
module InstanceMethods
|
@@ -39,6 +35,6 @@ module HTTPX
|
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
type sessionRetries = Session &
|
38
|
+
type sessionRetries = Session & Retries::InstanceMethods
|
43
39
|
end
|
44
40
|
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
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,15 @@
|
|
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
|
+
type state = :idle | :open | :closed
|
9
|
+
|
10
|
+
DEFAULTS: Hash[Symbol, untyped]
|
11
|
+
DNS_PORT: Integer
|
12
|
+
|
7
13
|
@options: Options
|
8
14
|
@ns_index: Integer
|
9
15
|
@resolver_options: Hash[Symbol, untyped]
|
@@ -15,7 +21,7 @@ module HTTPX
|
|
15
21
|
@queries: Hash[String, Connection]
|
16
22
|
@read_buffer: String
|
17
23
|
@write_buffer: Buffer
|
18
|
-
@state:
|
24
|
+
@state: state
|
19
25
|
|
20
26
|
def closed?: () -> bool
|
21
27
|
|
@@ -35,6 +41,8 @@ module HTTPX
|
|
35
41
|
|
36
42
|
def initialize: (options) -> untyped
|
37
43
|
|
44
|
+
def calculate_interests: () -> (:r | :w)
|
45
|
+
|
38
46
|
def consume: () -> void
|
39
47
|
|
40
48
|
def do_retry: () -> void
|
@@ -46,15 +54,13 @@ module HTTPX
|
|
46
54
|
|
47
55
|
def parse: (String) -> void
|
48
56
|
|
49
|
-
def resolve: (Connection, String hostname) -> void
|
50
|
-
| (Connection) -> void
|
51
|
-
| () -> void
|
57
|
+
def resolve: (?Connection connection, ?String hostname) -> void
|
52
58
|
|
53
59
|
def build_socket: () -> void
|
54
60
|
|
55
|
-
def transition: (
|
61
|
+
def transition: (state nextstate) -> void
|
56
62
|
|
57
|
-
def handle_error: (StandardError) -> void
|
63
|
+
def handle_error: (NativeResolveError | StandardError) -> void
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
@@ -4,6 +4,8 @@ module HTTPX
|
|
4
4
|
include Callbacks
|
5
5
|
include Loggable
|
6
6
|
|
7
|
+
CHECK_IF_IP: ^(String name) -> bool
|
8
|
+
|
7
9
|
def uncache: (Connection) -> void
|
8
10
|
|
9
11
|
private
|
@@ -16,12 +18,9 @@ module HTTPX
|
|
16
18
|
|
17
19
|
def system_resolve: (String hostname) -> Array[ipaddr]?
|
18
20
|
|
19
|
-
def emit_resolve_error: (Connection, String hostname, StandardError) -> void
|
20
|
-
| (Connection, String hostname) -> void
|
21
|
-
| (Connection) -> void
|
21
|
+
def emit_resolve_error: (Connection, ?String hostname, ?StandardError) -> void
|
22
22
|
|
23
|
-
def resolve_error: (String hostname, StandardError?) -> void
|
24
|
-
| (String hostname) -> void
|
23
|
+
def resolve_error: (String hostname, ?StandardError?) -> void
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
data/sig/resolver/system.rbs
CHANGED
data/sig/resolver.rbs
CHANGED
@@ -4,6 +4,13 @@ module HTTPX
|
|
4
4
|
type resolver = Resolver::System | Resolver::Native | Resolver::HTTPS
|
5
5
|
|
6
6
|
module Resolver
|
7
|
+
RESOLVE_TIMEOUT: Integer | Float
|
8
|
+
|
9
|
+
def self.registry: (Symbol tag) -> Class
|
10
|
+
| () -> Hash[Symbol, Class]
|
11
|
+
|
12
|
+
def self.register: (Symbol tag, Class handler) -> void
|
13
|
+
|
7
14
|
type dns_resource = singleton(Resolv::DNS::Resource)
|
8
15
|
|
9
16
|
type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
|
data/sig/response.rbs
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
module HTTPX
|
2
2
|
interface _Response
|
3
|
-
def raise_for_status: () -> void
|
3
|
+
def raise_for_status: () -> void
|
4
4
|
end
|
5
5
|
|
6
6
|
class Response
|
7
|
+
extend Forwardable
|
8
|
+
|
7
9
|
include _Response
|
8
10
|
include _ToS
|
9
11
|
include _Reader
|
10
12
|
|
11
|
-
attr_reader status:
|
12
|
-
attr_reader headers:
|
13
|
+
attr_reader status: Integer
|
14
|
+
attr_reader headers: Headers
|
13
15
|
attr_reader body: Body
|
14
16
|
attr_reader version: String
|
15
17
|
|
@@ -18,56 +20,66 @@ module HTTPX
|
|
18
20
|
|
19
21
|
def copy_to: (_ToPath | _Writer destination) -> void
|
20
22
|
def close: () -> void
|
21
|
-
def uri: () ->
|
23
|
+
def uri: () -> URI::Generic
|
22
24
|
|
23
|
-
def merge_headers: (
|
25
|
+
def merge_headers: (_Each[[String, headers_value]]) -> void
|
24
26
|
def bodyless?: () -> bool
|
25
27
|
def content_type: () -> ContentType
|
26
28
|
def complete?: () -> bool
|
27
29
|
|
30
|
+
def json: (?json_options opts) -> untyped
|
31
|
+
|
32
|
+
def form: () -> Hash[String, untyped]
|
33
|
+
|
28
34
|
private
|
29
35
|
|
30
|
-
def initialize: (Request,
|
36
|
+
def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
|
31
37
|
def no_data?: () -> bool
|
32
38
|
|
39
|
+
def decode:(String format, ?untyped options) -> untyped
|
40
|
+
|
33
41
|
class Body
|
34
|
-
include _Writer
|
35
42
|
include _Reader
|
36
43
|
include _ToS
|
37
44
|
include _ToStr
|
38
45
|
|
39
|
-
@state: :idle | :memory | :buffer
|
46
|
+
@state: :idle | :memory | :buffer | :closed
|
40
47
|
@threshold_size: Integer
|
41
48
|
@window_size: Integer
|
42
49
|
|
50
|
+
def write:(String chunk) -> Integer?
|
51
|
+
|
43
52
|
def each: () { (String) -> void } -> void
|
44
53
|
| () -> Enumerable[String]
|
45
54
|
|
46
55
|
def bytesize: () -> Numeric
|
47
56
|
def empty?: () -> bool
|
48
|
-
def copy_to: (
|
57
|
+
def copy_to: (String | File | _Writer destination) -> void
|
49
58
|
def close: () -> void
|
50
59
|
def closed?: () -> bool
|
51
60
|
|
52
61
|
private
|
53
62
|
|
54
|
-
def initialize: (Response,
|
63
|
+
def initialize: (Response, Options) -> untyped
|
55
64
|
def rewind: () -> void
|
56
65
|
def transition: () -> void
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
60
69
|
class ContentType
|
70
|
+
MIME_TYPE_RE: Regexp
|
71
|
+
CHARSET_RE: Regexp
|
72
|
+
|
61
73
|
attr_reader mime_type: String?
|
62
74
|
attr_reader charset: String?
|
63
75
|
|
64
|
-
def self.parse: (_ToS) ->
|
76
|
+
def self.parse: (_ToS) -> ContentType
|
65
77
|
def self.mime_type: (_ToS) -> String?
|
66
78
|
def self.charset: (_ToS) -> String?
|
67
79
|
|
68
80
|
private
|
69
81
|
|
70
|
-
def initialize: (String
|
82
|
+
def initialize: (String? header_value) -> void
|
71
83
|
end
|
72
84
|
|
73
85
|
class ErrorResponse
|