httpx 0.14.1 → 0.15.0
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/doc/release_notes/0_13_2.md +1 -1
- data/doc/release_notes/0_14_1.md +1 -1
- data/doc/release_notes/0_14_2.md +6 -0
- data/doc/release_notes/0_14_3.md +5 -0
- data/doc/release_notes/0_14_4.md +5 -0
- data/doc/release_notes/0_14_5.md +11 -0
- data/doc/release_notes/0_15_0.md +44 -0
- data/lib/httpx.rb +1 -0
- data/lib/httpx/connection.rb +14 -3
- data/lib/httpx/connection/http1.rb +15 -2
- data/lib/httpx/connection/http2.rb +14 -0
- data/lib/httpx/domain_name.rb +0 -290
- data/lib/httpx/errors.rb +2 -0
- data/lib/httpx/extensions.rb +1 -1
- data/lib/httpx/options.rb +2 -0
- data/lib/httpx/plugins/digest_authentication.rb +19 -21
- data/lib/httpx/plugins/grpc.rb +1 -1
- data/lib/httpx/plugins/grpc/call.rb +1 -2
- data/lib/httpx/plugins/multipart/part.rb +1 -1
- data/lib/httpx/plugins/ntlm_authentication.rb +66 -0
- data/lib/httpx/plugins/proxy/socks4.rb +4 -0
- data/lib/httpx/plugins/proxy/socks5.rb +4 -0
- data/lib/httpx/pmatch_extensions.rb +33 -0
- data/lib/httpx/punycode.rb +304 -0
- data/lib/httpx/request.rb +1 -1
- data/lib/httpx/response.rb +2 -0
- data/lib/httpx/selector.rb +31 -31
- data/lib/httpx/utils.rb +6 -4
- data/lib/httpx/version.rb +1 -1
- data/sig/chainable.rbs +5 -0
- data/sig/connection/http1.rbs +2 -0
- data/sig/connection/http2.rbs +2 -0
- data/sig/options.rbs +1 -1
- data/sig/plugins/aws_sdk_authentication.rbs +2 -0
- data/sig/plugins/basic_authentication.rbs +1 -1
- data/sig/plugins/digest_authentication.rbs +1 -1
- data/sig/plugins/follow_redirects.rbs +1 -1
- data/sig/plugins/grpc.rbs +93 -0
- data/sig/plugins/multipart.rbs +2 -2
- data/sig/plugins/ntlm_authentication.rbs +27 -0
- data/sig/plugins/proxy/socks4.rbs +1 -0
- data/sig/plugins/proxy/socks5.rbs +1 -0
- data/sig/utils.rbs +7 -0
- metadata +18 -2
data/lib/httpx/request.rb
CHANGED
@@ -45,7 +45,7 @@ module HTTPX
|
|
45
45
|
def initialize(verb, uri, options = {})
|
46
46
|
@verb = verb.to_s.downcase.to_sym
|
47
47
|
@options = Options.new(options)
|
48
|
-
@uri = Utils.
|
48
|
+
@uri = Utils.to_uri(uri)
|
49
49
|
if @uri.relative?
|
50
50
|
raise(Error, "invalid URI: #{@uri}") unless @options.origin
|
51
51
|
|
data/lib/httpx/response.rb
CHANGED
data/lib/httpx/selector.rb
CHANGED
@@ -52,41 +52,41 @@ class HTTPX::Selector
|
|
52
52
|
# first, we group IOs based on interest type. On call to #interests however,
|
53
53
|
# things might already happen, and new IOs might be registered, so we might
|
54
54
|
# have to start all over again. We do this until we group all selectables
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@selectables
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
55
|
+
begin
|
56
|
+
loop do
|
57
|
+
begin
|
58
|
+
r = nil
|
59
|
+
w = nil
|
60
|
+
|
61
|
+
selectables = @selectables
|
62
|
+
@selectables = []
|
63
|
+
|
64
|
+
selectables.each do |io|
|
65
|
+
interests = io.interests
|
66
|
+
|
67
|
+
(r ||= []) << io if READ_INTERESTS.include?(interests)
|
68
|
+
(w ||= []) << io if WRITE_INTERESTS.include?(interests)
|
69
|
+
end
|
70
|
+
|
71
|
+
if @selectables.empty?
|
72
|
+
@selectables = selectables
|
73
|
+
|
74
|
+
# do not run event loop if there's nothing to wait on.
|
75
|
+
# this might happen if connect failed and connection was unregistered.
|
76
|
+
return if (!r || r.empty?) && (!w || w.empty?)
|
77
|
+
|
78
|
+
break
|
79
|
+
else
|
80
|
+
@selectables = [*selectables, @selectables]
|
81
|
+
end
|
82
|
+
rescue StandardError
|
83
|
+
@selectables = selectables if selectables
|
84
|
+
raise
|
80
85
|
end
|
81
|
-
rescue StandardError
|
82
|
-
@selectables = selectables if selectables
|
83
|
-
raise
|
84
86
|
end
|
85
|
-
end
|
86
87
|
|
87
|
-
|
88
|
+
# TODO: what to do if there are no selectables?
|
88
89
|
|
89
|
-
begin
|
90
90
|
readers, writers = IO.select(r, w, nil, interval)
|
91
91
|
|
92
92
|
raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil?
|
data/lib/httpx/utils.rb
CHANGED
@@ -18,14 +18,16 @@ module HTTPX
|
|
18
18
|
end
|
19
19
|
|
20
20
|
if RUBY_VERSION < "2.3"
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
def to_uri(uri)
|
23
|
+
URI(uri)
|
23
24
|
end
|
25
|
+
|
24
26
|
else
|
25
27
|
|
26
28
|
URIParser = URI::RFC2396_Parser.new
|
27
29
|
|
28
|
-
def
|
30
|
+
def to_uri(uri)
|
29
31
|
return Kernel.URI(uri) unless uri.is_a?(String) && !uri.ascii_only?
|
30
32
|
|
31
33
|
uri = Kernel.URI(URIParser.escape(uri))
|
@@ -34,7 +36,7 @@ module HTTPX
|
|
34
36
|
|
35
37
|
non_ascii_hostname.force_encoding(Encoding::UTF_8)
|
36
38
|
|
37
|
-
idna_hostname =
|
39
|
+
idna_hostname = Punycode.encode_hostname(non_ascii_hostname)
|
38
40
|
|
39
41
|
uri.host = idna_hostname
|
40
42
|
uri.non_ascii_hostname = non_ascii_hostname
|
data/lib/httpx/version.rb
CHANGED
data/sig/chainable.rbs
CHANGED
@@ -14,6 +14,8 @@ module HTTPX
|
|
14
14
|
def plugin: (:authentication) -> Plugins::sessionAuthentication
|
15
15
|
| (:basic_authentication) -> Plugins::sessionBasicAuthentication
|
16
16
|
| (:digest_authentication) -> Plugins::sessionDigestAuthentication
|
17
|
+
| (:ntlm_authentication) -> Plugins::sessionNTLMAuthentication
|
18
|
+
| (:aws_sdk_authentication) -> Plugins::sessionAwsSdkAuthentication
|
17
19
|
| (:compression) -> Session
|
18
20
|
| (:cookies) -> Plugins::sessionCookies
|
19
21
|
| (:expect) -> Session
|
@@ -25,7 +27,10 @@ module HTTPX
|
|
25
27
|
| (:proxy) -> Plugins::sessionProxy
|
26
28
|
| (:push_promise) -> Plugins::sessionPushPromise
|
27
29
|
| (:retries) -> Plugins::sessionRetries
|
30
|
+
| (:rate_limiter) -> Session
|
28
31
|
| (:stream) -> Plugins::sessionStream
|
32
|
+
| (:aws_sigv4) -> Plugins::awsSigV4Session
|
33
|
+
| (:grpc) -> Plugins::grpcSession
|
29
34
|
| (Symbol | Module, ?options?) { (Class) -> void } -> Session
|
30
35
|
| (Symbol | Module, ?options?) -> Session
|
31
36
|
|
data/sig/connection/http1.rbs
CHANGED
data/sig/connection/http2.rbs
CHANGED
data/sig/options.rbs
CHANGED
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
WINDOW_SIZE: Integer
|
6
6
|
MAX_BODY_THRESHOLD_SIZE: Integer
|
7
7
|
|
8
|
-
type timeout_type = :connect_timeout
|
8
|
+
type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout
|
9
9
|
type timeout = Hash[timeout_type, Numeric?]
|
10
10
|
|
11
11
|
def self.new: (options) -> instance
|
@@ -10,6 +10,6 @@ module HTTPX
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::
|
13
|
+
type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::BasicAuthentication::InstanceMethods
|
14
14
|
end
|
15
15
|
end
|
@@ -27,6 +27,6 @@ module HTTPX
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::
|
30
|
+
type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::DigestAuthentication::InstanceMethods
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module HTTPX
|
2
|
+
class GRPCError < Error
|
3
|
+
attr_reader status: Integer
|
4
|
+
attr_reader details: String
|
5
|
+
attr_reader metadata: headers
|
6
|
+
end
|
7
|
+
|
8
|
+
module Plugins
|
9
|
+
module GRPC
|
10
|
+
type compression_option = bool | String
|
11
|
+
type rpc_def = [String, untyped, untyped, Hash[Symbol, untyped]]
|
12
|
+
|
13
|
+
type grpc_message = String | _Each[String]
|
14
|
+
|
15
|
+
type grpc_request = untyped | _Each[untyped]
|
16
|
+
type grpc_response = untyped | _Each[untyped]
|
17
|
+
|
18
|
+
class Call
|
19
|
+
attr_writer decoder: _Callable
|
20
|
+
|
21
|
+
def metadata: () -> headers
|
22
|
+
|
23
|
+
def trailing_metadata: () -> headers?
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def initialize: (Response | StreamResponse response) -> untyped
|
28
|
+
|
29
|
+
def grpc_response: () -> grpc_response
|
30
|
+
end
|
31
|
+
|
32
|
+
module Message
|
33
|
+
def self?.unary: (response) -> grpc_message
|
34
|
+
|
35
|
+
def self?.stream: (StreamResponse) { (String) -> void } -> void
|
36
|
+
| (StreamResponse) -> Enumerable[String]
|
37
|
+
|
38
|
+
def self?.encode: (String bytes, ?deflater: Compression::_Deflater?) -> String
|
39
|
+
|
40
|
+
def self?.decode: (String message, encodings: Array[String], encoders: Compression::encodings_registry) -> String
|
41
|
+
| (String message, encodings: Array[String], encoders: Compression::encodings_registry) { (String) -> void } -> void
|
42
|
+
|
43
|
+
def self?.cancel: (Request) -> void
|
44
|
+
|
45
|
+
def self?.verify_status: (StreamResponse | response) -> void
|
46
|
+
end
|
47
|
+
|
48
|
+
interface _GRPCOptions
|
49
|
+
def grpc_service: () -> String?
|
50
|
+
def grpc_service=: (string) -> String
|
51
|
+
|
52
|
+
def grpc_compression: () -> compression_option?
|
53
|
+
def grpc_compression=: (compression_option) -> compression_option
|
54
|
+
|
55
|
+
def grpc_rpcs: () -> Hash[String, rpc_def]?
|
56
|
+
def grpc_rpcs=: (Hash[String, rpc_def]) -> Hash[String, rpc_def]
|
57
|
+
|
58
|
+
def grpc_deadline: () -> Integer?
|
59
|
+
def grpc_deadline=: (Integer) -> Integer
|
60
|
+
|
61
|
+
def call_credentials: () -> credentials?
|
62
|
+
def call_credentials=: (credentials) -> credentials
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.extra_options: (Options) -> (Options & _GRPCOptions)
|
66
|
+
def self.load_dependencies: (singleton(Session)) -> void
|
67
|
+
|
68
|
+
module ResponseMethods
|
69
|
+
def merge_headers: (headers_input trailers) -> void
|
70
|
+
|
71
|
+
def encoders: () -> Compression::encodings_registry
|
72
|
+
end
|
73
|
+
|
74
|
+
module InstanceMethods
|
75
|
+
def with_channel_credentials: (String ca_path, ?String? key, ?String? cert, **untyped) -> instance
|
76
|
+
|
77
|
+
def rpc: (_ToS rpc_name, untyped input, untyped output, **untyped) -> instance
|
78
|
+
|
79
|
+
def build_stub: (string origin, ?service: _ToS, ?compression: compression_option) -> instance
|
80
|
+
|
81
|
+
def execute: (_ToS rpc_method, grpc_message input, ?deadline: Integer, ?metadata: headers_input, **untyped) -> Call
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def rpc_execute: (_ToS rpc_method, grpc_request input, **untyped) -> Call
|
86
|
+
|
87
|
+
def build_grpc_request: (string rpc_method, grpc_message input, ?deadline: Integer, ?metadata?: headers_input, **untyped) -> Request
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
type grpcSession = Session & Plugins::GRPC::InstanceMethods
|
92
|
+
end
|
93
|
+
end
|
data/sig/plugins/multipart.rbs
CHANGED
@@ -23,7 +23,7 @@ module HTTPX
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def initialize: (
|
26
|
+
def initialize: (_Each[Symbol | string, multipart_nested_value] multipart_data) -> untyped
|
27
27
|
|
28
28
|
def header_part: (string key, String content_type, String? filename) -> StringIO
|
29
29
|
|
@@ -33,7 +33,7 @@ module HTTPX
|
|
33
33
|
end
|
34
34
|
|
35
35
|
module Part
|
36
|
-
def self?.call: (multipart_nested_value) -> ([_Reader, String, String?]
|
36
|
+
def self?.call: (multipart_nested_value) -> ([_Reader, String, String?])
|
37
37
|
end
|
38
38
|
|
39
39
|
module MimeTypeDetector
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module HTTPX
|
2
|
+
module Plugins
|
3
|
+
module NTLMAuthentication
|
4
|
+
|
5
|
+
interface _NTLMOptions
|
6
|
+
def ntlm: () -> NTLMParams?
|
7
|
+
def ntlm=: (NTLMParams) -> NTLMParams
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.extra_options: (Options) -> (Options & _NTLMOptions)
|
11
|
+
|
12
|
+
def self.load_dependencies: (*untyped) -> void
|
13
|
+
|
14
|
+
module InstanceMethods
|
15
|
+
def ntlm_authentication: (string user, string password, ?string? domain) -> instance
|
16
|
+
end
|
17
|
+
|
18
|
+
class NTLMParams
|
19
|
+
attr_reader user: String
|
20
|
+
attr_reader password: String
|
21
|
+
attr_reader domain: String?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
type sessionNTLMAuthentication = Plugins::sessionAuthentication & Plugins::NTLMAuthentication::InstanceMethods
|
26
|
+
end
|
27
|
+
end
|
data/sig/utils.rbs
ADDED
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.15.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: 2021-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -64,6 +64,11 @@ extra_rdoc_files:
|
|
64
64
|
- doc/release_notes/0_13_2.md
|
65
65
|
- doc/release_notes/0_14_0.md
|
66
66
|
- doc/release_notes/0_14_1.md
|
67
|
+
- doc/release_notes/0_14_2.md
|
68
|
+
- doc/release_notes/0_14_3.md
|
69
|
+
- doc/release_notes/0_14_4.md
|
70
|
+
- doc/release_notes/0_14_5.md
|
71
|
+
- doc/release_notes/0_15_0.md
|
67
72
|
- doc/release_notes/0_1_0.md
|
68
73
|
- doc/release_notes/0_2_0.md
|
69
74
|
- doc/release_notes/0_2_1.md
|
@@ -107,6 +112,11 @@ files:
|
|
107
112
|
- doc/release_notes/0_13_2.md
|
108
113
|
- doc/release_notes/0_14_0.md
|
109
114
|
- doc/release_notes/0_14_1.md
|
115
|
+
- doc/release_notes/0_14_2.md
|
116
|
+
- doc/release_notes/0_14_3.md
|
117
|
+
- doc/release_notes/0_14_4.md
|
118
|
+
- doc/release_notes/0_14_5.md
|
119
|
+
- doc/release_notes/0_15_0.md
|
110
120
|
- doc/release_notes/0_1_0.md
|
111
121
|
- doc/release_notes/0_2_0.md
|
112
122
|
- doc/release_notes/0_2_1.md
|
@@ -180,6 +190,7 @@ files:
|
|
180
190
|
- lib/httpx/plugins/multipart/encoder.rb
|
181
191
|
- lib/httpx/plugins/multipart/mime_type_detector.rb
|
182
192
|
- lib/httpx/plugins/multipart/part.rb
|
193
|
+
- lib/httpx/plugins/ntlm_authentication.rb
|
183
194
|
- lib/httpx/plugins/persistent.rb
|
184
195
|
- lib/httpx/plugins/proxy.rb
|
185
196
|
- lib/httpx/plugins/proxy/http.rb
|
@@ -192,7 +203,9 @@ files:
|
|
192
203
|
- lib/httpx/plugins/stream.rb
|
193
204
|
- lib/httpx/plugins/upgrade.rb
|
194
205
|
- lib/httpx/plugins/upgrade/h2.rb
|
206
|
+
- lib/httpx/pmatch_extensions.rb
|
195
207
|
- lib/httpx/pool.rb
|
208
|
+
- lib/httpx/punycode.rb
|
196
209
|
- lib/httpx/registry.rb
|
197
210
|
- lib/httpx/request.rb
|
198
211
|
- lib/httpx/resolver.rb
|
@@ -237,8 +250,10 @@ files:
|
|
237
250
|
- sig/plugins/digest_authentication.rbs
|
238
251
|
- sig/plugins/expect.rbs
|
239
252
|
- sig/plugins/follow_redirects.rbs
|
253
|
+
- sig/plugins/grpc.rbs
|
240
254
|
- sig/plugins/h2c.rbs
|
241
255
|
- sig/plugins/multipart.rbs
|
256
|
+
- sig/plugins/ntlm_authentication.rbs
|
242
257
|
- sig/plugins/persistent.rbs
|
243
258
|
- sig/plugins/proxy.rbs
|
244
259
|
- sig/plugins/proxy/http.rbs
|
@@ -266,6 +281,7 @@ files:
|
|
266
281
|
- sig/transcoder/chunker.rbs
|
267
282
|
- sig/transcoder/form.rbs
|
268
283
|
- sig/transcoder/json.rbs
|
284
|
+
- sig/utils.rbs
|
269
285
|
homepage: https://gitlab.com/honeyryderchuck/httpx
|
270
286
|
licenses:
|
271
287
|
- Apache 2.0
|