httpx 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_15_2.md +9 -0
  3. data/doc/release_notes/0_15_3.md +5 -0
  4. data/doc/release_notes/0_15_4.md +5 -0
  5. data/doc/release_notes/0_16_0.md +93 -0
  6. data/lib/httpx.rb +6 -3
  7. data/lib/httpx/adapters/faraday.rb +3 -11
  8. data/lib/httpx/buffer.rb +1 -1
  9. data/lib/httpx/callbacks.rb +1 -1
  10. data/lib/httpx/chainable.rb +15 -8
  11. data/lib/httpx/connection.rb +2 -2
  12. data/lib/httpx/connection/http1.rb +3 -1
  13. data/lib/httpx/connection/http2.rb +1 -11
  14. data/lib/httpx/errors.rb +11 -11
  15. data/lib/httpx/io/ssl.rb +2 -2
  16. data/lib/httpx/io/tls.rb +1 -1
  17. data/lib/httpx/loggable.rb +1 -1
  18. data/lib/httpx/options.rb +81 -74
  19. data/lib/httpx/parser/http1.rb +1 -1
  20. data/lib/httpx/plugins/aws_sigv4.rb +10 -9
  21. data/lib/httpx/plugins/compression.rb +12 -11
  22. data/lib/httpx/plugins/cookies.rb +20 -7
  23. data/lib/httpx/plugins/cookies/cookie.rb +4 -3
  24. data/lib/httpx/plugins/cookies/jar.rb +24 -1
  25. data/lib/httpx/plugins/digest_authentication.rb +15 -11
  26. data/lib/httpx/plugins/expect.rb +19 -15
  27. data/lib/httpx/plugins/follow_redirects.rb +9 -9
  28. data/lib/httpx/plugins/grpc.rb +73 -47
  29. data/lib/httpx/plugins/grpc/call.rb +4 -1
  30. data/lib/httpx/plugins/ntlm_authentication.rb +8 -6
  31. data/lib/httpx/plugins/proxy.rb +4 -6
  32. data/lib/httpx/plugins/proxy/socks4.rb +2 -1
  33. data/lib/httpx/plugins/proxy/socks5.rb +2 -1
  34. data/lib/httpx/plugins/proxy/ssh.rb +9 -9
  35. data/lib/httpx/plugins/retries.rb +25 -21
  36. data/lib/httpx/plugins/upgrade.rb +7 -6
  37. data/lib/httpx/registry.rb +1 -1
  38. data/lib/httpx/request.rb +4 -12
  39. data/lib/httpx/resolver/https.rb +0 -2
  40. data/lib/httpx/response.rb +45 -18
  41. data/lib/httpx/selector.rb +13 -12
  42. data/lib/httpx/session.rb +19 -8
  43. data/lib/httpx/session2.rb +21 -0
  44. data/lib/httpx/transcoder/body.rb +1 -1
  45. data/lib/httpx/transcoder/chunker.rb +2 -1
  46. data/lib/httpx/version.rb +1 -1
  47. data/sig/buffer.rbs +2 -0
  48. data/sig/chainable.rbs +24 -28
  49. data/sig/connection.rbs +20 -8
  50. data/sig/connection/http1.rbs +3 -3
  51. data/sig/connection/http2.rbs +1 -1
  52. data/sig/errors.rbs +35 -1
  53. data/sig/headers.rbs +5 -5
  54. data/sig/httpx.rbs +4 -1
  55. data/sig/loggable.rbs +3 -1
  56. data/sig/options.rbs +35 -32
  57. data/sig/plugins/authentication.rbs +1 -1
  58. data/sig/plugins/aws_sdk_authentication.rbs +5 -1
  59. data/sig/plugins/aws_sigv4.rbs +1 -2
  60. data/sig/plugins/basic_authentication.rbs +1 -1
  61. data/sig/plugins/compression.rbs +4 -6
  62. data/sig/plugins/cookies.rbs +4 -5
  63. data/sig/plugins/cookies/cookie.rbs +5 -7
  64. data/sig/plugins/cookies/jar.rbs +9 -10
  65. data/sig/plugins/digest_authentication.rbs +2 -3
  66. data/sig/plugins/expect.rbs +2 -4
  67. data/sig/plugins/follow_redirects.rbs +3 -5
  68. data/sig/plugins/grpc.rbs +4 -7
  69. data/sig/plugins/h2c.rbs +0 -2
  70. data/sig/plugins/multipart.rbs +2 -4
  71. data/sig/plugins/ntlm_authentication.rbs +2 -3
  72. data/sig/plugins/persistent.rbs +3 -8
  73. data/sig/plugins/proxy.rbs +7 -7
  74. data/sig/plugins/proxy/ssh.rbs +4 -4
  75. data/sig/plugins/push_promise.rbs +0 -2
  76. data/sig/plugins/retries.rbs +4 -8
  77. data/sig/plugins/stream.rbs +1 -1
  78. data/sig/plugins/upgrade.rbs +2 -3
  79. data/sig/pool.rbs +1 -2
  80. data/sig/registry.rbs +1 -1
  81. data/sig/request.rbs +2 -2
  82. data/sig/resolver.rbs +7 -0
  83. data/sig/resolver/native.rbs +9 -5
  84. data/sig/resolver/resolver_mixin.rbs +4 -5
  85. data/sig/resolver/system.rbs +2 -0
  86. data/sig/response.rbs +17 -11
  87. data/sig/selector.rbs +7 -6
  88. data/sig/session.rbs +19 -14
  89. data/sig/transcoder.rbs +11 -4
  90. data/sig/transcoder/body.rbs +6 -1
  91. data/sig/transcoder/chunker.rbs +8 -2
  92. data/sig/transcoder/form.rbs +2 -1
  93. data/sig/transcoder/json.rbs +1 -0
  94. data/sig/utils.rbs +2 -0
  95. metadata +12 -2
