httpx 0.21.0 → 1.2.1
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/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
data/sig/connection/http2.rbs
CHANGED
data/sig/connection.rbs
CHANGED
|
@@ -17,10 +17,9 @@ 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
|
|
|
22
|
+
attr_reader type: io_type
|
|
24
23
|
attr_reader origin: URI::Generic
|
|
25
24
|
attr_reader origins: Array[String]
|
|
26
25
|
attr_reader state: Symbol
|
|
@@ -28,33 +27,40 @@ module HTTPX
|
|
|
28
27
|
attr_reader options: Options
|
|
29
28
|
attr_writer timers: Timers
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
attr_accessor family: Integer?
|
|
31
|
+
|
|
32
32
|
@window_size: Integer
|
|
33
33
|
@read_buffer: Buffer
|
|
34
34
|
@write_buffer: Buffer
|
|
35
35
|
@inflight: Integer
|
|
36
36
|
@keep_alive_timeout: Numeric?
|
|
37
|
-
@
|
|
37
|
+
@timeout: Numeric?
|
|
38
|
+
@current_timeout: Numeric?
|
|
39
|
+
@io: TCP | SSL | UNIX
|
|
40
|
+
@parser: HTTP1 | HTTP2 | _Parser
|
|
41
|
+
@connected_at: Float
|
|
42
|
+
@response_received_at: Float
|
|
43
|
+
@intervals: Array[Timers::Interval]
|
|
38
44
|
|
|
39
45
|
def addresses: () -> Array[ipaddr]?
|
|
40
46
|
|
|
41
|
-
def addresses=: (Array[ipaddr]) -> void
|
|
47
|
+
def addresses=: (Array[ipaddr] addresses) -> void
|
|
42
48
|
|
|
43
|
-
def
|
|
49
|
+
def send: (Request request) -> void
|
|
44
50
|
|
|
45
|
-
def
|
|
51
|
+
def match?: (URI::Generic uri, Options options) -> bool
|
|
46
52
|
|
|
47
|
-
def
|
|
53
|
+
def expired?: () -> boolish
|
|
48
54
|
|
|
49
|
-
def
|
|
55
|
+
def mergeable?: (Connection connection) -> bool
|
|
50
56
|
|
|
51
|
-
def
|
|
57
|
+
def coalescable?: (Connection connection) -> bool
|
|
52
58
|
|
|
53
|
-
def
|
|
59
|
+
def create_idle: (?Hash[Symbol, untyped] options) -> Connection
|
|
54
60
|
|
|
55
|
-
def
|
|
61
|
+
def merge: (Connection connection) -> void
|
|
56
62
|
|
|
57
|
-
def
|
|
63
|
+
def purge_pending: () { (Request request) -> void } -> void
|
|
58
64
|
|
|
59
65
|
def connecting?: () -> bool
|
|
60
66
|
|
|
@@ -66,20 +72,29 @@ module HTTPX
|
|
|
66
72
|
|
|
67
73
|
def call: () -> void
|
|
68
74
|
|
|
75
|
+
def terminate: () -> void
|
|
76
|
+
|
|
69
77
|
def close: () -> void
|
|
70
|
-
def reset: () -> void
|
|
71
78
|
|
|
72
|
-
def
|
|
79
|
+
def reset: () -> void
|
|
73
80
|
|
|
74
81
|
def timeout: () -> Numeric?
|
|
75
82
|
|
|
83
|
+
def idling: () -> void
|
|
84
|
+
|
|
85
|
+
def used?: () -> boolish
|
|
86
|
+
|
|
76
87
|
def deactivate: () -> void
|
|
77
88
|
|
|
78
|
-
def
|
|
89
|
+
def open?: () -> bool
|
|
90
|
+
|
|
91
|
+
def handle_socket_timeout: (Numeric interval) -> void
|
|
79
92
|
|
|
80
93
|
private
|
|
81
94
|
|
|
82
|
-
def initialize: (
|
|
95
|
+
def initialize: (URI::Generic uri, options) -> void
|
|
96
|
+
|
|
97
|
+
def initialize_type: (URI::Generic uri, options) -> io_type
|
|
83
98
|
|
|
84
99
|
def connect: () -> void
|
|
85
100
|
|
|
@@ -89,20 +104,23 @@ module HTTPX
|
|
|
89
104
|
|
|
90
105
|
def send_pending: () -> void
|
|
91
106
|
|
|
92
|
-
def parser: () -> _Parser
|
|
107
|
+
def parser: () -> (HTTP1 | HTTP2 | _Parser)
|
|
93
108
|
|
|
94
109
|
def send_request_to_parser: (Request request) -> void
|
|
95
110
|
|
|
96
|
-
def build_parser: () ->
|
|
97
|
-
| (String) -> _Parser
|
|
111
|
+
def build_parser: (?String protocol) -> (HTTP1 | HTTP2)
|
|
98
112
|
|
|
99
|
-
def set_parser_callbacks: (
|
|
113
|
+
def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
|
|
100
114
|
|
|
101
|
-
def transition: (Symbol) -> void
|
|
115
|
+
def transition: (Symbol nextstate) -> void
|
|
102
116
|
|
|
103
|
-
def
|
|
117
|
+
def handle_transition: (Symbol nextstate) -> void
|
|
104
118
|
|
|
105
|
-
def
|
|
119
|
+
def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
|
|
120
|
+
|
|
121
|
+
def on_error: (HTTPX::TimeoutError | Error | StandardError error) -> void
|
|
122
|
+
|
|
123
|
+
def handle_error: (StandardError error) -> void
|
|
106
124
|
|
|
107
125
|
def purge_after_closed: () -> void
|
|
108
126
|
|
|
@@ -111,5 +129,9 @@ module HTTPX
|
|
|
111
129
|
def write_timeout_callback: (Request request, Numeric write_timeout) -> void
|
|
112
130
|
|
|
113
131
|
def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
|
|
132
|
+
|
|
133
|
+
def set_request_timeout: (Request request, Numeric timeout, Symbol start_event, Symbol | Array[Symbol] finish_events) { () -> void } -> void
|
|
134
|
+
|
|
135
|
+
def self.parser_type: (String protocol) -> (singleton(HTTP1) | singleton(HTTP2))
|
|
114
136
|
end
|
|
115
137
|
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
|
|
|
@@ -55,4 +58,7 @@ module HTTPX
|
|
|
55
58
|
|
|
56
59
|
def initialize: (Connection connection, String hostname, ?String message) -> untyped
|
|
57
60
|
end
|
|
61
|
+
|
|
62
|
+
class MisdirectedRequestError < HTTPError
|
|
63
|
+
end
|
|
58
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 = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" |
|
|
13
|
+
"PROPFIND" | "PROPPATCH" | "MKCOL" | "COPY" | "MOVE" | "LOCK" | "UNLOCK" | "ORDERPATCH" |
|
|
14
|
+
"ACL" | "REPORT" | "PATCH" | "SEARCH"
|
|
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,26 @@
|
|
|
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 can_verify_peer?: () -> bool
|
|
18
|
+
|
|
19
|
+
def verify_hostname: (String host) -> bool
|
|
20
|
+
|
|
21
|
+
def ssl_session_expired?: () -> boolish
|
|
22
|
+
|
|
23
|
+
# :nocov:
|
|
24
|
+
def try_ssl_connect: () -> void
|
|
25
|
+
end
|
|
26
|
+
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) ?{ (self) -> 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
data/sig/options.rbs
CHANGED
|
@@ -2,21 +2,22 @@ module HTTPX
|
|
|
2
2
|
class Options
|
|
3
3
|
# include _ToHash
|
|
4
4
|
|
|
5
|
+
BUFFER_SIZE: Integer
|
|
5
6
|
WINDOW_SIZE: Integer
|
|
6
7
|
MAX_BODY_THRESHOLD_SIZE: Integer
|
|
7
8
|
CONNECT_TIMEOUT: Integer
|
|
8
9
|
OPERATION_TIMEOUT: Integer
|
|
9
10
|
KEEP_ALIVE_TIMEOUT: Integer
|
|
10
11
|
SETTINGS_TIMEOUT: Integer
|
|
12
|
+
CLOSE_HANDSHAKE_TIMEOUT: Integer
|
|
11
13
|
DEFAULT_OPTIONS: Hash[Symbol, untyped]
|
|
14
|
+
REQUEST_BODY_IVARS: Array[Symbol]
|
|
12
15
|
|
|
13
|
-
type timeout_type = :connect_timeout | :settings_timeout | :
|
|
14
|
-
type timeout = Hash[timeout_type, Numeric]
|
|
16
|
+
type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
|
|
17
|
+
type timeout = Hash[timeout_type, Numeric?]
|
|
15
18
|
|
|
16
19
|
def self.new: (?options) -> instance
|
|
17
20
|
|
|
18
|
-
def self.def_option: (Symbol, ?String) -> void
|
|
19
|
-
| (Symbol) { (*nil) -> untyped } -> void
|
|
20
21
|
# headers
|
|
21
22
|
attr_reader uri: URI?
|
|
22
23
|
|
|
@@ -33,23 +34,32 @@ module HTTPX
|
|
|
33
34
|
attr_reader max_concurrent_requests: Integer?
|
|
34
35
|
|
|
35
36
|
# max_requests
|
|
36
|
-
attr_reader max_requests:
|
|
37
|
+
attr_reader max_requests: Numeric?
|
|
37
38
|
|
|
38
39
|
# window_size
|
|
39
40
|
attr_reader window_size: Integer
|
|
40
41
|
|
|
42
|
+
# buffer_size
|
|
43
|
+
attr_reader buffer_size: Integer
|
|
44
|
+
|
|
41
45
|
# body_threshold_size
|
|
42
46
|
attr_reader body_threshold_size: Integer
|
|
43
47
|
|
|
44
48
|
# transport
|
|
45
|
-
attr_reader transport:
|
|
46
|
-
|
|
47
|
-
# transport_options
|
|
48
|
-
attr_reader transport_options: Hash[untyped, untyped]?
|
|
49
|
+
attr_reader transport: "unix" | nil
|
|
49
50
|
|
|
50
51
|
# addresses
|
|
51
52
|
attr_reader addresses: Array[ipaddr]?
|
|
52
53
|
|
|
54
|
+
# supported_compression_formats
|
|
55
|
+
attr_reader supported_compression_formats: Array[String]
|
|
56
|
+
|
|
57
|
+
# compress_request_body
|
|
58
|
+
attr_reader compress_request_body: bool
|
|
59
|
+
|
|
60
|
+
# decompress_response_body
|
|
61
|
+
attr_reader decompress_response_body: bool
|
|
62
|
+
|
|
53
63
|
# params
|
|
54
64
|
attr_reader params: Transcoder::urlencoded_input?
|
|
55
65
|
|
|
@@ -112,17 +122,23 @@ module HTTPX
|
|
|
112
122
|
# ip_families
|
|
113
123
|
attr_reader ip_families: Array[ip_family]
|
|
114
124
|
|
|
115
|
-
def ==: (
|
|
125
|
+
def ==: (Options other) -> bool
|
|
126
|
+
|
|
127
|
+
def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
|
|
128
|
+
|
|
116
129
|
def merge: (_ToHash[Symbol, untyped] other) -> instance
|
|
130
|
+
|
|
117
131
|
def to_hash: () -> Hash[Symbol, untyped]
|
|
118
132
|
|
|
133
|
+
def extend_with_plugin_classes: (Module pl) -> void
|
|
134
|
+
|
|
119
135
|
private
|
|
120
136
|
|
|
121
137
|
REQUEST_IVARS: Array[Symbol]
|
|
122
138
|
|
|
123
|
-
def initialize: (?options options) ->
|
|
139
|
+
def initialize: (?options options) -> void
|
|
124
140
|
|
|
125
|
-
def
|
|
141
|
+
def do_initialize: (?options options) -> void
|
|
126
142
|
end
|
|
127
143
|
|
|
128
144
|
type options = Options | Hash[Symbol, untyped]
|
|
@@ -4,6 +4,7 @@ module HTTPX
|
|
|
4
4
|
class Digest
|
|
5
5
|
@user: String
|
|
6
6
|
@password: String
|
|
7
|
+
@hashed: bool
|
|
7
8
|
|
|
8
9
|
def can_authenticate?: (String? authenticate) -> boolish
|
|
9
10
|
|
|
@@ -13,7 +14,7 @@ module HTTPX
|
|
|
13
14
|
|
|
14
15
|
def generate_header: (String meth, String uri, String authenticate) -> String
|
|
15
16
|
|
|
16
|
-
def initialize: (string user, string password) -> void
|
|
17
|
+
def initialize: (string user, string password, ?hashed: bool, **untyped) -> void
|
|
17
18
|
|
|
18
19
|
def make_cnonce: () -> String
|
|
19
20
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module HTTPX
|
|
2
|
+
module Plugins
|
|
3
|
+
module Authorization
|
|
4
|
+
module InstanceMethods
|
|
5
|
+
def authorization: (string token) -> instance
|
|
6
|
+
|
|
7
|
+
def bearer_auth: (string token) -> instance
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
type sessionAuthorization = Session & Authorization::InstanceMethods
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -6,10 +6,10 @@ module HTTPX
|
|
|
6
6
|
def self.configure: (singleton(Session)) -> void
|
|
7
7
|
|
|
8
8
|
module InstanceMethods
|
|
9
|
-
def
|
|
9
|
+
def basic_auth: (string user, string password) -> instance
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
type sessionBasicAuth =
|
|
13
|
+
type sessionBasicAuth = sessionAuthorization & BasicAuth::InstanceMethods
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module HTTPX
|
|
2
|
+
module Plugins
|
|
3
|
+
module Brotli
|
|
4
|
+
def self?.load_dependencies: (singleton(Session)) -> void
|
|
5
|
+
|
|
6
|
+
def self?.encode: (body_encoder body) -> Deflater
|
|
7
|
+
|
|
8
|
+
def self?.decode: (HTTPX::Response response, ?bytesize: Integer) -> Transcoder::_Decoder
|
|
9
|
+
|
|
10
|
+
class Deflater < Transcoder::Deflater
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module RequestBodyClassMethods
|
|
14
|
+
def initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module ResponseBodyClassMethods
|
|
18
|
+
def initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> (Transcoder::_Decoder | Transcoder::GZIP::Inflater)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module HTTPX
|
|
2
|
+
module Plugins
|
|
3
|
+
module Callbacks
|
|
4
|
+
class CallbackError < Exception
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module InstanceMethods
|
|
8
|
+
include HTTPX::Callbacks
|
|
9
|
+
|
|
10
|
+
type socket = TCPSocket | SSLSocket | UNIXSocket
|
|
11
|
+
|
|
12
|
+
def on_connection_opened: () { (http_uri origin, socket sock) -> void } -> self
|
|
13
|
+
|
|
14
|
+
def on_connection_closed: () { (http_uri origin) -> void } -> self
|
|
15
|
+
|
|
16
|
+
def on_request_error: () { (Request request, StandardError error) -> void } -> self
|
|
17
|
+
|
|
18
|
+
def on_request_started: () { (Request request) -> void } -> self
|
|
19
|
+
|
|
20
|
+
def on_request_body_chunk: () { (Request request, String chunk) -> void } -> self
|
|
21
|
+
|
|
22
|
+
def on_request_completed: () { (Request request) -> void } -> self
|
|
23
|
+
|
|
24
|
+
def on_response_started: () { (Request request, Response response) -> void } -> self
|
|
25
|
+
|
|
26
|
+
def on_response_body_chunk: () { (Request request, Response response, String chunk) -> void } -> self
|
|
27
|
+
|
|
28
|
+
def on_response_completed: () { (Request request, response response) -> void } -> self
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def emit_or_callback_error: (*untyped) -> void
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
type sessionCallbacks = Session & Callbacks::InstanceMethods
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -5,13 +5,17 @@ module HTTPX
|
|
|
5
5
|
class CircuitStore
|
|
6
6
|
@circuits: Hash[String, Circuit]
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
@circuits_mutex: Thread::Mutex
|
|
9
|
+
|
|
10
|
+
def try_open: (uri uri, response response) -> response?
|
|
9
11
|
|
|
10
12
|
def try_respond: (Request request) -> response?
|
|
11
13
|
|
|
14
|
+
def try_close: (http_uri uri) -> void
|
|
15
|
+
|
|
12
16
|
private
|
|
13
17
|
|
|
14
|
-
def get_circuit_for_uri: (
|
|
18
|
+
def get_circuit_for_uri: (uri uri) -> Circuit
|
|
15
19
|
|
|
16
20
|
def initialize: (Options & _CircuitOptions options) -> void
|
|
17
21
|
end
|
|
@@ -23,6 +27,8 @@ module HTTPX
|
|
|
23
27
|
@break_in: Float
|
|
24
28
|
@circuit_breaker_half_open_drip_rate: Float
|
|
25
29
|
@attempts: Integer
|
|
30
|
+
@real_attempts: Integer
|
|
31
|
+
@drip_factor: Integer
|
|
26
32
|
|
|
27
33
|
@response: response?
|
|
28
34
|
@opened_at: Float?
|
|
@@ -30,7 +36,7 @@ module HTTPX
|
|
|
30
36
|
|
|
31
37
|
def respond: () -> response?
|
|
32
38
|
|
|
33
|
-
def try_open: (response) ->
|
|
39
|
+
def try_open: (response) -> response?
|
|
34
40
|
|
|
35
41
|
def try_close: () -> void
|
|
36
42
|
|
|
@@ -52,6 +58,10 @@ module HTTPX
|
|
|
52
58
|
|
|
53
59
|
module InstanceMethods
|
|
54
60
|
@circuit_store: CircuitStore
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def try_circuit_open: (Request request, response response) -> response?
|
|
55
65
|
end
|
|
56
66
|
|
|
57
67
|
end
|
data/sig/plugins/compression.rbs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module HTTPX
|
|
2
2
|
module Plugins
|
|
3
3
|
module Compression
|
|
4
|
-
type encodings_registry = Registry[Symbol, Class]
|
|
5
4
|
|
|
6
5
|
type deflatable = _Reader | _ToS
|
|
7
6
|
|
|
@@ -16,12 +15,15 @@ module HTTPX
|
|
|
16
15
|
def initialize: (Integer | Float bytesize) -> untyped
|
|
17
16
|
end
|
|
18
17
|
|
|
18
|
+
interface _Compressor
|
|
19
|
+
def deflater: () -> _Deflater
|
|
20
|
+
def inflater: (Integer | Float bytesize) -> _Inflater
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def self.configure: (singleton(Session)) -> void
|
|
20
24
|
|
|
21
25
|
interface _CompressionOptions
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
def encodings: () -> encodings_registry?
|
|
26
|
+
def encodings: () -> Hash[String, _Compressor]
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def self.extra_options: (Options) -> (Options & _CompressionOptions)
|
data/sig/plugins/cookies/jar.rbs
CHANGED
|
@@ -13,8 +13,8 @@ module HTTPX
|
|
|
13
13
|
|
|
14
14
|
def []: (uri) -> Array[Cookie]
|
|
15
15
|
|
|
16
|
-
def each: (?uri) { (Cookie) -> void } -> void
|
|
17
|
-
| (?uri) -> Enumerable[Cookie]
|
|
16
|
+
def each: (?uri?) { (Cookie) -> void } -> void
|
|
17
|
+
| (?uri?) -> Enumerable[Cookie]
|
|
18
18
|
|
|
19
19
|
def merge: (_Each[cookie] cookies) -> instance
|
|
20
20
|
|
data/sig/plugins/cookies.rbs
CHANGED
|
@@ -12,10 +12,10 @@ module HTTPX
|
|
|
12
12
|
def self.load_dependencies: (*untyped) -> void
|
|
13
13
|
|
|
14
14
|
module InstanceMethods
|
|
15
|
-
def
|
|
15
|
+
def digest_auth: (string user, string password, ?hashed: bool) -> instance
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
type sessionDigestAuth =
|
|
19
|
+
type sessionDigestAuth = sessionAuthorization & DigestAuth::InstanceMethods
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -10,6 +10,10 @@ module HTTPX
|
|
|
10
10
|
def max_redirects: () -> Integer?
|
|
11
11
|
|
|
12
12
|
def follow_insecure_redirects: () -> bool?
|
|
13
|
+
|
|
14
|
+
def allow_auth_to_other_origins: () -> bool?
|
|
15
|
+
|
|
16
|
+
def redirect_on: (http_uri) -> bool?
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
|
|
@@ -17,13 +21,18 @@ module HTTPX
|
|
|
17
21
|
module InstanceMethods
|
|
18
22
|
def max_redirects: (_ToI) -> instance
|
|
19
23
|
|
|
20
|
-
def
|
|
24
|
+
def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
|
|
25
|
+
|
|
21
26
|
def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
module RequestMethods
|
|
25
|
-
|
|
30
|
+
attr_accessor root_request: instance?
|
|
31
|
+
|
|
32
|
+
def redirect_request: () -> instance
|
|
33
|
+
|
|
26
34
|
def redirect_request=: (Request) -> void
|
|
35
|
+
|
|
27
36
|
def max_redirects: () -> Integer
|
|
28
37
|
end
|
|
29
38
|
end
|