httpx 0.14.3 → 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_13_2.md +1 -1
  3. data/doc/release_notes/0_14_4.md +5 -0
  4. data/doc/release_notes/0_14_5.md +11 -0
  5. data/doc/release_notes/0_15_0.md +53 -0
  6. data/doc/release_notes/0_15_1.md +8 -0
  7. data/doc/release_notes/0_15_2.md +9 -0
  8. data/lib/httpx.rb +1 -0
  9. data/lib/httpx/connection.rb +14 -3
  10. data/lib/httpx/connection/http1.rb +22 -3
  11. data/lib/httpx/connection/http2.rb +14 -0
  12. data/lib/httpx/domain_name.rb +0 -290
  13. data/lib/httpx/errors.rb +2 -0
  14. data/lib/httpx/extensions.rb +1 -1
  15. data/lib/httpx/loggable.rb +1 -1
  16. data/lib/httpx/options.rb +5 -1
  17. data/lib/httpx/plugins/cookies/cookie.rb +1 -2
  18. data/lib/httpx/plugins/cookies/jar.rb +4 -0
  19. data/lib/httpx/plugins/digest_authentication.rb +19 -21
  20. data/lib/httpx/plugins/grpc.rb +1 -1
  21. data/lib/httpx/plugins/grpc/call.rb +1 -2
  22. data/lib/httpx/plugins/ntlm_authentication.rb +66 -0
  23. data/lib/httpx/plugins/proxy/socks4.rb +4 -0
  24. data/lib/httpx/plugins/proxy/socks5.rb +4 -0
  25. data/lib/httpx/pmatch_extensions.rb +33 -0
  26. data/lib/httpx/punycode.rb +304 -0
  27. data/lib/httpx/request.rb +1 -1
  28. data/lib/httpx/response.rb +2 -0
  29. data/lib/httpx/selector.rb +41 -37
  30. data/lib/httpx/utils.rb +6 -4
  31. data/lib/httpx/version.rb +1 -1
  32. data/sig/chainable.rbs +5 -0
  33. data/sig/connection/http1.rbs +2 -0
  34. data/sig/connection/http2.rbs +2 -0
  35. data/sig/options.rbs +1 -1
  36. data/sig/plugins/aws_sdk_authentication.rbs +2 -0
  37. data/sig/plugins/basic_authentication.rbs +1 -1
  38. data/sig/plugins/digest_authentication.rbs +1 -1
  39. data/sig/plugins/follow_redirects.rbs +1 -1
  40. data/sig/plugins/grpc.rbs +93 -0
  41. data/sig/plugins/multipart.rbs +1 -1
  42. data/sig/plugins/ntlm_authentication.rbs +27 -0
  43. data/sig/plugins/proxy/socks4.rbs +1 -0
  44. data/sig/plugins/proxy/socks5.rbs +1 -0
  45. data/sig/utils.rbs +7 -0
  46. metadata +19 -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.uri(uri)
48
+ @uri = Utils.to_uri(uri)
49
49
  if @uri.relative?
50
50
  raise(Error, "invalid URI: #{@uri}") unless @options.origin
51
51
 
@@ -296,3 +296,5 @@ module HTTPX
296
296
  # rubocop:enable Style/MissingRespondToMissing
297
297
  end
298
298
  end
299
+
300
+ require "httpx/pmatch_extensions" if RUBY_VERSION >= "3.0.0"
@@ -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
- loop do
56
- begin
57
- r = nil
58
- w = nil
59
-
60
- selectables = @selectables
61
- @selectables = []
62
-
63
- selectables.each do |io|
64
- interests = io.interests
65
-
66
- (r ||= []) << io if READ_INTERESTS.include?(interests)
67
- (w ||= []) << io if WRITE_INTERESTS.include?(interests)
68
- end
69
-
70
- if @selectables.empty?
71
- @selectables = selectables
72
-
73
- # do not run event loop if there's nothing to wait on.
74
- # this might happen if connect failed and connection was unregistered.
75
- return if (!r || r.empty?) && (!w || w.empty?)
76
-
77
- break
78
- else
79
- @selectables = [*selectables, @selectables]
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
- # TODO: what to do if there are no selectables?
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?
@@ -95,14 +95,18 @@ class HTTPX::Selector
95
95
  retry
96
96
  end
97
97
 
98
- readers.each do |io|
99
- yield io
98
+ if writers
99
+ readers.each do |io|
100
+ yield io
100
101
 
101
- # so that we don't yield 2 times
102
- writers.delete(io)
103
- end if readers
102
+ # so that we don't yield 2 times
103
+ writers.delete(io)
104
+ end if readers
104
105
 
105
- writers.each(&block) if writers
106
+ writers.each(&block)
107
+ else
108
+ readers.each(&block) if readers
109
+ end
106
110
  end
107
111
 
108
112
  def select_one(interval)
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
- def uri(*args)
22
- URI(*args)
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 uri(uri)
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 = DomainName.new(non_ascii_hostname).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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "0.14.3"
4
+ VERSION = "0.15.2"
5
5
  end
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
 
@@ -42,6 +42,8 @@ module HTTPX
42
42
 
43
43
  def ping: () -> void
44
44
 
45
+ def timeout: () -> Integer
46
+
45
47
  private
46
48
 
47
49
  def initialize: (Buffer, options) -> untyped
@@ -35,6 +35,8 @@ module HTTPX
35
35
 
36
36
  alias reset init_connection
37
37
 
38
+ def timeout: () -> Integer
39
+
38
40
  private
39
41
 