@@ -6,6 +6,6 @@ module HTTPX
6
6
  end
7
7
  end
8
8
 
9
- type sessionAuthentication = Session & Plugins::Authentication::InstanceMethods
9
+ type sessionAuthentication = Session & Authentication::InstanceMethods
10
10
  end
11
11
  end
@@ -3,6 +3,10 @@ module HTTPX
3
3
  module AwsSdkAuthentication
4
4
  class Credentials
5
5
  include _SigV4Credentials
6
+
7
+ private
8
+
9
+ def initialize: (untyped aws_credentials) -> untyped
6
10
  end
7
11
 
8
12
  def self.load_dependencies: (singleton(Session)) -> void
@@ -16,6 +20,6 @@ module HTTPX
16
20
  end
17
21
  end
18
22
 
19
- type sessionAwsSdkAuthentication = Session & Plugins::AwsSdkAuthentication::InstanceMethods
23
+ type sessionAwsSdkAuthentication = Session & AwsSdkAuthentication::InstanceMethods
20
24
  end
21
25
  end
@@ -42,7 +42,6 @@ module HTTPX
42
42
 
43
43
  interface _SigV4Options
44
44
  def sigv4_signer: () -> Signer?
45
- def sigv4_signer=: (Signer) -> Signer
46
45
  end
47
46
 
48
47
  def self.extra_options: (Options) -> (Options & _SigV4Options)
@@ -59,6 +58,6 @@ module HTTPX
59
58
  end
60
59
  end
61
60
 
62
- type awsSigV4Session = Session & Plugins::AWSSigV4::InstanceMethods
61
+ type awsSigV4Session = Session & AWSSigV4::InstanceMethods
63
62
  end
64
63
  end
@@ -10,6 +10,6 @@ module HTTPX
10
10
  end
11
11
  end
12
12
 
13
- type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::BasicAuthentication::InstanceMethods
13
+ type sessionBasicAuthentication = sessionAuthentication & BasicAuthentication::InstanceMethods
14
14
  end
15
15
  end
@@ -15,23 +15,21 @@ module HTTPX
15
15
 
16
16
  def initialize: (Numeric bytesize) -> untyped
17
17
  end
18
-
18
+
19
19
  def self.configure: (singleton(Session)) -> void
20
20
 
21
21
  interface _CompressionOptions
22
- def compression_threshold_size: () -> _Integer?
23
- def compression_threshold_size=: (int) -> int
22
+ def compression_threshold_size: () -> Integer?
24
23
 
25
24
  def encodings: () -> encodings_registry?
26
- def encodings=: (encodings_registry) -> encodings_registry
27
25
  end
28
-
26
+
29
27
  def self.extra_options: (Options) -> (Options & _CompressionOptions)
30
28
 
31
29
 
32
30
  module ResponseBodyMethods
33
31
  @encodings: Array[String]
34
- @_deflaters: Array[_Decoder]
32
+ @_deflaters: Array[_Deflater]
35
33
 
36
34
  private
37
35
 
@@ -1,13 +1,12 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Cookies
4
- type jar = Jar | _Each[cookies]
4
+ type jar = Jar | _Each[Jar::cookie]
5
5
 
6
6
  interface _CookieOptions
7
7
  def cookies: () -> Jar?
8
- def cookies=: (jar) -> Jar
9
8
  end
10
-
9
+
11
10
  def self.extra_options: (Options) -> (Options & _CookieOptions)
12
11
 
13
12
  module InstanceMethods
@@ -19,7 +18,7 @@ module HTTPX
19
18
  end
20
19
  end
21
20
 
22
- type sessionCookies = Session & Plugins::Cookies::InstanceMethods
23
- type headersCookies = Headers & Plugins::Cookies::HeadersMethods
21
+ type sessionCookies = Session & Cookies::InstanceMethods
22
+ type headersCookies = Headers & Cookies::HeadersMethods
24
23
  end
25
24
  end
@@ -31,19 +31,17 @@ module HTTPX
31
31
 
32
32
  def valid_for_uri?: (uri) -> bool
33
33
 
34
- def self.new: (Cookie) -> untyped
35
- | (cookie_attributes) -> untyped
36
- | (String, String) -> untyped
37
- | (String, String, cookie_attributes) -> untyped
34
+ def self.new: (Cookie) -> instance
35
+ | (cookie_attributes) -> instance
36
+ | (_ToS, _ToS, ?cookie_attributes) -> instance
38
37
 
39
38
  def self.path_match?: (String, String) -> bool
40
39
 
41
40
  private
42
41
 
43
42
  def initialize: (cookie_attributes) -> untyped
44
- | (String, String) -> untyped
45
- | (String, String, cookie_attributes?) -> untyped
46
-
43
+ | (_ToS, _ToS, ?cookie_attributes) -> untyped
44
+
47
45
  def acceptable_from_uri?: (uri) -> bool
48
46
  end
49
47
  end
@@ -1,27 +1,26 @@
1
1
  module HTTPX
2
2
  module Plugins::Cookies
3
3
  class Jar
4
- type cookie = Cookie | Array[String, String, cookie_attributes] | Array[String, String] | cookie_attributes
4
+ type cookie = Cookie | Array[[String, String, cookie_attributes]] | Array[[String, String]] | cookie_attributes
5
5
 
6
6
  include Enumerable[Cookie]
7
7
 
8
8
  @cookies: Array[Cookie]
9
9
 
10
- def parse: (String) -> void
10
+ def parse: (String set_cookie) -> void
11
11
 
12
- def add: (Cookie) -> void
13
- | (Cookie, String) -> void
12
+ def add: (Cookie name, ?String path) -> void
14
13
 
15
14
  def []: (uri) -> Array[Cookie]
16
15
 
17
- def each: (uri) { (Cookie) -> void } -> void
18
- | (uri) -> Enumerable[Cookie]
19
- | () { (Cookie) -> void } -> void
20
- | () -> Enumerable[Cookie]
16
+ def each: (?uri) { (Cookie) -> void } -> void
17
+ | (?uri) -> Enumerable[Cookie]
18
+
19
+ def merge: (_Each[cookie] cookies) -> instance
20
+
21
21
  private
22
22
 
23
- def initialize: () -> void
24
- | (_Each[cookie]) -> untyped
23
+ def initialize: (?_Each[cookie] cookies) -> untyped
25
24
  end
26
25
  end
27
26
  end
@@ -5,9 +5,8 @@ module HTTPX
5
5
 
6
6
  interface _DigestOptions
7
7
  def digest: () -> Digest?
8
- def digest=: (Digest) -> Digest
9
8
  end
10
-
9
+
11
10
  def self.extra_options: (Options) -> (Options & _DigestOptions)
12
11
 
13
12
  def self.load_dependencies: (*untyped) -> void
@@ -27,6 +26,6 @@ module HTTPX
27
26
  end
28
27
  end
29
28
 
30
- type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::DigestAuthentication::InstanceMethods
29
+ type sessionDigestAuthentication = sessionAuthentication & DigestAuthentication::InstanceMethods
31
30
  end
32
31
  end
@@ -2,15 +2,13 @@ module HTTPX
2
2
  module Plugins
3
3
  module Expect
4
4
  EXPECT_TIMEOUT: Integer
5
-
5
+
6
6
  interface _ExpectOptions
7
7
  def expect_timeout: () -> Integer?
8
- def expect_timeout=: (int) -> Integer
9
8
 
10
9
  def expect_threshold_size: () -> Integer?
11
- def expect_threshold_size=: (int) -> Integer
12
10
  end
13
-
11
+
14
12
  def self.extra_options: (Options) -> (Options & _ExpectOptions)
15
13
  end
16
14
  end
@@ -5,15 +5,13 @@ module HTTPX
5
5
  module FollowRedirects
6
6
  MAX_REDIRECTS: Integer
