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/sig/resolver.rbs
CHANGED
@@ -2,9 +2,7 @@ module HTTPX
|
|
2
2
|
type ipaddr = IPAddr | String
|
3
3
|
|
4
4
|
module Resolver
|
5
|
-
|
6
|
-
|
7
|
-
RESOLVE_TIMEOUT: Integer | Float
|
5
|
+
RESOLVE_TIMEOUT: Array[Integer]
|
8
6
|
|
9
7
|
@lookup_mutex: Thread::Mutex
|
10
8
|
|
@@ -13,6 +11,7 @@ module HTTPX
|
|
13
11
|
type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
|
14
12
|
| { "name" => String, "TTL" => Numeric, "data" => String }
|
15
13
|
|
14
|
+
type dns_decoding_response = [:ok, Array[dns_result]] | [:decode_error, Resolv::DNS::DecodeError] | [:dns_error, Integer] | Symbol
|
16
15
|
|
17
16
|
def nolookup_resolve: (String hostname) -> Array[IPAddr]
|
18
17
|
|
@@ -20,6 +19,11 @@ module HTTPX
|
|
20
19
|
|
21
20
|
def system_resolve: (String hostname) -> Array[IPAddr]?
|
22
21
|
|
22
|
+
def self?.resolver_for: (:native resolver_type) -> singleton(Native) |
|
23
|
+
(:system resolver_type) -> singleton(System) |
|
24
|
+
(:https resolver_type) -> singleton(HTTPS) |
|
25
|
+
[U] (U resolver_type) -> U
|
26
|
+
|
23
27
|
def self?.cached_lookup: (String hostname) -> Array[IPAddr]?
|
24
28
|
|
25
29
|
def self?.cached_lookup_set: (String hostname, ip_family family, Array[dns_result] addresses) -> void
|
@@ -28,8 +32,8 @@ module HTTPX
|
|
28
32
|
|
29
33
|
def self?.generate_id: () -> Integer
|
30
34
|
|
31
|
-
def self?.encode_dns_query: (String hostname, ?type: dns_resource) -> String
|
35
|
+
def self?.encode_dns_query: (String hostname, ?type: dns_resource, ?message_id: Integer) -> String
|
32
36
|
|
33
|
-
def self?.decode_dns_answer: (String) ->
|
37
|
+
def self?.decode_dns_answer: (String) -> dns_decoding_response
|
34
38
|
end
|
35
39
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class Response::Body
|
3
|
+
include _Reader
|
4
|
+
include _ToS
|
5
|
+
include _ToStr
|
6
|
+
|
7
|
+
attr_reader encoding: Encoding | String
|
8
|
+
attr_reader encodings: Array[Encoding | String]
|
9
|
+
|
10
|
+
@response: Response
|
11
|
+
@headers: Headers
|
12
|
+
@options: Options
|
13
|
+
@state: :idle | :memory | :buffer | :closed
|
14
|
+
@window_size: Integer
|
15
|
+
@length: Integer
|
16
|
+
@buffer: StringIO | Tempfile | nil
|
17
|
+
@reader: StringIO | Tempfile | nil
|
18
|
+
@inflaters: Array[Transcoder::_Inflater]
|
19
|
+
|
20
|
+
def initialize: (Response, Options) -> void
|
21
|
+
|
22
|
+
def closed?: () -> bool
|
23
|
+
|
24
|
+
def write:(String chunk) -> Integer?
|
25
|
+
|
26
|
+
def filename: () -> String?
|
27
|
+
|
28
|
+
def bytesize: () -> Integer
|
29
|
+
|
30
|
+
def each: () { (String) -> void } -> void
|
31
|
+
| () -> Enumerable[String]
|
32
|
+
|
33
|
+
def empty?: () -> bool
|
34
|
+
|
35
|
+
def copy_to: (String | File | _Writer destination) -> void
|
36
|
+
|
37
|
+
def close: () -> void
|
38
|
+
|
39
|
+
def rewind: () -> void
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def initialize_inflaters: () -> void
|
44
|
+
|
45
|
+
def self.initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> Transcoder::GZIP::Inflater
|
46
|
+
|
47
|
+
def decode_chunk: (String chunk) -> String
|
48
|
+
|
49
|
+
def transition: (Symbol nextstate) -> void
|
50
|
+
|
51
|
+
def _with_same_buffer_pos: [A] () { () -> A } -> A
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class Response::Buffer
|
3
|
+
@threshold_size: Integer
|
4
|
+
@bytesize: Integer
|
5
|
+
@encoding: Encoding
|
6
|
+
@buffer: StringIO | Tempfile
|
7
|
+
|
8
|
+
def initialize: (threshold_size: Integer, ?bytesize: Integer, ?encoding: Encoding | String) -> void
|
9
|
+
|
10
|
+
def size: () -> Integer
|
11
|
+
|
12
|
+
def write: (String) -> void
|
13
|
+
|
14
|
+
def to_s: () -> String
|
15
|
+
|
16
|
+
def close: () -> void
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def try_upgrade_buffer: () -> void
|
21
|
+
|
22
|
+
def _with_same_buffer_pos: () { () -> void } -> void
|
23
|
+
end
|
24
|
+
end
|
data/sig/response.rbs
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module HTTPX
|
2
2
|
interface _Response
|
3
|
+
def finished?: () -> bool
|
4
|
+
|
3
5
|
def raise_for_status: () -> self
|
4
6
|
|
5
7
|
def error: () -> StandardError?
|
@@ -7,6 +9,7 @@ module HTTPX
|
|
7
9
|
|
8
10
|
class Response
|
9
11
|
extend Forwardable
|
12
|
+
include Callbacks
|
10
13
|
|
11
14
|
include _Response
|
12
15
|
include _ToS
|
@@ -22,58 +25,30 @@ module HTTPX
|
|
22
25
|
@content_type: ContentType
|
23
26
|
|
24
27
|
def copy_to: (_ToPath | _Writer destination) -> void
|
28
|
+
|
25
29
|
def close: () -> void
|
30
|
+
|
26
31
|
def uri: () -> URI::Generic
|
27
32
|
|
33
|
+
def peer_address: () -> ipaddr?
|
34
|
+
|
28
35
|
def merge_headers: (_Each[[String, headers_value]]) -> void
|
36
|
+
|
29
37
|
def bodyless?: () -> bool
|
38
|
+
|
30
39
|
def content_type: () -> ContentType
|
40
|
+
|
31
41
|
def complete?: () -> bool
|
32
42
|
|
33
43
|
def json: (?json_options opts) -> untyped
|
34
44
|
|
35
45
|
def form: () -> Hash[String, untyped]
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
|
40
|
-
def no_data?: () -> bool
|
41
|
-
|
42
|
-
def decode:(String format, ?untyped options) -> untyped
|
43
|
-
|
44
|
-
class Body
|
45
|
-
include _Reader
|
46
|
-
include _ToS
|
47
|
-
include _ToStr
|
48
|
-
|
49
|
-
@response: Response
|
50
|
-
@headers: Headers
|
51
|
-
@options: Options
|
52
|
-
@state: :idle | :memory | :buffer | :closed
|
53
|
-
@threshold_size: Integer
|
54
|
-
@window_size: Integer
|
55
|
-
@encoding: String
|
56
|
-
@length: Integer
|
57
|
-
@buffer: StringIO | Tempfile | nil
|
47
|
+
def initialize: (Request request, String | Integer status, String version, headers?) -> void
|
58
48
|
|
59
|
-
|
60
|
-
|
61
|
-
def each: () { (String) -> void } -> void
|
62
|
-
| () -> Enumerable[String]
|
63
|
-
|
64
|
-
def bytesize: () -> Numeric
|
65
|
-
def empty?: () -> bool
|
66
|
-
def copy_to: (String | File | _Writer destination) -> void
|
67
|
-
def close: () -> void
|
68
|
-
def closed?: () -> bool
|
69
|
-
|
70
|
-
private
|
49
|
+
private
|
71
50
|
|
72
|
-
|
73
|
-
def rewind: () -> void
|
74
|
-
def transition: () -> void
|
75
|
-
def _with_same_buffer_pos: [A] () { () -> A } -> A
|
76
|
-
end
|
51
|
+
def decode:(Transcoder::_Decode transcoder, ?untyped options) -> untyped
|
77
52
|
end
|
78
53
|
|
79
54
|
class ContentType
|
@@ -95,18 +70,28 @@ module HTTPX
|
|
95
70
|
|
96
71
|
class ErrorResponse
|
97
72
|
include _Response
|
73
|
+
include _Reader
|
98
74
|
include Loggable
|
75
|
+
extend Forwardable
|
99
76
|
|
100
77
|
@options: Options
|
101
78
|
@error: Exception
|
102
79
|
|
103
80
|
attr_reader request: Request
|
104
81
|
|
82
|
+
attr_reader response: Response?
|
83
|
+
|
105
84
|
def status: () -> (Integer | _ToS)
|
106
85
|
|
86
|
+
def uri: () -> URI::Generic
|
87
|
+
|
88
|
+
def peer_address: () -> ipaddr?
|
89
|
+
|
90
|
+
def close: () -> void
|
91
|
+
|
107
92
|
private
|
108
93
|
|
109
|
-
def initialize: (Request, Exception
|
94
|
+
def initialize: (Request, Exception) -> untyped
|
110
95
|
end
|
111
96
|
|
112
97
|
type response = Response | ErrorResponse
|
data/sig/selector.rbs
CHANGED
data/sig/session.rbs
CHANGED
@@ -11,42 +11,53 @@ module HTTPX
|
|
11
11
|
|
12
12
|
def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
|
13
13
|
|
14
|
-
def self.default_options: -> Options
|
15
|
-
|
16
14
|
def wrap: () { (instance) -> void } -> void
|
17
15
|
|
18
16
|
def close: (*untyped) -> void
|
19
17
|
|
20
|
-
def build_request: (
|
18
|
+
def build_request: (verb verb, generic_uri uri, ?request_params params, ?Options options) -> Request
|
21
19
|
|
22
|
-
|
20
|
+
def initialize: (?options) { (self) -> void } -> void
|
21
|
+
| (?options) -> void
|
23
22
|
|
24
|
-
|
25
|
-
| (?options) -> untyped
|
23
|
+
private
|
26
24
|
|
27
25
|
def pool: -> Pool
|
26
|
+
|
28
27
|
def on_response: (Request, response) -> void
|
28
|
+
|
29
29
|
def on_promise: (untyped, untyped) -> void
|
30
|
-
def fetch_response: (Request request, untyped, untyped) -> response?
|
31
30
|
|
32
|
-
def
|
31
|
+
def fetch_response: (Request request, Array[Connection] connections, untyped options) -> response?
|
32
|
+
|
33
|
+
def find_connection: (Request request, Array[Connection] connections, Options options) -> Connection
|
33
34
|
|
34
|
-
def
|
35
|
+
def deactivate_connection: (Request request, Array[Connection] connections, Options options) -> void
|
35
36
|
|
36
|
-
def
|
37
|
+
def send_request: (Request request, Array[Connection] connections, ?Options options) -> void
|
37
38
|
|
38
|
-
def
|
39
|
-
| (Array[[verb | string, uri, options]], options) -> Array[Request]
|
40
|
-
| (Array[[verb | string, uri]], options) -> Array[Request]
|
41
|
-
| (verb | string, _Each[[uri, options]], Options) -> Array[Request]
|
42
|
-
| (verb | string, _Each[uri], options) -> Array[Request]
|
39
|
+
def set_connection_callbacks: (Connection connection, Array[Connection] connections, Options options, ?cloned: bool) -> void
|
43
40
|
|
44
|
-
def
|
41
|
+
def set_request_callbacks: (Request request) -> void
|
42
|
+
|
43
|
+
def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> (Connection & AltSvc::ConnectionMixin)?
|
44
|
+
|
45
|
+
def build_requests: (verb, uri, request_params) -> Array[Request]
|
46
|
+
| (Array[[verb, uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
|
47
|
+
| (Array[[verb, uri]], request_params) -> Array[Request]
|
48
|
+
| (verb, _Each[[uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
|
49
|
+
| (verb, _Each[uri], request_params) -> Array[Request]
|
50
|
+
|
51
|
+
def init_connection: (http_uri uri, Options options) -> Connection
|
45
52
|
|
46
53
|
def send_requests: (*Request) -> Array[response]
|
47
54
|
|
48
|
-
def _send_requests: (Array[Request]) -> Array[Connection]
|
55
|
+
def _send_requests: (Array[Request] requests) -> Array[Connection]
|
49
56
|
|
50
|
-
def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
|
57
|
+
def receive_requests: (Array[Request] requests, Array[Connection] connections) -> Array[response]
|
58
|
+
|
59
|
+
attr_reader self.default_options: Options
|
51
60
|
end
|
61
|
+
|
62
|
+
OriginalSession: singleton(Session)
|
52
63
|
end
|
data/sig/timers.rbs
CHANGED
@@ -1,32 +1,42 @@
|
|
1
1
|
module HTTPX
|
2
2
|
class Timers
|
3
3
|
@intervals: Array[Interval]
|
4
|
-
@next_interval_at:
|
4
|
+
@next_interval_at: Float
|
5
5
|
|
6
|
-
def after: (Numeric interval_in_secs
|
6
|
+
def after: (Numeric interval_in_secs, ^() -> void) -> Interval
|
7
|
+
| (Numeric interval_in_secs) { () -> void } -> Interval
|
7
8
|
|
8
9
|
def wait_interval: () -> Numeric?
|
9
10
|
|
10
11
|
def fire: (?TimeoutError error) -> void
|
11
12
|
|
12
|
-
def cancel: () -> void
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
13
|
def initialize: () -> void
|
17
14
|
|
18
15
|
class Interval
|
19
16
|
include Comparable
|
20
17
|
|
18
|
+
type callback = ^() -> void
|
19
|
+
|
21
20
|
attr_reader interval: Numeric
|
22
21
|
|
23
|
-
@callbacks: Array[
|
22
|
+
@callbacks: Array[callback]
|
23
|
+
@on_empty: callback?
|
24
|
+
|
25
|
+
|
26
|
+
def on_empty: () { () -> void } -> void
|
24
27
|
|
25
28
|
def to_f: () -> Float
|
26
29
|
|
27
|
-
def <<: (
|
30
|
+
def <<: (callback) -> void
|
31
|
+
|
32
|
+
def delete: (callback) -> void
|
28
33
|
|
29
34
|
def elapse: (Numeric elapsed) -> Numeric
|
35
|
+
|
36
|
+
def elapsed?: () -> bool
|
37
|
+
|
38
|
+
def no_callbacks?: () -> bool
|
39
|
+
|
30
40
|
private
|
31
41
|
|
32
42
|
def initialize: (Numeric interval) -> void
|
data/sig/transcoder/body.rbs
CHANGED
@@ -7,13 +7,14 @@ module HTTPX
|
|
7
7
|
class Encoder
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
include _Encoder
|
11
|
-
include _ToS
|
12
|
-
|
13
10
|
@raw: bodyIO
|
14
11
|
|
12
|
+
def bytesize: () -> (Integer | Float)
|
13
|
+
|
15
14
|
def content_type: () -> String
|
16
15
|
|
16
|
+
def to_s: () -> String
|
17
|
+
|
17
18
|
private
|
18
19
|
|
19
20
|
def initialize: (untyped body) -> untyped
|
data/sig/transcoder/form.rbs
CHANGED
@@ -3,17 +3,19 @@ module HTTPX::Transcoder
|
|
3
3
|
|
4
4
|
type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
|
5
5
|
|
6
|
-
type urlencoded_input = Enumerable[[_ToS, form_nested_value]]
|
6
|
+
type urlencoded_input = Enumerable[[_ToS, form_nested_value | Multipart::multipart_nested_value]]
|
7
7
|
|
8
8
|
module Form
|
9
|
-
def self?.encode: (urlencoded_input form) -> Encoder
|
9
|
+
def self?.encode: (urlencoded_input form) -> (Encoder | Multipart::Encoder)
|
10
10
|
def self?.decode: (HTTPX::Response response) -> _Decoder
|
11
|
+
def self?.multipart?: (form_nested_value | Multipart::multipart_nested_value data) -> bool
|
11
12
|
|
12
13
|
class Encoder
|
13
14
|
extend Forwardable
|
14
|
-
include _Encoder
|
15
15
|
include _ToS
|
16
16
|
|
17
|
+
def bytesize: () -> Integer
|
18
|
+
|
17
19
|
def content_type: () -> String
|
18
20
|
|
19
21
|
private
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Transcoder
|
3
|
+
module GZIP
|
4
|
+
def self?.encode: (_Encoder body) -> Deflater
|
5
|
+
def self?.decode: (Response response, ?bytesize: Integer) -> Inflater
|
6
|
+
|
7
|
+
class Deflater < Transcoder::Deflater
|
8
|
+
@compressed_chunk: String
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def write: (String chunk) -> void
|
13
|
+
|
14
|
+
def compressed_chunk: () -> String
|
15
|
+
end
|
16
|
+
|
17
|
+
class Inflater
|
18
|
+
def initialize: (Integer | Float bytesize) -> void
|
19
|
+
|
20
|
+
def call: (String chunk) -> String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/sig/transcoder/json.rbs
CHANGED
@@ -5,19 +5,24 @@ module HTTPX::Transcoder
|
|
5
5
|
def self?.encode: (_ToJson json) -> Encoder
|
6
6
|
def self?.decode: (HTTPX::Response response) -> _Decoder
|
7
7
|
|
8
|
+
def self?.json_load: (string source, ?json_options) -> untyped
|
9
|
+
def self?.json_dump: (_ToJson obj, *untyped) -> String
|
10
|
+
|
8
11
|
class Encoder
|
9
12
|
extend Forwardable
|
10
|
-
include _Encoder
|
11
|
-
include _ToS
|
12
13
|
|
13
14
|
@raw: String
|
14
15
|
@charset: String
|
15
16
|
|
17
|
+
def bytesize: () -> Integer
|
18
|
+
|
16
19
|
def content_type: () -> String
|
17
20
|
|
21
|
+
def to_s: () -> String
|
22
|
+
|
18
23
|
private
|
19
24
|
|
20
|
-
def initialize: (_ToJson json) ->
|
25
|
+
def initialize: (_ToJson json) -> void
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module HTTPX
|
2
|
-
module
|
2
|
+
module Transcoder
|
3
3
|
module Multipart
|
4
4
|
interface _MultipartInput
|
5
5
|
def filename: () -> String
|
@@ -9,13 +9,6 @@ module HTTPX
|
|
9
9
|
|
10
10
|
MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
|
11
11
|
|
12
|
-
def self.load_dependencies: (singleton(Session)) -> void
|
13
|
-
def self.configure: (*untyped) -> void
|
14
|
-
def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
|
15
|
-
def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
|
16
|
-
|
17
|
-
def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> U } -> U
|
18
|
-
|
19
12
|
type multipart_value = string | Pathname | File | _Reader
|
20
13
|
|
21
14
|
type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
|
@@ -24,14 +17,14 @@ module HTTPX
|
|
24
17
|
type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
|
25
18
|
|
26
19
|
class Encoder
|
27
|
-
include Transcoder::_Encoder
|
28
|
-
|
29
20
|
@boundary: String
|
30
21
|
@part_index: Integer
|
31
22
|
@buffer: String
|
32
23
|
|
33
|
-
@form: Enumerable[[Symbol | string, multipart_nested_value]]
|
34
|
-
@parts: Array[_Reader]
|
24
|
+
@form: Enumerable[[Symbol | string, Object & multipart_nested_value]]
|
25
|
+
@parts: Array[Object & _Reader]
|
26
|
+
|
27
|
+
def bytesize: () -> Integer
|
35
28
|
|
36
29
|
def content_type: () -> String
|
37
30
|
|
@@ -47,13 +40,18 @@ module HTTPX
|
|
47
40
|
|
48
41
|
def header_part: (string key, String content_type, String? filename) -> StringIO
|
49
42
|
|
50
|
-
def read_chunks: (String buffer, ?
|
43
|
+
def read_chunks: (String buffer, ?int? length) -> void
|
51
44
|
|
52
|
-
def read_from_part: (?
|
45
|
+
def read_from_part: (?int? max_length) -> String?
|
53
46
|
end
|
54
47
|
|
55
48
|
class Decoder
|
49
|
+
CRLF: String
|
56
50
|
BOUNDARY_RE: Regexp
|
51
|
+
MULTIPART_CONTENT_TYPE: Regexp
|
52
|
+
MULTIPART_CONTENT_DISPOSITION: Regexp
|
53
|
+
MULTIPART_CONTENT_ID: Regexp
|
54
|
+
WINDOW_SIZE: Integer
|
57
55
|
|
58
56
|
@state: :idle | :part_header | :part_body | :parse_boundary | :done
|
59
57
|
@buffer: String
|
@@ -61,15 +59,13 @@ module HTTPX
|
|
61
59
|
@boundary: String
|
62
60
|
@intermediate_boundary: String
|
63
61
|
|
64
|
-
def call: (Response response, untyped) -> Hash[String, untyped]
|
62
|
+
def call: (Response response, *untyped) -> Hash[String, untyped]
|
65
63
|
|
66
64
|
private
|
67
65
|
|
68
66
|
def initialize: (Response response) -> void
|
69
67
|
|
70
68
|
def parse: () -> void
|
71
|
-
|
72
|
-
def get_filename: (String head) -> String?
|
73
69
|
end
|
74
70
|
|
75
71
|
class FilePart # < SimpleDelegator
|
@@ -84,8 +80,8 @@ module HTTPX
|
|
84
80
|
end
|
85
81
|
|
86
82
|
module Part
|
87
|
-
def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
|
88
|
-
| (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
|
83
|
+
def self?.call: [U] (Object & _MultipartInput multipart_input) -> [U, String, String]
|
84
|
+
| (Object & multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
|
89
85
|
end
|
90
86
|
|
91
87
|
module MimeTypeDetector
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Transcoder
|
3
|
+
class BodyReader
|
4
|
+
@body: _Reader | _Each[String]
|
5
|
+
|
6
|
+
def initialize: (bodyIO body) -> void
|
7
|
+
|
8
|
+
def bytesize: () -> (Integer | Float)
|
9
|
+
|
10
|
+
def read: (?int? length, ?string outbuf) -> String?
|
11
|
+
|
12
|
+
def close: () -> void
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Transcoder
|
3
|
+
class Deflater
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
@body: BodyReader
|
7
|
+
@buffer: Response::Buffer?
|
8
|
+
@body: _Encoder | StringIO
|
9
|
+
@closed: bool
|
10
|
+
|
11
|
+
attr_reader content_type: String
|
12
|
+
|
13
|
+
def initialize: (_Encoder body) -> void
|
14
|
+
|
15
|
+
def bytesize: () -> (Integer | Float)
|
16
|
+
|
17
|
+
def read: (?int? length, ?string outbuf) -> String?
|
18
|
+
|
19
|
+
def close: () -> void
|
20
|
+
|
21
|
+
def deflate: (String? chunk) -> String?
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def buffer_deflate!: () -> void
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module HTTPX::Transcoder
|
2
|
+
module Xml
|
3
|
+
MIME_TYPES: Regexp
|
4
|
+
|
5
|
+
def self?.encode: (untyped xml) -> Encoder
|
6
|
+
def self?.decode: (HTTPX::Response response) -> _Decoder
|
7
|
+
|
8
|
+
class Encoder
|
9
|
+
@raw: untyped # can be nokogiri object
|
10
|
+
|
11
|
+
def content_type: () -> String
|
12
|
+
|
13
|
+
def bytesize: () -> (Integer | Float)
|
14
|
+
|
15
|
+
def to_s: () -> String
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def initialize: (String xml) -> void
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|