40
42
  def initialize: (Buffer, options) -> untyped
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 | :operation_timeout | :keep_alive_timeout | :total_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
@@ -15,5 +15,7 @@ module HTTPX
15
15
  def aws_sdk_authentication: (**untyped) -> instance
16
16
  end
17
17
  end
18
+
19
+ type sessionAwsSdkAuthentication = Session & Plugins::AwsSdkAuthentication::InstanceMethods
18
20
  end
19
21
  end
@@ -10,6 +10,6 @@ module HTTPX
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::Authentication::InstanceMethods
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::Authentication::InstanceMethods
30
+ type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::DigestAuthentication::InstanceMethods
31
31
  end
32
32
  end
@@ -30,6 +30,6 @@ module HTTPX
30
30
  end
31
31
  end
32
32
 
33
- type sessionFollowRedirects = Session & Plugins::Authentication::InstanceMethods
33
+ type sessionFollowRedirects = Session & Plugins::FollowRedirects::InstanceMethods
34
34
  end
35
35
  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
@@ -23,7 +23,7 @@ module HTTPX
23
23
 
24
24
  private
25
25
 
26
- def initialize: (Hash[Symbol | string, multipart_nested_value] multipart_data) -> untyped
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
 
@@ -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
@@ -14,6 +14,7 @@ module HTTPX
14
14
  class SocksParser
15
15
  include Callbacks
16
16
 
17
+ def timeout: () -> Integer
17
18
  def close: () -> void
18
19
  def consume: (*untyped) -> void
19
20
  def empty: () -> bool
@@ -15,6 +15,7 @@ module HTTPX
15
15
  class SocksParser
16
16
  include Callbacks
17
17
 
18
+ def timeout: () -> Integer
18
19
  def close: () -> void
19
20
  def consume: (*untyped) -> void
20
21
  def empty: () -> bool
data/sig/utils.rbs ADDED
@@ -0,0 +1,7 @@
1
+ module HTTPX
2
+ module Utils
3
+ def self?.parse_retry_after: (String) -> Numeric
4
+
5
+ def self?.to_uri: (generic_uri uri) -> URI::Generic
6
+ end
7
+ end
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.14.3
4
+ version: 0.15.2
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-05-28 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -66,6 +66,11 @@ extra_rdoc_files:
66
66
  - doc/release_notes/0_14_1.md
67
67
  - doc/release_notes/0_14_2.md
68
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
72
+ - doc/release_notes/0_15_1.md
73
+ - doc/release_notes/0_15_2.md
69
74
  - doc/release_notes/0_1_0.md
70
75
  - doc/release_notes/0_2_0.md
71
76
  - doc/release_notes/0_2_1.md
@@ -111,6 +116,11 @@ files:
111
116
  - doc/release_notes/0_14_1.md
112
117
  - doc/release_notes/0_14_2.md
113
118
  - doc/release_notes/0_14_3.md
119
+ - doc/release_notes/0_14_4.md
120
+ - doc/release_notes/0_14_5.md
121
+ - doc/release_notes/0_15_0.md
122
+ - doc/release_notes/0_15_1.md
123
+ - doc/release_notes/0_15_2.md
114
124
  - doc/release_notes/0_1_0.md
115
125
  - doc/release_notes/0_2_0.md
116
126
  - doc/release_notes/0_2_1.md
@@ -184,6 +194,7 @@ files:
184
194
  - lib/httpx/plugins/multipart/encoder.rb
185
195
  - lib/httpx/plugins/multipart/mime_type_detector.rb
186
196
  - lib/httpx/plugins/multipart/part.rb
197
+ - lib/httpx/plugins/ntlm_authentication.rb
187
198
  - lib/httpx/plugins/persistent.rb
188
199
  - lib/httpx/plugins/proxy.rb
189
200
  - lib/httpx/plugins/proxy/http.rb
@@ -196,7 +207,9 @@ files:
196
207
  - lib/httpx/plugins/stream.rb
197
208
  - lib/httpx/plugins/upgrade.rb
198
209
  - lib/httpx/plugins/upgrade/h2.rb
210
+ - lib/httpx/pmatch_extensions.rb
199
211
  - lib/httpx/pool.rb
212
+ - lib/httpx/punycode.rb
200
213
  - lib/httpx/registry.rb
201
214
  - lib/httpx/request.rb
202
215
  - lib/httpx/resolver.rb
@@ -241,8 +254,10 @@ files:
241
254
  - sig/plugins/digest_authentication.rbs
242
255
  - sig/plugins/expect.rbs
243
256
  - sig/plugins/follow_redirects.rbs
257
+ - sig/plugins/grpc.rbs
244
258
  - sig/plugins/h2c.rbs
245
259
  - sig/plugins/multipart.rbs
260
+ - sig/plugins/ntlm_authentication.rbs
246
261
  - sig/plugins/persistent.rbs
247
262
  - sig/plugins/proxy.rbs
248
263
  - sig/plugins/proxy/http.rbs
@@ -270,6 +285,7 @@ files:
270
285
  - sig/transcoder/chunker.rbs
271
286
  - sig/transcoder/form.rbs
272
287
  - sig/transcoder/json.rbs
288
+ - sig/utils.rbs
273
289
  homepage: https://gitlab.com/honeyryderchuck/httpx
274
290
  licenses:
275
291
  - Apache 2.0
@@ -278,6 +294,7 @@ metadata:
278
294
  changelog_uri: https://honeyryderchuck.gitlab.io/httpx/#release-notes
279
295
  documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
280
296
  source_code_uri: https://gitlab.com/honeyryderchuck/httpx
297
+ homepage_uri: https://honeyryderchuck.gitlab.io/httpx/
281
298
  post_install_message:
282
299
  rdoc_options: []
283
300
  require_paths: