httpx 0.20.0 → 1.3.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 +5 -5
- 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_19_8.md +1 -1
- data/doc/release_notes/0_20_0.md +2 -2
- data/doc/release_notes/0_20_1.md +5 -0
- data/doc/release_notes/0_20_2.md +7 -0
- data/doc/release_notes/0_20_3.md +6 -0
- data/doc/release_notes/0_20_4.md +17 -0
- data/doc/release_notes/0_20_5.md +3 -0
- data/doc/release_notes/0_21_0.md +96 -0
- 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/doc/release_notes/1_2_2.md +10 -0
- data/doc/release_notes/1_2_3.md +16 -0
- data/doc/release_notes/1_2_4.md +8 -0
- data/doc/release_notes/1_2_5.md +7 -0
- data/doc/release_notes/1_2_6.md +13 -0
- data/doc/release_notes/1_3_0.md +18 -0
- data/doc/release_notes/1_3_1.md +17 -0
- data/lib/httpx/adapters/datadog.rb +215 -122
- data/lib/httpx/adapters/faraday.rb +145 -107
- data/lib/httpx/adapters/sentry.rb +26 -7
- data/lib/httpx/adapters/webmock.rb +34 -18
- data/lib/httpx/altsvc.rb +63 -26
- 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 +75 -44
- data/lib/httpx/connection/http2.rb +31 -38
- data/lib/httpx/connection.rb +287 -117
- data/lib/httpx/domain_name.rb +10 -13
- data/lib/httpx/errors.rb +52 -2
- data/lib/httpx/extensions.rb +24 -131
- data/lib/httpx/io/ssl.rb +83 -77
- data/lib/httpx/io/tcp.rb +48 -71
- data/lib/httpx/io/udp.rb +18 -52
- data/lib/httpx/io/unix.rb +10 -15
- data/lib/httpx/io.rb +3 -9
- data/lib/httpx/loggable.rb +4 -19
- data/lib/httpx/options.rb +176 -118
- data/lib/httpx/parser/http1.rb +4 -0
- data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
- data/lib/httpx/plugins/{authentication → auth}/digest.rb +14 -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 +4 -3
- data/lib/httpx/plugins/aws_sigv4.rb +12 -9
- 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 +100 -0
- data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +53 -0
- data/lib/httpx/plugins/circuit_breaker.rb +148 -0
- data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
- data/lib/httpx/plugins/cookies.rb +30 -17
- data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +14 -12
- data/lib/httpx/plugins/expect.rb +21 -14
- data/lib/httpx/plugins/follow_redirects.rb +140 -41
- 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 +36 -29
- data/lib/httpx/plugins/h2c.rb +26 -19
- 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 +175 -0
- data/lib/httpx/plugins/persistent.rb +1 -1
- data/lib/httpx/plugins/proxy/http.rb +23 -13
- data/lib/httpx/plugins/proxy/socks4.rb +9 -7
- data/lib/httpx/plugins/proxy/socks5.rb +11 -9
- data/lib/httpx/plugins/proxy.rb +80 -61
- data/lib/httpx/plugins/push_promise.rb +1 -1
- data/lib/httpx/plugins/rate_limiter.rb +5 -1
- data/lib/httpx/plugins/response_cache/file_store.rb +40 -0
- data/lib/httpx/plugins/response_cache/store.rb +62 -25
- data/lib/httpx/plugins/response_cache.rb +105 -12
- data/lib/httpx/plugins/retries.rb +87 -17
- data/lib/httpx/plugins/ssrf_filter.rb +145 -0
- data/lib/httpx/plugins/stream.rb +27 -23
- data/lib/httpx/plugins/upgrade/h2.rb +4 -4
- data/lib/httpx/plugins/upgrade.rb +8 -10
- data/lib/httpx/plugins/webdav.rb +80 -0
- data/lib/httpx/pool/synch_pool.rb +93 -0
- data/lib/httpx/pool.rb +102 -27
- data/lib/httpx/punycode.rb +9 -291
- data/lib/httpx/request/body.rb +154 -0
- data/lib/httpx/request.rb +130 -146
- data/lib/httpx/resolver/https.rb +62 -27
- data/lib/httpx/resolver/multi.rb +9 -13
- data/lib/httpx/resolver/native.rb +192 -76
- data/lib/httpx/resolver/resolver.rb +34 -9
- data/lib/httpx/resolver/system.rb +16 -11
- 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 +159 -217
- data/lib/httpx/selector.rb +9 -4
- data/lib/httpx/session.rb +137 -89
- data/lib/httpx/session_extensions.rb +4 -1
- data/lib/httpx/timers.rb +34 -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 +21 -8
- data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
- data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +4 -4
- 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 +52 -0
- data/lib/httpx/transcoder.rb +5 -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 +2 -1
- data/sig/callbacks.rbs +3 -3
- data/sig/chainable.rbs +11 -9
- data/sig/connection/http1.rbs +8 -7
- data/sig/connection/http2.rbs +19 -19
- data/sig/connection.rbs +64 -24
- data/sig/errors.rbs +22 -3
- data/sig/httpx.rbs +5 -4
- data/sig/io/ssl.rbs +27 -0
- data/sig/io/tcp.rbs +60 -0
- data/sig/io/udp.rbs +20 -0
- data/sig/io/unix.rbs +27 -0
- data/sig/io.rbs +6 -0
- data/sig/options.rbs +32 -22
- data/sig/parser/http1.rbs +1 -1
- 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 +71 -0
- data/sig/plugins/compression.rbs +7 -5
- 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 +18 -4
- 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 +7 -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/http.rbs +3 -0
- data/sig/plugins/proxy/socks4.rbs +9 -6
- data/sig/plugins/proxy/socks5.rbs +10 -6
- data/sig/plugins/proxy/ssh.rbs +1 -1
- data/sig/plugins/proxy.rbs +13 -5
- data/sig/plugins/push_promise.rbs +3 -3
- data/sig/plugins/rate_limiter.rbs +1 -1
- data/sig/plugins/response_cache.rbs +36 -7
- data/sig/plugins/retries.rbs +30 -8
- data/sig/plugins/stream.rbs +24 -17
- data/sig/plugins/upgrade.rbs +5 -3
- data/sig/pool.rbs +10 -7
- data/sig/request/body.rbs +38 -0
- data/sig/request.rbs +15 -24
- data/sig/resolver/https.rbs +8 -3
- data/sig/resolver/native.rbs +17 -4
- data/sig/resolver/resolver.rbs +8 -6
- 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 +24 -39
- data/sig/selector.rbs +1 -1
- data/sig/session.rbs +29 -18
- data/sig/timers.rbs +18 -8
- 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 +8 -3
- data/sig/{plugins → transcoder}/multipart.rbs +15 -19
- 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 +22 -0
- data/sig/transcoder.rbs +24 -9
- data/sig/utils.rbs +8 -2
- metadata +163 -41
- 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 -12
- /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
- /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
data/lib/httpx.rb
CHANGED
@@ -11,7 +11,6 @@ require "httpx/domain_name"
|
|
11
11
|
require "httpx/altsvc"
|
12
12
|
require "httpx/callbacks"
|
13
13
|
require "httpx/loggable"
|
14
|
-
require "httpx/registry"
|
15
14
|
require "httpx/transcoder"
|
16
15
|
require "httpx/timers"
|
17
16
|
require "httpx/pool"
|
@@ -21,7 +20,6 @@ require "httpx/response"
|
|
21
20
|
require "httpx/options"
|
22
21
|
require "httpx/chainable"
|
23
22
|
|
24
|
-
require "mutex_m"
|
25
23
|
# Top-Level Namespace
|
26
24
|
#
|
27
25
|
module HTTPX
|
@@ -32,16 +30,17 @@ module HTTPX
|
|
32
30
|
#
|
33
31
|
module Plugins
|
34
32
|
@plugins = {}
|
35
|
-
@
|
33
|
+
@plugins_mutex = Thread::Mutex.new
|
36
34
|
|
37
35
|
# Loads a plugin based on a name. If the plugin hasn't been loaded, tries to load
|
38
36
|
# it from the load path under "httpx/plugins/" directory.
|
39
37
|
#
|
40
38
|
def self.load_plugin(name)
|
41
39
|
h = @plugins
|
42
|
-
|
40
|
+
m = @plugins_mutex
|
41
|
+
unless (plugin = m.synchronize { h[name] })
|
43
42
|
require "httpx/plugins/#{name}"
|
44
|
-
raise "Plugin #{name} hasn't been registered" unless (plugin =
|
43
|
+
raise "Plugin #{name} hasn't been registered" unless (plugin = m.synchronize { h[name] })
|
45
44
|
end
|
46
45
|
plugin
|
47
46
|
end
|
@@ -50,20 +49,19 @@ module HTTPX
|
|
50
49
|
#
|
51
50
|
def self.register_plugin(name, mod)
|
52
51
|
h = @plugins
|
53
|
-
|
52
|
+
m = @plugins_mutex
|
53
|
+
m.synchronize { h[name] = mod }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
# :nocov:
|
58
|
-
def self.const_missing(const_name)
|
59
|
-
super unless const_name == :Client
|
60
|
-
warn "DEPRECATION WARNING: the class #{self}::Client is deprecated. Use #{self}::Session instead."
|
61
|
-
Session
|
62
|
-
end
|
63
|
-
# :nocov:
|
64
|
-
|
65
57
|
extend Chainable
|
66
58
|
end
|
67
59
|
|
68
60
|
require "httpx/session"
|
69
61
|
require "httpx/session_extensions"
|
62
|
+
|
63
|
+
# load integrations when possible
|
64
|
+
|
65
|
+
require "httpx/adapters/datadog" if defined?(DDTrace) || defined?(Datadog)
|
66
|
+
require "httpx/adapters/sentry" if defined?(Sentry)
|
67
|
+
require "httpx/adapters/webmock" if defined?(WebMock)
|
data/sig/altsvc.rbs
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module AltSvc
|
3
|
+
module ConnectionMixin
|
4
|
+
|
5
|
+
def send: (Request request) -> void
|
6
|
+
|
7
|
+
def match?: (URI::Generic uri, Options options) -> bool
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def match_altsvcs?: (URI::Generic uri) -> bool
|
12
|
+
|
13
|
+
def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
|
14
|
+
end
|
15
|
+
|
16
|
+
type altsvc_params = Hash[String, untyped]
|
17
|
+
|
18
|
+
def self?.cached_altsvc: (String origin) -> Array[altsvc_params]
|
19
|
+
|
20
|
+
def self?.cached_altsvc_set: (String origin, altsvc_params) -> void
|
21
|
+
|
22
|
+
def self?.lookup: (String origin, Integer | Float ttl) -> Array[altsvc_params]
|
23
|
+
|
24
|
+
def self?.emit: (Request request, response response) { (http_uri alt_origin, String origin, altsvc_params alt_params) -> void } -> void
|
25
|
+
|
26
|
+
def self?.parse: (String altsvc) { (http_uri alt_origin, altsvc_params alt_params) -> void } -> void
|
27
|
+
| (String altsvc) -> Enumerable[[http_uri, altsvc_params]]
|
28
|
+
|
29
|
+
def self?.parse_altsvc_scheme: (String alt_proto) -> String?
|
30
|
+
|
31
|
+
def self.parse_altsvc_origin: (string alt_proto, String alt_origin) -> http_uri?
|
32
|
+
end
|
33
|
+
end
|
data/sig/buffer.rbs
CHANGED
@@ -11,11 +11,12 @@ module HTTPX
|
|
11
11
|
|
12
12
|
def full?: () -> bool
|
13
13
|
def shift!: (Integer) -> void
|
14
|
+
def capacity: () -> Integer
|
14
15
|
|
15
16
|
# delegated
|
16
17
|
def <<: (string data) -> String
|
17
18
|
def empty?: () -> bool
|
18
|
-
def bytesize: () -> Integer
|
19
|
+
def bytesize: () -> (Integer | Float)
|
19
20
|
def clear: () -> void
|
20
21
|
def replace: (string) -> void
|
21
22
|
|
data/sig/callbacks.rbs
CHANGED
@@ -4,9 +4,9 @@ module HTTPX
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module Callbacks
|
7
|
-
def on: (Symbol) { (*untyped) -> void } ->
|
8
|
-
def once: (Symbol) { (*untyped) -> void } ->
|
9
|
-
def only: (Symbol) { (*untyped) -> void } ->
|
7
|
+
def on: (Symbol) { (*untyped) -> void } -> self
|
8
|
+
def once: (Symbol) { (*untyped) -> void } -> self
|
9
|
+
def only: (Symbol) { (*untyped) -> void } -> self
|
10
10
|
def emit: (Symbol, *untyped) -> void
|
11
11
|
|
12
12
|
def callbacks_for?: (Symbol) -> bool
|
data/sig/chainable.rbs
CHANGED
@@ -2,9 +2,9 @@ module HTTPX
|
|
2
2
|
module Chainable
|
3
3
|
def request: (*Request, **untyped) -> Array[response]
|
4
4
|
| (Request, **untyped) -> response
|
5
|
-
| (verb
|
6
|
-
| (Array[[verb
|
7
|
-
| (verb
|
5
|
+
| (verb, uri | [uri], **untyped) -> response
|
6
|
+
| (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
|
7
|
+
| (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
|
8
8
|
|
9
9
|
def accept: (String) -> Session
|
10
10
|
def wrap: () { (Session) -> void } -> void
|
@@ -12,18 +12,17 @@ module HTTPX
|
|
12
12
|
def with: (options) -> Session
|
13
13
|
| (options) { (Session) -> void } -> void
|
14
14
|
|
15
|
-
def plugin: (:
|
16
|
-
| (:
|
17
|
-
| (:
|
18
|
-
| (:
|
15
|
+
def plugin: (:auth, ?options) -> Plugins::sessionAuthorization
|
16
|
+
| (:basic_auth, ?options) -> Plugins::sessionBasicAuth
|
17
|
+
| (:digest_auth, ?options) -> Plugins::sessionDigestAuth
|
18
|
+
| (:ntlm_auth, ?options) -> Plugins::sessionNTLMAuth
|
19
19
|
| (:aws_sdk_authentication, ?options) -> Plugins::sessionAwsSdkAuthentication
|
20
|
-
| (:
|
20
|
+
| (:brotli, ?options) -> Session
|
21
21
|
| (:cookies, ?options) -> Plugins::sessionCookies
|
22
22
|
| (:expect, ?options) -> Session
|
23
23
|
| (:follow_redirects, ?options) -> Plugins::sessionFollowRedirects
|
24
24
|
| (:upgrade, ?options) -> Session
|
25
25
|
| (:h2c, ?options) -> Session
|
26
|
-
| (:multipart, ?options) -> Session
|
27
26
|
| (:persistent, ?options) -> Plugins::sessionPersistent
|
28
27
|
| (:proxy, ?options) -> (Plugins::sessionProxy & Plugins::httpProxy)
|
29
28
|
| (:push_promise, ?options) -> Plugins::sessionPushPromise
|
@@ -33,6 +32,9 @@ module HTTPX
|
|
33
32
|
| (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
|
34
33
|
| (:grpc, ?options) -> Plugins::grpcSession
|
35
34
|
| (:response_cache, ?options) -> Plugins::sessionResponseCache
|
35
|
+
| (:circuit_breaker, ?options) -> Plugins::sessionCircuitBreaker
|
36
|
+
| (:oauth, ?options) -> Plugins::sessionOAuth
|
37
|
+
| (:callbacks, ?options) -> Plugins::sessionCallbacks
|
36
38
|
| (Symbol | Module, ?options) { (Class) -> void } -> Session
|
37
39
|
| (Symbol | Module, ?options) -> Session
|
38
40
|
|
data/sig/connection/http1.rbs
CHANGED
@@ -10,8 +10,9 @@ module HTTPX
|
|
10
10
|
attr_reader pending: Array[Request]
|
11
11
|
attr_reader requests: Array[Request]
|
12
12
|
|
13
|
+
attr_accessor max_concurrent_requests: Integer
|
14
|
+
|
13
15
|
@options: Options
|
14
|
-
@max_concurrent_requests: Integer
|
15
16
|
@max_requests: Integer
|
16
17
|
@parser: Parser::HTTP1
|
17
18
|
@buffer: Buffer
|
@@ -31,13 +32,13 @@ module HTTPX
|
|
31
32
|
|
32
33
|
def exhausted?: () -> bool
|
33
34
|
|
34
|
-
def <<: (
|
35
|
+
def <<: (string) -> void
|
35
36
|
|
36
37
|
def send: (Request) -> void
|
37
38
|
|
38
39
|
def consume: () -> void
|
39
40
|
|
40
|
-
def handle_error: (StandardError ex) -> void
|
41
|
+
def handle_error: (StandardError ex, ?Request? request) -> void
|
41
42
|
|
42
43
|
def on_start: () -> void
|
43
44
|
|
@@ -53,19 +54,19 @@ module HTTPX
|
|
53
54
|
|
54
55
|
def ping: () -> void
|
55
56
|
|
56
|
-
def timeout: () -> Numeric
|
57
|
+
def timeout: () -> Numeric?
|
57
58
|
|
58
59
|
private
|
59
60
|
|
60
|
-
def initialize: (Buffer, options) -> untyped
|
61
|
+
def initialize: (Buffer buffer, Options options) -> untyped
|
61
62
|
|
62
|
-
def manage_connection: (Response) -> void
|
63
|
+
def manage_connection: (Request request, Response response) -> void
|
63
64
|
|
64
65
|
def disable: () -> void
|
65
66
|
|
66
67
|
def disable_pipelining: () -> void
|
67
68
|
|
68
|
-
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
69
|
+
def set_protocol_headers: (Request request) -> _Each[[String, String]]
|
69
70
|
|
70
71
|
def handle: (Request request) -> void
|
71
72
|
|
data/sig/connection/http2.rbs
CHANGED
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
|
6
6
|
MAX_CONCURRENT_REQUESTS: Integer
|
7
7
|
|
8
|
-
attr_reader streams: Hash[Request,
|
8
|
+
attr_reader streams: Hash[Request, ::HTTP2::Stream]
|
9
9
|
attr_reader pending: Array[Request]
|
10
10
|
|
11
11
|
@options: Options
|
@@ -24,7 +24,7 @@ module HTTPX
|
|
24
24
|
|
25
25
|
def exhausted?: () -> bool
|
26
26
|
|
27
|
-
def <<: (
|
27
|
+
def <<: (string) -> void
|
28
28
|
|
29
29
|
def can_buffer_more_requests?: () -> bool
|
30
30
|
|
@@ -32,45 +32,45 @@ module HTTPX
|
|
32
32
|
|
33
33
|
def consume: () -> void
|
34
34
|
|
35
|
-
def handle_error: (StandardError ex) -> void
|
35
|
+
def handle_error: (StandardError ex, ?Request? request) -> void
|
36
36
|
|
37
37
|
def ping: () -> void
|
38
38
|
|
39
39
|
alias reset init_connection
|
40
40
|
|
41
|
-
def timeout: () -> Numeric
|
41
|
+
def timeout: () -> Numeric?
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
def initialize: (Buffer, options) -> untyped
|
45
|
+
def initialize: (Buffer buffer, Options options) -> untyped
|
46
46
|
|
47
47
|
def send_pending: () -> void
|
48
48
|
|
49
49
|
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
50
50
|
|
51
|
-
def handle: (Request request,
|
51
|
+
def handle: (Request request, ::HTTP2::Stream stream) -> void
|
52
52
|
|
53
53
|
def init_connection: () -> void
|
54
54
|
|
55
|
-
def handle_stream: (
|
55
|
+
def handle_stream: (::HTTP2::Stream stream, Request request) -> void
|
56
56
|
|
57
57
|
def join_headline: (Request request) -> String
|
58
58
|
|
59
|
-
def join_headers: (
|
59
|
+
def join_headers: (::HTTP2::Stream stream, Request request) -> void
|
60
60
|
|
61
|
-
def join_trailers: (
|
61
|
+
def join_trailers: (::HTTP2::Stream stream, Request request) -> void
|
62
62
|
|
63
|
-
def join_body: (
|
63
|
+
def join_body: (::HTTP2::Stream stream, Request request) -> void
|
64
64
|
|
65
|
-
def on_stream_headers: (
|
65
|
+
def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
|
66
66
|
|
67
|
-
def on_stream_trailers: (
|
67
|
+
def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
|
68
68
|
|
69
|
-
def on_stream_data: (
|
69
|
+
def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
|
70
70
|
|
71
|
-
def on_stream_refuse: (
|
71
|
+
def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
|
72
72
|
|
73
|
-
def on_stream_close: (
|
73
|
+
def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
|
74
74
|
|
75
75
|
def on_frame: (string bytes) -> void
|
76
76
|
|
@@ -78,13 +78,13 @@ module HTTPX
|
|
78
78
|
|
79
79
|
def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
|
80
80
|
|
81
|
-
def on_frame_sent: (
|
81
|
+
def on_frame_sent: (::HTTP2::frame) -> void
|
82
82
|
|
83
|
-
def on_frame_received: (
|
83
|
+
def on_frame_received: (::HTTP2::frame) -> void
|
84
84
|
|
85
|
-
def on_altsvc: (String origin,
|
85
|
+
def on_altsvc: (String origin, ::HTTP2::frame) -> void
|
86
86
|
|
87
|
-
def on_promise: (
|
87
|
+
def on_promise: (::HTTP2::Stream) -> void
|
88
88
|
|
89
89
|
def on_origin: (String) -> void
|
90
90
|
|
data/sig/connection.rbs
CHANGED
@@ -17,42 +17,51 @@ module HTTPX
|
|
17
17
|
extend Forwardable
|
18
18
|
include Loggable
|
19
19
|
include Callbacks
|
20
|
-
include HTTPX::Registry[String, Class]
|
21
20
|
|
22
|
-
BUFFER_SIZE: Integer
|
23
21
|
|
24
|
-
attr_reader
|
22
|
+
attr_reader type: io_type
|
23
|
+
attr_reader origin: http_uri
|
25
24
|
attr_reader origins: Array[String]
|
26
25
|
attr_reader state: Symbol
|
27
26
|
attr_reader pending: Array[Request]
|
28
27
|
attr_reader options: Options
|
28
|
+
attr_reader ssl_session: OpenSSL::SSL::Session?
|
29
29
|
attr_writer timers: Timers
|
30
30
|
|
31
|
-
|
31
|
+
attr_accessor family: Integer?
|
32
|
+
|
32
33
|
@window_size: Integer
|
33
34
|
@read_buffer: Buffer
|
34
35
|
@write_buffer: Buffer
|
35
36
|
@inflight: Integer
|
36
37
|
@keep_alive_timeout: Numeric?
|
37
|
-
@
|
38
|
+
@timeout: Numeric?
|
39
|
+
@current_timeout: Numeric?
|
40
|
+
@io: TCP | SSL | UNIX
|
41
|
+
@parser: Object & _Parser
|
42
|
+
@connected_at: Float
|
43
|
+
@response_received_at: Float
|
44
|
+
@intervals: Array[Timers::Interval]
|
38
45
|
|
39
46
|
def addresses: () -> Array[ipaddr]?
|
40
47
|
|
41
|
-
def addresses=: (Array[ipaddr]) -> void
|
48
|
+
def addresses=: (Array[ipaddr] addresses) -> void
|
42
49
|
|
43
|
-
def
|
50
|
+
def send: (Request request) -> void
|
44
51
|
|
45
|
-
def
|
52
|
+
def match?: (URI::Generic uri, Options options) -> bool
|
46
53
|
|
47
|
-
def
|
54
|
+
def expired?: () -> boolish
|
48
55
|
|
49
|
-
def
|
56
|
+
def mergeable?: (Connection connection) -> bool
|
57
|
+
|
58
|
+
def coalescable?: (Connection connection) -> bool
|
50
59
|
|
51
|
-
def
|
60
|
+
def create_idle: (?Hash[Symbol, untyped] options) -> Connection
|
52
61
|
|
53
|
-
def
|
62
|
+
def merge: (Connection connection) -> void
|
54
63
|
|
55
|
-
def
|
64
|
+
def purge_pending: () { (Request request) -> void } -> void
|
56
65
|
|
57
66
|
def connecting?: () -> bool
|
58
67
|
|
@@ -60,21 +69,33 @@ module HTTPX
|
|
60
69
|
|
61
70
|
def interests: () -> io_interests?
|
62
71
|
|
63
|
-
def to_io: () -> IO
|
72
|
+
def to_io: () -> ::IO
|
64
73
|
|
65
74
|
def call: () -> void
|
66
75
|
|
76
|
+
def terminate: () -> void
|
77
|
+
|
67
78
|
def close: () -> void
|
68
|
-
def reset: () -> void
|
69
79
|
|
70
|
-
def
|
80
|
+
def reset: () -> void
|
71
81
|
|
72
82
|
def timeout: () -> Numeric?
|
73
83
|
|
84
|
+
def idling: () -> void
|
85
|
+
|
86
|
+
def used?: () -> boolish
|
87
|
+
|
74
88
|
def deactivate: () -> void
|
89
|
+
|
90
|
+
def open?: () -> bool
|
91
|
+
|
92
|
+
def handle_socket_timeout: (Numeric interval) -> void
|
93
|
+
|
75
94
|
private
|
76
95
|
|
77
|
-
def initialize: (
|
96
|
+
def initialize: (http_uri uri, Options options) -> void
|
97
|
+
|
98
|
+
def initialize_type: (http_uri uri, Options options) -> io_type
|
78
99
|
|
79
100
|
def connect: () -> void
|
80
101
|
|
@@ -84,21 +105,40 @@ module HTTPX
|
|
84
105
|
|
85
106
|
def send_pending: () -> void
|
86
107
|
|
87
|
-
def parser: () -> _Parser
|
108
|
+
def parser: () -> (Object & _Parser)
|
88
109
|
|
89
110
|
def send_request_to_parser: (Request request) -> void
|
90
111
|
|
91
|
-
def build_parser: () -> _Parser
|
92
|
-
|
112
|
+
def build_parser: (?String protocol) -> (Object & _Parser)
|
113
|
+
|
114
|
+
def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
|
115
|
+
|
116
|
+
def transition: (Symbol nextstate) -> void
|
93
117
|
|
94
|
-
def
|
118
|
+
def handle_transition: (Symbol nextstate) -> void
|
95
119
|
|
96
|
-
def
|
120
|
+
def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
|
97
121
|
|
98
|
-
def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
|
122
|
+
def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
|
99
123
|
|
100
|
-
def handle_error: (StandardError) -> void
|
124
|
+
def handle_error: (StandardError error, ?Request? request) -> void
|
101
125
|
|
102
126
|
def purge_after_closed: () -> void
|
127
|
+
|
128
|
+
def set_request_timeouts: (Request request) -> void
|
129
|
+
|
130
|
+
def set_request_read_timeout: (Request request) -> void
|
131
|
+
|
132
|
+
def set_request_write_timeout: (Request request) -> void
|
133
|
+
|
134
|
+
def set_request_request_timeout: (Request request) -> void
|
135
|
+
|
136
|
+
def write_timeout_callback: (Request request, Numeric write_timeout) -> void
|
137
|
+
|
138
|
+
def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
|
139
|
+
|
140
|
+
def set_request_timeout: (Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
|
141
|
+
|
142
|
+
def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
|
103
143
|
end
|
104
144
|
end
|
data/sig/errors.rbs
CHANGED
@@ -2,6 +2,12 @@ module HTTPX
|
|
2
2
|
class Error < StandardError
|
3
3
|
end
|
4
4
|
|
5
|
+
class UnsupportedSchemeError < Error
|
6
|
+
end
|
7
|
+
|
8
|
+
class ConnectionError < Error
|
9
|
+
end
|
10
|
+
|
5
11
|
class TimeoutError < Error
|
6
12
|
attr_reader timeout: Numeric
|
7
13
|
|
@@ -11,9 +17,6 @@ module HTTPX
|
|
11
17
|
def initialize: (Numeric timeout, String message) -> untyped
|
12
18
|
end
|
13
19
|
|
14
|
-
class TotalTimeoutError < TimeoutError
|
15
|
-
end
|
16
|
-
|
17
20
|
class ConnectTimeoutError < TimeoutError
|
18
21
|
end
|
19
22
|
|
@@ -23,6 +26,19 @@ module HTTPX
|
|
23
26
|
class ResolveTimeoutError < TimeoutError
|
24
27
|
end
|
25
28
|
|
29
|
+
class RequestTimeoutError < TimeoutError
|
30
|
+
attr_reader request: Request
|
31
|
+
attr_reader response: response?
|
32
|
+
|
33
|
+
def initialize: (Request request, response? response, Numeric timeout) -> void
|
34
|
+
end
|
35
|
+
|
36
|
+
class ReadTimeoutError < RequestTimeoutError
|
37
|
+
end
|
38
|
+
|
39
|
+
class WriteTimeoutError < RequestTimeoutError
|
40
|
+
end
|
41
|
+
|
26
42
|
class ResolveError < Error
|
27
43
|
end
|
28
44
|
|
@@ -42,4 +58,7 @@ module HTTPX
|
|
42
58
|
|
43
59
|
def initialize: (Connection connection, String hostname, ?String message) -> untyped
|
44
60
|
end
|
61
|
+
|
62
|
+
class MisdirectedRequestError < HTTPError
|
63
|
+
end
|
45
64
|
end
|
data/sig/httpx.rbs
CHANGED
@@ -5,12 +5,13 @@ module HTTPX
|
|
5
5
|
|
6
6
|
VERSION: String
|
7
7
|
|
8
|
-
type
|
8
|
+
type http_uri = URI::HTTP | URI::HTTPS
|
9
|
+
type uri = http_uri | string
|
9
10
|
type generic_uri = String | URI::Generic
|
10
11
|
|
11
|
-
type verb =
|
12
|
-
|
13
|
-
|
12
|
+
type verb = String
|
13
|
+
|
14
|
+
type request_params = Hash[Symbol, untyped]
|
14
15
|
|
15
16
|
type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
|
16
17
|
|
data/sig/io/ssl.rbs
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module HTTPX
|
2
|
+
|
3
|
+
class TLSError < OpenSSL::SSL::SSLError
|
4
|
+
end
|
5
|
+
|
6
|
+
class SSL < TCP
|
7
|
+
TLS_OPTIONS: Hash[Symbol, untyped]
|
8
|
+
|
9
|
+
@ctx: OpenSSL::SSL::SSLContext
|
10
|
+
@verify_hostname: bool
|
11
|
+
|
12
|
+
attr_writer ssl_session: OpenSSL::SSL::Session?
|
13
|
+
|
14
|
+
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
15
|
+
# def initialize: (URI::Generic origin, Array[ipaddr]? addresses, options options) ?{ (self) -> void } -> void
|
16
|
+
|
17
|
+
def session_new_cb: { (OpenSSL::SSL::Session sess) -> void } -> void
|
18
|
+
def can_verify_peer?: () -> bool
|
19
|
+
|
20
|
+
def verify_hostname: (String host) -> bool
|
21
|
+
|
22
|
+
def ssl_session_expired?: () -> boolish
|
23
|
+
|
24
|
+
# :nocov:
|
25
|
+
def try_ssl_connect: () -> void
|
26
|
+
end
|
27
|
+
end
|
data/sig/io/tcp.rbs
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class TCP
|
3
|
+
include Loggable
|
4
|
+
|
5
|
+
attr_reader ip: ipaddr?
|
6
|
+
|
7
|
+
attr_reader port: Integer
|
8
|
+
|
9
|
+
attr_reader addresses: Array[ipaddr]
|
10
|
+
|
11
|
+
attr_reader state: Symbol
|
12
|
+
|
13
|
+
attr_reader interests: io_interests
|
14
|
+
|
15
|
+
alias host ip
|
16
|
+
|
17
|
+
# TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
|
18
|
+
def initialize: (URI::Generic origin, Array[ipaddr]? addresses, Options options) ?{ (instance) -> void } -> void
|
19
|
+
|
20
|
+
def add_addresses: (Array[ipaddr] addrs) -> void
|
21
|
+
|
22
|
+
def to_io: () -> ::IO
|
23
|
+
|
24
|
+
def protocol: () -> String
|
25
|
+
|
26
|
+
def connect: () -> void
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# :nocov:
|
31
|
+
def try_connect: () -> void
|
32
|
+
|
33
|
+
public
|
34
|
+
|
35
|
+
def read: (Integer size, ?(Buffer | String) buffer) -> (0 | nil | untyped)
|
36
|
+
|
37
|
+
def write: (Buffer buffer) -> Integer?
|
38
|
+
|
39
|
+
def close: () -> void
|
40
|
+
|
41
|
+
def connected?: () -> bool
|
42
|
+
|
43
|
+
def expired?: () -> boolish
|
44
|
+
|
45
|
+
def closed?: () -> bool
|
46
|
+
|
47
|
+
# :nocov:
|
48
|
+
def inspect: () -> ::String
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def build_socket: () -> Socket
|
53
|
+
|
54
|
+
def transition: (Symbol nextstate) -> void
|
55
|
+
|
56
|
+
def do_transition: (Symbol nextstate) -> void
|
57
|
+
|
58
|
+
def log_transition_state: (Symbol nextstate) -> void
|
59
|
+
end
|
60
|
+
end
|
data/sig/io/udp.rbs
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class UDP
|
3
|
+
include Loggable
|
4
|
+
|
5
|
+
def initialize: (String ip, Integer port, Options options) -> void
|
6
|
+
|
7
|
+
def to_io: () -> ::IO
|
8
|
+
|
9
|
+
def connect: () -> void
|
10
|
+
|
11
|
+
def connected?: () -> bool
|
12
|
+
|
13
|
+
# :nocov:
|
14
|
+
def close: () -> void
|
15
|
+
|
16
|
+
def read: (Integer size, ?(Buffer | String) buffer) -> Integer?
|
17
|
+
|
18
|
+
def write: (Buffer buffer) -> Integer?
|
19
|
+
end
|
20
|
+
end
|
data/sig/io/unix.rbs
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class UNIX < TCP
|
3
|
+
|
4
|
+
attr_reader path: String
|
5
|
+
|
6
|
+
alias host path
|
7
|
+
|
8
|
+
@hostname: String
|
9
|
+
|
10
|
+
@options: Options
|
11
|
+
|
12
|
+
@fallback_protocol: String
|
13
|
+
|
14
|
+
@keep_open: bool
|
15
|
+
|
16
|
+
@io: Socket
|
17
|
+
|
18
|
+
def initialize: (http_uri origin, String? path, Options options) -> void
|
19
|
+
|
20
|
+
def connect: () -> void
|
21
|
+
|
22
|
+
def expired?: () -> bool
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_socket: () -> Socket
|
26
|
+
end
|
27
|
+
end
|