httpx 0.18.4 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes/0_18_3.md +1 -1
- data/doc/release_notes/0_18_4.md +2 -2
- data/doc/release_notes/0_18_5.md +10 -0
- data/doc/release_notes/0_18_6.md +5 -0
- data/doc/release_notes/0_18_7.md +5 -0
- data/doc/release_notes/0_19_0.md +39 -0
- data/lib/httpx/adapters/faraday.rb +7 -3
- data/lib/httpx/connection/http1.rb +6 -6
- data/lib/httpx/connection/http2.rb +7 -5
- data/lib/httpx/connection.rb +22 -10
- data/lib/httpx/extensions.rb +16 -0
- data/lib/httpx/headers.rb +0 -2
- data/lib/httpx/io/tcp.rb +27 -6
- data/lib/httpx/options.rb +44 -11
- data/lib/httpx/plugins/cookies.rb +5 -7
- data/lib/httpx/plugins/internal_telemetry.rb +1 -1
- data/lib/httpx/plugins/multipart/mime_type_detector.rb +7 -1
- data/lib/httpx/plugins/proxy/http.rb +10 -23
- data/lib/httpx/plugins/proxy/socks4.rb +1 -1
- data/lib/httpx/plugins/proxy/socks5.rb +1 -1
- data/lib/httpx/plugins/proxy.rb +35 -15
- data/lib/httpx/plugins/retries.rb +1 -1
- data/lib/httpx/pool.rb +40 -20
- data/lib/httpx/resolver/https.rb +32 -42
- data/lib/httpx/resolver/multi.rb +79 -0
- data/lib/httpx/resolver/native.rb +28 -36
- data/lib/httpx/resolver/resolver.rb +92 -0
- data/lib/httpx/resolver/system.rb +175 -19
- data/lib/httpx/resolver.rb +37 -11
- data/lib/httpx/response.rb +4 -2
- data/lib/httpx/session.rb +1 -15
- data/lib/httpx/session_extensions.rb +26 -0
- data/lib/httpx/timers.rb +1 -1
- data/lib/httpx/transcoder/chunker.rb +0 -1
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +3 -0
- data/sig/connection/http1.rbs +0 -2
- data/sig/connection/http2.rbs +2 -2
- data/sig/connection.rbs +1 -0
- data/sig/errors.rbs +8 -0
- data/sig/headers.rbs +0 -2
- data/sig/httpx.rbs +4 -0
- data/sig/options.rbs +10 -7
- data/sig/parser/http1.rbs +14 -5
- data/sig/pool.rbs +17 -9
- data/sig/registry.rbs +3 -0
- data/sig/request.rbs +11 -0
- data/sig/resolver/https.rbs +15 -27
- data/sig/resolver/multi.rbs +7 -0
- data/sig/resolver/native.rbs +3 -12
- data/sig/resolver/resolver.rbs +36 -0
- data/sig/resolver/system.rbs +3 -9
- data/sig/resolver.rbs +12 -10
- data/sig/response.rbs +15 -5
- data/sig/selector.rbs +3 -3
- data/sig/timers.rbs +5 -2
- data/sig/transcoder/chunker.rbs +16 -5
- data/sig/transcoder/json.rbs +5 -0
- data/sig/transcoder.rbs +3 -1
- metadata +15 -4
- data/lib/httpx/resolver/resolver_mixin.rb +0 -75
- data/sig/resolver/resolver_mixin.rbs +0 -26
data/sig/parser/http1.rbs
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Parser
|
3
|
+
class Error < HTTPX::Error
|
4
|
+
end
|
5
|
+
|
3
6
|
type parsed_headers = Hash[String, Array[String]]
|
4
7
|
|
5
8
|
interface _HTTP1Events
|
@@ -14,16 +17,22 @@ module HTTPX
|
|
14
17
|
class HTTP1
|
15
18
|
VERSIONS: Array[String]
|
16
19
|
|
17
|
-
|
20
|
+
attr_reader status_code: Integer
|
21
|
+
attr_reader http_version: [Integer, Integer]
|
22
|
+
attr_reader headers: parsed_headers
|
18
23
|
|
19
|
-
|
24
|
+
@observer: _HTTP1Events
|
25
|
+
@state: Symbol
|
26
|
+
@buffer: String
|
27
|
+
@content_type: String?
|
28
|
+
@content_length: Integer
|
29
|
+
@_has_trailers: bool
|
30
|
+
@upgrade: bool
|
20
31
|
|
21
|
-
def
|
32
|
+
def <<: (String chunk) -> void
|
22
33
|
|
23
34
|
def reset!: () -> void
|
24
35
|
|
25
|
-
def status_code: () -> Integer
|
26
|
-
|
27
36
|
def upgrade?: () -> bool
|
28
37
|
|
29
38
|
def upgrade_data: () -> String
|
data/sig/pool.rbs
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
module HTTPX
|
2
2
|
class Pool
|
3
|
+
type resolver_manager = Resolver::Multi | Resolver::System
|
4
|
+
|
5
|
+
@resolvers: Hash[Class, resolver_manager]
|
6
|
+
@timers: Timers
|
7
|
+
@selector: Selector
|
8
|
+
@connections: Array[Connection]
|
9
|
+
@connected_connections: Integer
|
10
|
+
|
3
11
|
def empty?: () -> void
|
4
12
|
|
5
13
|
def next_tick: () -> void
|
6
14
|
|
7
|
-
def close: (
|
15
|
+
def close: (?Array[Connection] connections) -> void
|
8
16
|
|
9
|
-
def init_connection: (Connection, Options) -> void
|
17
|
+
def init_connection: (Connection connection, Options options) -> void
|
10
18
|
|
11
|
-
def find_connection: (
|
19
|
+
def find_connection: (URI::Generic uri, Options options) -> Connection?
|
12
20
|
|
13
21
|
def deactivate: (*Array[Connection]) -> void
|
14
22
|
|
@@ -22,20 +30,20 @@ module HTTPX
|
|
22
30
|
|
23
31
|
def on_resolver_error: (Connection, StandardError) -> void
|
24
32
|
|
25
|
-
def on_resolver_close: (
|
33
|
+
def on_resolver_close: (Resolver::Resolver) -> void
|
26
34
|
|
27
35
|
def register_connection: (Connection) -> void
|
28
36
|
|
29
37
|
def unregister_connection: (Connection) -> void
|
30
38
|
|
31
|
-
def select_connection: (
|
39
|
+
def select_connection: (Resolver::Resolver | Connection connection) -> void
|
32
40
|
|
33
|
-
def deselect_connection: (
|
41
|
+
def deselect_connection: (Resolver::Resolver | Connection connection) -> void
|
34
42
|
|
35
|
-
def coalesce_connections: (Connection, Connection) -> void
|
43
|
+
def coalesce_connections: (Connection coalescable, Connection coalescing) -> void
|
36
44
|
|
37
|
-
def next_timeout: () ->
|
45
|
+
def next_timeout: () -> (Integer | Float | nil)
|
38
46
|
|
39
|
-
def find_resolver_for: (Connection) ->
|
47
|
+
def find_resolver_for: (Connection) { (Resolver::Resolver resolver) -> void } -> resolver_manager
|
40
48
|
end
|
41
49
|
end
|
data/sig/registry.rbs
CHANGED
data/sig/request.rbs
CHANGED
@@ -15,6 +15,11 @@ module HTTPX
|
|
15
15
|
attr_reader response: response?
|
16
16
|
attr_reader drain_error: StandardError?
|
17
17
|
|
18
|
+
@trailers: Headers?
|
19
|
+
@informational_status: Integer?
|
20
|
+
@query: String?
|
21
|
+
@drainer: Enumerator[String, void]?
|
22
|
+
|
18
23
|
def initialize: (Symbol | String, generic_uri, ?options) -> untyped
|
19
24
|
|
20
25
|
def interests: () -> (:r | :w)
|
@@ -46,6 +51,10 @@ module HTTPX
|
|
46
51
|
def trailers?: () -> boolish
|
47
52
|
|
48
53
|
class Body
|
54
|
+
@headers: Headers
|
55
|
+
@body: body_encoder?
|
56
|
+
@unbounded_body: bool
|
57
|
+
|
49
58
|
def initialize: (Headers, Options) -> untyped
|
50
59
|
def each: () { (String) -> void } -> void
|
51
60
|
| () -> Enumerable[String]
|
@@ -61,6 +70,8 @@ module HTTPX
|
|
61
70
|
end
|
62
71
|
|
63
72
|
class ProcIO
|
73
|
+
@block: ^(String) -> void
|
74
|
+
|
64
75
|
def initialize: (^(String) -> void) -> untyped
|
65
76
|
|
66
77
|
def write: (String data) -> Integer
|
data/sig/resolver/https.rbs
CHANGED
@@ -1,49 +1,37 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Resolver
|
3
|
-
class HTTPS
|
4
|
-
|
5
|
-
include _ToIO
|
3
|
+
class HTTPS < Resolver
|
4
|
+
NAMESERVER: String
|
6
5
|
|
6
|
+
DEFAULTS: Hash[Symbol, untyped]
|
7
|
+
FAMILY_TYPES: Hash[singleton(Resolv::DNS::Resource), String]
|
8
|
+
|
9
|
+
@family: ip_family
|
7
10
|
@options: Options
|
8
|
-
@resolver_options: Hash[Symbol, untyped]
|
9
|
-
@_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
|
10
|
-
@queries: Hash[String, Connection]
|
11
11
|
@requests: Hash[Request, Connection]
|
12
12
|
@connections: Array[Connection]
|
13
|
-
@uri: URI::
|
13
|
+
@uri: URI::Generic
|
14
14
|
@uri_addresses: Array[String]?
|
15
|
+
@resolver: Resolv::DNS
|
16
|
+
@resolver_connection: Connection
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
def timeout: () -> Numeric?
|
19
|
-
|
20
|
-
def closed?: () -> bool
|
21
|
-
|
22
|
-
def empty?: () -> bool
|
18
|
+
attr_writer pool: Pool
|
23
19
|
|
24
|
-
def
|
25
|
-
|
26
|
-
def call: () -> void
|
27
|
-
|
28
|
-
def interests: () -> io_interests?
|
20
|
+
def <<: (Connection) -> void
|
29
21
|
|
30
22
|
private
|
31
23
|
|
32
|
-
def initialize: (options) ->
|
33
|
-
|
34
|
-
def pool: () -> Pool
|
24
|
+
def initialize: (ip_family family, options options) -> void
|
35
25
|
|
36
26
|
def resolver_connection: () -> Connection
|
37
27
|
|
38
|
-
def resolve: (Connection, String hostname) -> void
|
39
|
-
| (Connection) -> void
|
40
|
-
| () -> void
|
28
|
+
def resolve: (?Connection connection, ?String? hostname) -> void
|
41
29
|
|
42
30
|
def on_response: (Request, response) -> void
|
43
31
|
|
44
|
-
def
|
32
|
+
def parse: (Response response) -> void
|
45
33
|
|
46
|
-
def build_request: (String hostname
|
34
|
+
def build_request: (String hostname) -> Request
|
47
35
|
|
48
36
|
def decode_response_body: (Response) -> Array[dns_result]
|
49
37
|
end
|
data/sig/resolver/native.rbs
CHANGED
@@ -1,33 +1,24 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Resolver
|
3
|
-
class Native
|
3
|
+
class Native < Resolver
|
4
4
|
extend Forwardable
|
5
|
-
include ResolverMixin
|
6
5
|
include _ToIO
|
7
6
|
|
8
7
|
DEFAULTS: Hash[Symbol, untyped]
|
9
8
|
DNS_PORT: Integer
|
10
9
|
|
10
|
+
@family: ip_family
|
11
11
|
@options: Options
|
12
12
|
@ns_index: Integer
|
13
|
-
@resolver_options: Hash[Symbol, untyped]
|
14
13
|
@nameserver: String
|
15
14
|
@_timeouts: Array[Numeric]
|
16
15
|
@timeouts: Hash[String, Array[Numeric]]
|
17
|
-
@_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
|
18
16
|
@connections: Array[Connection]
|
19
|
-
@queries: Hash[String, Connection]
|
20
17
|
@read_buffer: String
|
21
18
|
@write_buffer: Buffer
|
22
19
|
|
23
20
|
attr_reader state: Symbol
|
24
21
|
|
25
|
-
def closed?: () -> bool
|
26
|
-
|
27
|
-
def empty?: () -> bool
|
28
|
-
|
29
|
-
def close: () -> void
|
30
|
-
|
31
22
|
def call: () -> void
|
32
23
|
|
33
24
|
def interests: () -> io_interests
|
@@ -38,7 +29,7 @@ module HTTPX
|
|
38
29
|
|
39
30
|
private
|
40
31
|
|
41
|
-
def initialize: (options) ->
|
32
|
+
def initialize: (ip_family family, options options) -> void
|
42
33
|
|
43
34
|
def calculate_interests: () -> (:r | :w)
|
44
35
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Resolver
|
3
|
+
class Resolver
|
4
|
+
include Callbacks
|
5
|
+
include Loggable
|
6
|
+
|
7
|
+
RECORD_TYPES: Hash[Integer, singleton(Resolv::DNS::Resource)]
|
8
|
+
|
9
|
+
attr_reader family: ip_family
|
10
|
+
|
11
|
+
@record_type: singleton(Resolv::DNS::Resource)
|
12
|
+
@options: Options
|
13
|
+
@resolver_options: Hash[Symbol, untyped]
|
14
|
+
@queries: Hash[String, Connection]
|
15
|
+
@system_resolver: Resolv::Hosts
|
16
|
+
|
17
|
+
def close: () -> void
|
18
|
+
|
19
|
+
def closed?: () -> bool
|
20
|
+
|
21
|
+
def empty?: () -> bool
|
22
|
+
|
23
|
+
def emit_addresses: (Connection connection, ip_family family, Array[IPAddr]) -> void
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def initialize: (ip_family? family, options options) -> void
|
28
|
+
|
29
|
+
def early_resolve: (Connection connection, ?hostname: String) -> void
|
30
|
+
|
31
|
+
def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
|
32
|
+
|
33
|
+
def resolve_error: (String hostname, ?StandardError?) -> ResolveError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/sig/resolver/system.rbs
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
module HTTPX
|
2
2
|
module Resolver
|
3
|
-
class System
|
4
|
-
include ResolverMixin
|
5
|
-
|
3
|
+
class System < Resolver
|
6
4
|
RESOLV_ERRORS: Array[singleton(StandardError)] # ResolvError
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
def closed?: () -> true
|
11
|
-
|
12
|
-
def empty?: () -> true
|
6
|
+
@resolver: Resolv::DNS
|
13
7
|
|
14
8
|
def <<: (Connection) -> void
|
15
9
|
|
16
10
|
private
|
17
11
|
|
18
|
-
def initialize: (options) ->
|
12
|
+
def initialize: (options options) -> void
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
data/sig/resolver.rbs
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
module HTTPX
|
2
2
|
type ipaddr = IPAddr | String
|
3
3
|
|
4
|
-
type resolver = Resolver::System | Resolver::Native | Resolver::HTTPS
|
5
|
-
|
6
4
|
module Resolver
|
7
|
-
|
5
|
+
extend Registry[Symbol, Class]
|
8
6
|
|
9
|
-
|
10
|
-
| () -> Hash[Symbol, Class]
|
7
|
+
RESOLVE_TIMEOUT: Integer | Float
|
11
8
|
|
12
|
-
|
9
|
+
@lookup_mutex: Thread::Mutex
|
13
10
|
|
14
11
|
type dns_resource = singleton(Resolv::DNS::Resource)
|
15
12
|
|
16
13
|
type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
|
17
14
|
| { "name" => String, "TTL" => Numeric, "data" => String }
|
18
15
|
|
19
|
-
def self?.cached_lookup: (String hostname) -> Array[String]?
|
20
16
|
|
21
|
-
def
|
17
|
+
def nolookup_resolve: (String hostname) -> Array[IPAddr]
|
18
|
+
|
19
|
+
def ip_resolve: (String hostname) -> Array[IPAddr]?
|
20
|
+
|
21
|
+
def system_resolve: (String hostname) -> Array[IPAddr]?
|
22
|
+
|
23
|
+
def self?.cached_lookup: (String hostname) -> Array[IPAddr]?
|
22
24
|
|
23
|
-
def self?.
|
25
|
+
def self?.cached_lookup_set: (String hostname, ip_family family, Array[dns_result] addresses) -> void
|
24
26
|
|
25
|
-
def self?.lookup: (String hostname, Numeric ttl) -> Array[
|
27
|
+
def self?.lookup: (String hostname, Numeric ttl) -> Array[IPAddr]?
|
26
28
|
|
27
29
|
def self?.generate_id: () -> Integer
|
28
30
|
|
data/sig/response.rbs
CHANGED
@@ -19,6 +19,7 @@ module HTTPX
|
|
19
19
|
|
20
20
|
@options: Options
|
21
21
|
@request: Request
|
22
|
+
@content_type: ContentType
|
22
23
|
|
23
24
|
def copy_to: (_ToPath | _Writer destination) -> void
|
24
25
|
def close: () -> void
|
@@ -45,9 +46,15 @@ module HTTPX
|
|
45
46
|
include _ToS
|
46
47
|
include _ToStr
|
47
48
|
|
49
|
+
@response: Response
|
50
|
+
@headers: Headers
|
51
|
+
@options: Options
|
48
52
|
@state: :idle | :memory | :buffer | :closed
|
49
53
|
@threshold_size: Integer
|
50
54
|
@window_size: Integer
|
55
|
+
@encoding: String
|
56
|
+
@length: Integer
|
57
|
+
@buffer: StringIO | Tempfile | nil
|
51
58
|
|
52
59
|
def write:(String chunk) -> Integer?
|
53
60
|
|
@@ -65,6 +72,7 @@ module HTTPX
|
|
65
72
|
def initialize: (Response, Options) -> untyped
|
66
73
|
def rewind: () -> void
|
67
74
|
def transition: () -> void
|
75
|
+
def _with_same_buffer_pos: [A] () { () -> A } -> A
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
@@ -72,12 +80,13 @@ module HTTPX
|
|
72
80
|
MIME_TYPE_RE: Regexp
|
73
81
|
CHARSET_RE: Regexp
|
74
82
|
|
75
|
-
|
76
|
-
|
83
|
+
@header_value: String?
|
84
|
+
@mime_type: String?
|
85
|
+
@charset: String?
|
77
86
|
|
78
|
-
def
|
79
|
-
|
80
|
-
def
|
87
|
+
def mime_type: () -> String?
|
88
|
+
|
89
|
+
def charset: () -> String?
|
81
90
|
|
82
91
|
private
|
83
92
|
|
@@ -89,6 +98,7 @@ module HTTPX
|
|
89
98
|
include Loggable
|
90
99
|
|
91
100
|
@options: Options
|
101
|
+
@error: Exception
|
92
102
|
|
93
103
|
attr_reader request: Request
|
94
104
|
|
data/sig/selector.rbs
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module HTTPX
|
2
2
|
class Selector
|
3
|
-
type selectable = Connection | Resolver::Native | Resolver::
|
3
|
+
type selectable = Connection | Resolver::Native | Resolver::System
|
4
4
|
|
5
5
|
READABLE: Array[Symbol]
|
6
6
|
WRITABLE: Array[Symbol]
|
7
7
|
@selectables: Array[selectable]
|
8
8
|
|
9
|
-
def register: (selectable) -> void
|
10
|
-
def deregister: (selectable) -> void
|
9
|
+
def register: (selectable io) -> void
|
10
|
+
def deregister: (selectable io) -> void
|
11
11
|
|
12
12
|
def select: (Numeric? interval) { (selectable) -> void } -> void
|
13
13
|
|
data/sig/timers.rbs
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module HTTPX
|
2
2
|
class Timers
|
3
|
-
@
|
3
|
+
@intervals: Array[Interval]
|
4
|
+
@next_interval_at: Numeric
|
4
5
|
|
5
6
|
def after: (Numeric interval_in_secs) { () -> void } -> void
|
6
7
|
|
7
8
|
def wait_interval: () -> Numeric?
|
8
9
|
|
9
|
-
def fire: (?
|
10
|
+
def fire: (?TimeoutError error) -> void
|
10
11
|
|
11
12
|
def cancel: () -> void
|
12
13
|
|
@@ -19,6 +20,8 @@ module HTTPX
|
|
19
20
|
|
20
21
|
attr_reader interval: Numeric
|
21
22
|
|
23
|
+
@callbacks: Array[^() -> void]
|
24
|
+
|
22
25
|
def to_f: () -> Float
|
23
26
|
|
24
27
|
def <<: (^() -> void) -> void
|
data/sig/transcoder/chunker.rbs
CHANGED
@@ -10,27 +10,38 @@ module HTTPX::Transcoder
|
|
10
10
|
class Encoder
|
11
11
|
@raw: _Each[String]
|
12
12
|
|
13
|
-
|
13
|
+
def each: () { (String) -> void } -> void
|
14
|
+
| () -> Enumerator[String, void]
|
14
15
|
|
15
16
|
private
|
16
17
|
|
17
|
-
def initialize: (_Each[String] chunks) ->
|
18
|
+
def initialize: (_Each[String] chunks) -> void
|
18
19
|
end
|
19
20
|
|
20
21
|
class Decoder
|
21
22
|
extend Forwardable
|
22
23
|
include _ToS
|
23
|
-
|
24
|
+
|
25
|
+
@buffer: String
|
26
|
+
@chunk_length: Integer
|
27
|
+
@chunk_buffer: String
|
28
|
+
@finished: bool
|
29
|
+
@state: Symbol
|
30
|
+
@trailers: bool
|
31
|
+
|
32
|
+
def each: () { (String) -> void } -> void
|
24
33
|
|
25
34
|
def finished?: () -> bool
|
35
|
+
|
26
36
|
def empty?: () -> bool
|
37
|
+
|
27
38
|
def <<: (string) -> void
|
39
|
+
|
28
40
|
def clear: () -> void
|
29
41
|
|
30
42
|
private
|
31
43
|
|
32
|
-
def initialize: (String, bool) ->
|
33
|
-
| (String) -> untyped
|
44
|
+
def initialize: (String, ?bool) -> void
|
34
45
|
|
35
46
|
def nextstate: (Symbol) -> void
|
36
47
|
end
|
data/sig/transcoder/json.rbs
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module HTTPX::Transcoder
|
2
2
|
module JSON
|
3
|
+
JSON_REGEX: Regexp
|
4
|
+
|
3
5
|
def self?.encode: (_ToJson json) -> Encoder
|
4
6
|
def self?.decode: (HTTPX::Response response) -> _Decoder
|
5
7
|
|
@@ -8,6 +10,9 @@ module HTTPX::Transcoder
|
|
8
10
|
include _Encoder
|
9
11
|
include _ToS
|
10
12
|
|
13
|
+
@raw: String
|
14
|
+
@charset: String
|
15
|
+
|
11
16
|
def content_type: () -> String
|
12
17
|
|
13
18
|
private
|
data/sig/transcoder.rbs
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module HTTPX
|
2
2
|
type bodyIO = _Reader | _Each[[String, untyped]] | _ToS
|
3
3
|
|
4
|
+
type body_encoder = Transcoder::_Encoder | _Each[String]
|
5
|
+
|
4
6
|
module Transcoder
|
5
7
|
def self?.registry: (String tag) -> _Encode
|
6
8
|
| () -> Hash[String, _Encode]
|
@@ -12,7 +14,7 @@ module HTTPX
|
|
12
14
|
def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth) -> void
|
13
15
|
|
14
16
|
interface _Encode
|
15
|
-
def encode: (untyped payload) ->
|
17
|
+
def encode: (untyped payload) -> body_encoder
|
16
18
|
end
|
17
19
|
|
18
20
|
interface _Encoder
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -67,6 +67,10 @@ extra_rdoc_files:
|
|
67
67
|
- doc/release_notes/0_18_2.md
|
68
68
|
- doc/release_notes/0_18_3.md
|
69
69
|
- doc/release_notes/0_18_4.md
|
70
|
+
- doc/release_notes/0_18_5.md
|
71
|
+
- doc/release_notes/0_18_6.md
|
72
|
+
- doc/release_notes/0_18_7.md
|
73
|
+
- doc/release_notes/0_19_0.md
|
70
74
|
- doc/release_notes/0_1_0.md
|
71
75
|
- doc/release_notes/0_2_0.md
|
72
76
|
- doc/release_notes/0_2_1.md
|
@@ -127,6 +131,10 @@ files:
|
|
127
131
|
- doc/release_notes/0_18_2.md
|
128
132
|
- doc/release_notes/0_18_3.md
|
129
133
|
- doc/release_notes/0_18_4.md
|
134
|
+
- doc/release_notes/0_18_5.md
|
135
|
+
- doc/release_notes/0_18_6.md
|
136
|
+
- doc/release_notes/0_18_7.md
|
137
|
+
- doc/release_notes/0_19_0.md
|
130
138
|
- doc/release_notes/0_1_0.md
|
131
139
|
- doc/release_notes/0_2_0.md
|
132
140
|
- doc/release_notes/0_2_1.md
|
@@ -223,13 +231,15 @@ files:
|
|
223
231
|
- lib/httpx/request.rb
|
224
232
|
- lib/httpx/resolver.rb
|
225
233
|
- lib/httpx/resolver/https.rb
|
234
|
+
- lib/httpx/resolver/multi.rb
|
226
235
|
- lib/httpx/resolver/native.rb
|
227
|
-
- lib/httpx/resolver/
|
236
|
+
- lib/httpx/resolver/resolver.rb
|
228
237
|
- lib/httpx/resolver/system.rb
|
229
238
|
- lib/httpx/response.rb
|
230
239
|
- lib/httpx/selector.rb
|
231
240
|
- lib/httpx/session.rb
|
232
241
|
- lib/httpx/session2.rb
|
242
|
+
- lib/httpx/session_extensions.rb
|
233
243
|
- lib/httpx/timers.rb
|
234
244
|
- lib/httpx/transcoder.rb
|
235
245
|
- lib/httpx/transcoder/body.rb
|
@@ -286,8 +296,9 @@ files:
|
|
286
296
|
- sig/request.rbs
|
287
297
|
- sig/resolver.rbs
|
288
298
|
- sig/resolver/https.rbs
|
299
|
+
- sig/resolver/multi.rbs
|
289
300
|
- sig/resolver/native.rbs
|
290
|
-
- sig/resolver/
|
301
|
+
- sig/resolver/resolver.rbs
|
291
302
|
- sig/resolver/system.rbs
|
292
303
|
- sig/response.rbs
|
293
304
|
- sig/selector.rbs
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "resolv"
|
4
|
-
require "ipaddr"
|
5
|
-
|
6
|
-
module HTTPX
|
7
|
-
module Resolver
|
8
|
-
module ResolverMixin
|
9
|
-
include Callbacks
|
10
|
-
include Loggable
|
11
|
-
|
12
|
-
CHECK_IF_IP = lambda do |name|
|
13
|
-
begin
|
14
|
-
IPAddr.new(name)
|
15
|
-
true
|
16
|
-
rescue ArgumentError
|
17
|
-
false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def uncache(connection)
|
22
|
-
hostname = hostname || @queries.key(connection) || connection.origin.host
|
23
|
-
Resolver.uncache(hostname)
|
24
|
-
@_record_types[hostname].shift
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def emit_addresses(connection, addresses)
|
30
|
-
addresses.map! do |address|
|
31
|
-
address.is_a?(IPAddr) ? address : IPAddr.new(address.to_s)
|
32
|
-
end
|
33
|
-
log { "resolver: answer #{connection.origin.host}: #{addresses.inspect}" }
|
34
|
-
connection.addresses = addresses
|
35
|
-
catch(:coalesced) { emit(:resolve, connection) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def early_resolve(connection, hostname: connection.origin.host)
|
39
|
-
addresses = connection.addresses ||
|
40
|
-
ip_resolve(hostname) ||
|
41
|
-
(@resolver_options[:cache] && Resolver.cached_lookup(hostname)) ||
|
42
|
-
system_resolve(hostname)
|
43
|
-
return unless addresses
|
44
|
-
|
45
|
-
emit_addresses(connection, addresses)
|
46
|
-
end
|
47
|
-
|
48
|
-
def ip_resolve(hostname)
|
49
|
-
[hostname] if CHECK_IF_IP[hostname]
|
50
|
-
end
|
51
|
-
|
52
|
-
def system_resolve(hostname)
|
53
|
-
@system_resolver ||= Resolv::Hosts.new
|
54
|
-
ips = @system_resolver.getaddresses(hostname)
|
55
|
-
return if ips.empty?
|
56
|
-
|
57
|
-
ips.map { |ip| IPAddr.new(ip) }
|
58
|
-
rescue IOError
|
59
|
-
end
|
60
|
-
|
61
|
-
def emit_resolve_error(connection, hostname = connection.origin.host, ex = nil)
|
62
|
-
emit(:error, connection, resolve_error(hostname, ex))
|
63
|
-
end
|
64
|
-
|
65
|
-
def resolve_error(hostname, ex = nil)
|
66
|
-
return ex if ex.is_a?(ResolveError)
|
67
|
-
|
68
|
-
message = ex ? ex.message : "Can't resolve #{hostname}"
|
69
|
-
error = ResolveError.new(message)
|
70
|
-
error.set_backtrace(ex ? ex.backtrace : caller)
|
71
|
-
error
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|