7
7
  REDIRECT_STATUS: Range[Integer]
8
-
8
+
9
9
  interface _FollowRedirectsOptions
10
10
  def max_redirects: () -> Integer?
11
- def max_redirects=: (int) -> Integer
12
11
 
13
12
  def follow_insecure_redirects: () -> bool?
14
- def follow_insecure_redirects=: (bool) -> bool
15
13
  end
16
-
14
+
17
15
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
18
16
 
19
17
  module InstanceMethods
@@ -30,6 +28,6 @@ module HTTPX
30
28
  end
31
29
  end
32
30
 
33
- type sessionFollowRedirects = Session & Plugins::FollowRedirects::InstanceMethods
31
+ type sessionFollowRedirects = Session & FollowRedirects::InstanceMethods
34
32
  end
35
33
  end
data/sig/plugins/grpc.rbs CHANGED
@@ -15,6 +15,8 @@ module HTTPX
15
15
  type grpc_request = untyped | _Each[untyped]
16
16
  type grpc_response = untyped | _Each[untyped]
17
17
 
18
+ type credentials = Proc
19
+
18
20
  class Call
19
21
  attr_writer decoder: _Callable
20
22
 
@@ -39,7 +41,7 @@ module HTTPX
39
41
 
40
42
  def self?.decode: (String message, encodings: Array[String], encoders: Compression::encodings_registry) -> String
41
43
  | (String message, encodings: Array[String], encoders: Compression::encodings_registry) { (String) -> void } -> void
42
-
44
+
43
45
  def self?.cancel: (Request) -> void
44
46
 
45
47
  def self?.verify_status: (StreamResponse | response) -> void
@@ -47,19 +49,14 @@ module HTTPX
47
49
 
48
50
  interface _GRPCOptions
49
51
  def grpc_service: () -> String?
50
- def grpc_service=: (string) -> String
51
52
 
52
53
  def grpc_compression: () -> compression_option?
53
- def grpc_compression=: (compression_option) -> compression_option
54
54
 
55
55
  def grpc_rpcs: () -> Hash[String, rpc_def]?
56
- def grpc_rpcs=: (Hash[String, rpc_def]) -> Hash[String, rpc_def]
57
56
 
58
57
  def grpc_deadline: () -> Integer?
59
- def grpc_deadline=: (Integer) -> Integer
60
58
 
61
59
  def call_credentials: () -> credentials?
62
- def call_credentials=: (credentials) -> credentials
63
60
  end
64
61
 
65
62
  def self.extra_options: (Options) -> (Options & _GRPCOptions)
@@ -88,6 +85,6 @@ module HTTPX
88
85
  end
89
86
  end
90
87
 
91
- type grpcSession = Session & Plugins::GRPC::InstanceMethods
88
+ type grpcSession = Session & GRPC::InstanceMethods
92
89
  end
93
90
  end
data/sig/plugins/h2c.rbs CHANGED
@@ -15,7 +15,5 @@ module HTTPX
15
15
  def upgrade_to_h2c: (Request, Response) -> void
16
16
  end
17
17
  end
18
-
19
- type sessionH2C = Session & Plugins::H2C::InstanceMethods
20
18
  end
21
19
  end
@@ -13,8 +13,6 @@ module HTTPX
13
13
 
14
14
  type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
15
15
 
16
- type multipart_input = Enumerable[[string, multipart_value], untyped]
17
-
18
16
  class Encoder
19
17
  include Transcoder::_Encoder
20
18
  include _Reader
@@ -23,7 +21,7 @@ module HTTPX
23
21
 
24
22
  private
25
23
 
