httpx 0.18.7 → 0.19.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/doc/release_notes/0_19_0.md +39 -0
- data/doc/release_notes/0_19_1.md +5 -0
- data/doc/release_notes/0_19_2.md +7 -0
- data/doc/release_notes/0_19_3.md +6 -0
- data/lib/httpx/adapters/faraday.rb +7 -3
- data/lib/httpx/connection.rb +14 -10
- data/lib/httpx/extensions.rb +16 -0
- data/lib/httpx/headers.rb +0 -2
- data/lib/httpx/io/tcp.rb +24 -5
- data/lib/httpx/options.rb +44 -11
- data/lib/httpx/plugins/cookies.rb +5 -7
- data/lib/httpx/plugins/proxy.rb +2 -5
- data/lib/httpx/plugins/retries.rb +2 -2
- 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 +24 -39
- data/lib/httpx/resolver/resolver.rb +95 -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_extensions.rb +9 -2
- 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 +2 -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 +14 -4
- data/lib/httpx/resolver/resolver_mixin.rb +0 -75
- data/sig/resolver/resolver_mixin.rbs +0 -26
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -70,6 +70,10 @@ extra_rdoc_files:
|
|
70
70
|
- doc/release_notes/0_18_5.md
|
71
71
|
- doc/release_notes/0_18_6.md
|
72
72
|
- doc/release_notes/0_18_7.md
|
73
|
+
- doc/release_notes/0_19_0.md
|
74
|
+
- doc/release_notes/0_19_1.md
|
75
|
+
- doc/release_notes/0_19_2.md
|
76
|
+
- doc/release_notes/0_19_3.md
|
73
77
|
- doc/release_notes/0_1_0.md
|
74
78
|
- doc/release_notes/0_2_0.md
|
75
79
|
- doc/release_notes/0_2_1.md
|
@@ -133,6 +137,10 @@ files:
|
|
133
137
|
- doc/release_notes/0_18_5.md
|
134
138
|
- doc/release_notes/0_18_6.md
|
135
139
|
- doc/release_notes/0_18_7.md
|
140
|
+
- doc/release_notes/0_19_0.md
|
141
|
+
- doc/release_notes/0_19_1.md
|
142
|
+
- doc/release_notes/0_19_2.md
|
143
|
+
- doc/release_notes/0_19_3.md
|
136
144
|
- doc/release_notes/0_1_0.md
|
137
145
|
- doc/release_notes/0_2_0.md
|
138
146
|
- doc/release_notes/0_2_1.md
|
@@ -229,8 +237,9 @@ files:
|
|
229
237
|
- lib/httpx/request.rb
|
230
238
|
- lib/httpx/resolver.rb
|
231
239
|
- lib/httpx/resolver/https.rb
|
240
|
+
- lib/httpx/resolver/multi.rb
|
232
241
|
- lib/httpx/resolver/native.rb
|
233
|
-
- lib/httpx/resolver/
|
242
|
+
- lib/httpx/resolver/resolver.rb
|
234
243
|
- lib/httpx/resolver/system.rb
|
235
244
|
- lib/httpx/response.rb
|
236
245
|
- lib/httpx/selector.rb
|
@@ -293,8 +302,9 @@ files:
|
|
293
302
|
- sig/request.rbs
|
294
303
|
- sig/resolver.rbs
|
295
304
|
- sig/resolver/https.rbs
|
305
|
+
- sig/resolver/multi.rbs
|
296
306
|
- sig/resolver/native.rbs
|
297
|
-
- sig/resolver/
|
307
|
+
- sig/resolver/resolver.rbs
|
298
308
|
- sig/resolver/system.rbs
|
299
309
|
- sig/response.rbs
|
300
310
|
- 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
|
-
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
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module HTTPX
|
2
|
-
module Resolver
|
3
|
-
module ResolverMixin
|
4
|
-
include Callbacks
|
5
|
-
include Loggable
|
6
|
-
|
7
|
-
CHECK_IF_IP: ^(String name) -> bool
|
8
|
-
|
9
|
-
def uncache: (Connection) -> void
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def emit_addresses: (Connection, Array[ipaddr]) -> void
|
14
|
-
|
15
|
-
def early_resolve: (Connection, ?hostname: String) -> void
|
16
|
-
|
17
|
-
def ip_resolve: (String hostname) -> Array[ipaddr]?
|
18
|
-
|
19
|
-
def system_resolve: (String hostname) -> Array[ipaddr]?
|
20
|
-
|
21
|
-
def emit_resolve_error: (Connection, ?String hostname, ?StandardError) -> void
|
22
|
-
|
23
|
-
def resolve_error: (String hostname, ?StandardError?) -> void
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|