26
- def initialize: (_Each[Symbol | string, multipart_nested_value] multipart_data) -> untyped
24
+ def initialize: (_Each[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
27
25
 
28
26
  def header_part: (string key, String content_type, String? filename) -> StringIO
29
27
 
@@ -37,7 +35,7 @@ module HTTPX
37
35
  end
38
36
 
39
37
  module MimeTypeDetector
40
- def self?.call: (IO file, ?String filename) -> String?
38
+ def self?.call: (::IO file, ?String filename) -> String?
41
39
  end
42
40
  end
43
41
  end
@@ -4,9 +4,8 @@ module HTTPX
4
4
 
5
5
  interface _NTLMOptions
6
6
  def ntlm: () -> NTLMParams?
7
- def ntlm=: (NTLMParams) -> NTLMParams
8
7
  end
9
-
8
+
10
9
  def self.extra_options: (Options) -> (Options & _NTLMOptions)
11
10
 
12
11
  def self.load_dependencies: (*untyped) -> void
@@ -22,6 +21,6 @@ module HTTPX
22
21
  end
23
22
  end
24
23
 
25
- type sessionNTLMAuthentication = Plugins::sessionAuthentication & Plugins::NTLMAuthentication::InstanceMethods
24
+ type sessionNTLMAuthentication = sessionAuthentication & NTLMAuthentication::InstanceMethods
26
25
  end
27
26
  end
@@ -2,15 +2,10 @@ module HTTPX
2
2
  module Plugins
3
3
  module Persistent
4
4
  def self.load_dependencies: (singleton(Session)) -> void
5
-
6
- interface _PersistentOptions
7
- def persistent: () -> bool?
8
- def persistent=: (bool) -> bool
9
- end
10
-
11
- def self.extra_options: (Options) -> (Options & _PersistentOptions)
5
+
6
+ def self.extra_options: (Options) -> (Options)
12
7
  end
13
-
8
+
14
9
  type sessionPersistent = sessionFollowRedirects
15
10
  end
16
11
  end
@@ -1,5 +1,6 @@
1
1
  module HTTPX
2
- HTTPProxyError: singleton(Error)
2
+ class HTTPProxyError < Error
3
+ end
3
4
 
4
5
  module Plugins
5
6
  module Proxy
@@ -22,14 +23,13 @@ module HTTPX
22
23
  end
23
24
 
24
25
  def self.configure: (singleton(Session)) -> void
25
-
26
- type proxyParam = Parameters | Hash
27
-
26
+
27
+ type proxyParam = Parameters | Hash[Symbol, untyped]
28
+
28
29
  interface _ProxyOptions
29
30
  def proxy: () -> proxyParam?
30
- def proxy=: (Parameters | _ToHash) -> proxyParam
31
31
  end
32
-
32
+
33
33
  def self.extra_options: (Options) -> (Options & _ProxyOptions)
34
34
 
35
35
  module InstanceMethods
@@ -41,6 +41,6 @@ module HTTPX
41
41
  end
42
42
  end
43
43
 
44
- type sessionProxy = Session & Plugins::Proxy::InstanceMethods
44
+ type sessionProxy = Session & Proxy::InstanceMethods
45
45
  end
46
46
  end
@@ -3,16 +3,16 @@ module HTTPX
3
3
  module Proxy
4
4
  module SSH
5
5
  def self.load_dependencies: (singleton(Session)) -> void
6
-
7
- module InstancenMethods
6
+
7
+ module InstanceMethods
8
8
  private
9
9
 
10
- def build_gateway_socket: (int, URI::HTTPS | URI::HTTPS, Options) -> IO
10
+ def build_gateway_socket: (int, URI::HTTP | URI::HTTPS, Options) -> _ToIO
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
15
 
16
- type sessionSSHProxy = Plugins::Proxy::InstanceMethods & Plugins::Proxy::SSH::InstanceMethods
16
+ type sessionSSHProxy = Proxy::InstanceMethods & Proxy::SSH::InstanceMethods
17
17
  end
18
18
  end
@@ -1,8 +1,6 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module PushPromise
4
- def self.extra_options: (Options) -> Options
5
-
6
4
  module ResponseMethods
7
5
  def pushed?: () -> boolish
8
6
  def mark_as_pushed!: () -> void
@@ -4,25 +4,21 @@ module HTTPX
4
4
  MAX_RETRIES: Integer
5
5
  IDEMPOTENT_METHODS: Array[verb]
6
6
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
7
-
7
+
8
8
  interface _RetryCallback
9
9
  def call: (response) -> bool?
10
10
  end
11
11
 
12
12
  interface _RetriesOptions
13
13
  def retry_after: () -> Numeric?
14
- def retry_after=: (Numeric) -> Numeric
15
14
 
16
15
  def max_retries: () -> Integer?
17
- def max_retries=: (int) -> Integer
18
16
 
19
- def retry_change_requests: () -> bool?
20
- def retry_change_requests=: (bool) -> bool
17
+ def retry_change_requests: () -> boolish
21
18
 
22
19
  def retry_on: () -> _RetryCallback?
23
- def retry_on=: (_RetryCallback) -> _RetryCallback
24
20
  end
25
-
21
+
26
22
  def self.extra_options: (Options) -> (Options & _RetriesOptions)
27
23
 
28
24
  module InstanceMethods
@@ -39,6 +35,6 @@ module HTTPX
39
35
  end
40
36
  end
41
37
 
42
- type sessionRetries = Session & Plugins::Retries::InstanceMethods
38
+ type sessionRetries = Session & Retries::InstanceMethods
43
39
  end
44
40
  end