httpx 0.12.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_10_1.md +1 -1
  3. data/doc/release_notes/0_13_0.md +58 -0
  4. data/doc/release_notes/0_13_1.md +5 -0
  5. data/doc/release_notes/0_13_2.md +9 -0
  6. data/doc/release_notes/0_14_0.md +79 -0
  7. data/doc/release_notes/0_14_1.md +7 -0
  8. data/lib/httpx.rb +1 -2
  9. data/lib/httpx/callbacks.rb +12 -3
  10. data/lib/httpx/chainable.rb +2 -2
  11. data/lib/httpx/connection.rb +29 -22
  12. data/lib/httpx/connection/http1.rb +35 -15
  13. data/lib/httpx/connection/http2.rb +61 -15
  14. data/lib/httpx/headers.rb +7 -3
  15. data/lib/httpx/io/ssl.rb +30 -17
  16. data/lib/httpx/io/tcp.rb +48 -27
  17. data/lib/httpx/io/udp.rb +31 -7
  18. data/lib/httpx/io/unix.rb +27 -12
  19. data/lib/httpx/options.rb +97 -74
  20. data/lib/httpx/plugins/aws_sdk_authentication.rb +5 -2
  21. data/lib/httpx/plugins/aws_sigv4.rb +5 -4
  22. data/lib/httpx/plugins/basic_authentication.rb +8 -3
  23. data/lib/httpx/plugins/compression.rb +24 -12
  24. data/lib/httpx/plugins/compression/brotli.rb +10 -7
  25. data/lib/httpx/plugins/compression/deflate.rb +6 -5
  26. data/lib/httpx/plugins/compression/gzip.rb +4 -3
  27. data/lib/httpx/plugins/cookies.rb +3 -7
  28. data/lib/httpx/plugins/digest_authentication.rb +5 -5
  29. data/lib/httpx/plugins/expect.rb +6 -6
  30. data/lib/httpx/plugins/follow_redirects.rb +4 -4
  31. data/lib/httpx/plugins/grpc.rb +247 -0
  32. data/lib/httpx/plugins/grpc/call.rb +62 -0
  33. data/lib/httpx/plugins/grpc/message.rb +85 -0
  34. data/lib/httpx/plugins/h2c.rb +43 -58
  35. data/lib/httpx/plugins/internal_telemetry.rb +1 -1
  36. data/lib/httpx/plugins/multipart/part.rb +2 -2
  37. data/lib/httpx/plugins/proxy.rb +3 -7
  38. data/lib/httpx/plugins/proxy/http.rb +5 -4
  39. data/lib/httpx/plugins/proxy/ssh.rb +3 -3
  40. data/lib/httpx/plugins/rate_limiter.rb +1 -1
  41. data/lib/httpx/plugins/retries.rb +14 -15
  42. data/lib/httpx/plugins/stream.rb +99 -75
  43. data/lib/httpx/plugins/upgrade.rb +84 -0
  44. data/lib/httpx/plugins/upgrade/h2.rb +54 -0
  45. data/lib/httpx/pool.rb +14 -5
  46. data/lib/httpx/request.rb +25 -2
  47. data/lib/httpx/resolver/native.rb +7 -3
  48. data/lib/httpx/response.rb +9 -5
  49. data/lib/httpx/session.rb +17 -7
  50. data/lib/httpx/transcoder/chunker.rb +1 -1
  51. data/lib/httpx/version.rb +1 -1
  52. data/sig/callbacks.rbs +2 -0
  53. data/sig/chainable.rbs +2 -1
  54. data/sig/connection/http1.rbs +6 -1
  55. data/sig/connection/http2.rbs +6 -2
  56. data/sig/headers.rbs +2 -2
  57. data/sig/options.rbs +16 -22
  58. data/sig/plugins/aws_sdk_authentication.rbs +2 -0
  59. data/sig/plugins/aws_sigv4.rbs +0 -1
  60. data/sig/plugins/basic_authentication.rbs +2 -0
  61. data/sig/plugins/compression.rbs +7 -5
  62. data/sig/plugins/compression/brotli.rbs +1 -1
  63. data/sig/plugins/compression/deflate.rbs +1 -1
  64. data/sig/plugins/compression/gzip.rbs +1 -1
  65. data/sig/plugins/cookies.rbs +0 -1
  66. data/sig/plugins/digest_authentication.rbs +0 -1
  67. data/sig/plugins/expect.rbs +0 -2
  68. data/sig/plugins/follow_redirects.rbs +0 -2
  69. data/sig/plugins/h2c.rbs +5 -10
  70. data/sig/plugins/persistent.rbs +0 -1
  71. data/sig/plugins/proxy.rbs +0 -1
  72. data/sig/plugins/retries.rbs +0 -4
  73. data/sig/plugins/stream.rbs +17 -16
  74. data/sig/plugins/upgrade.rbs +23 -0
  75. data/sig/request.rbs +7 -2
  76. data/sig/response.rbs +4 -1
  77. data/sig/session.rbs +4 -0
  78. metadata +21 -7
  79. data/lib/httpx/timeout.rb +0 -67
  80. data/sig/timeout.rbs +0 -29
data/sig/headers.rbs CHANGED
@@ -14,8 +14,8 @@ module HTTPX
14
14
  def add: (headers_key field, string value) -> void
15
15
  def delete: (headers_key field) -> void
16
16
 
17
- def each: () { (headers_key, String) -> void } -> void
18
- | () -> Enumerable[[headers_key, String], void]
17
+ def each: (?_Each[headers_key, String]? extra_headers) { (headers_key, String) -> void } -> void
18
+ | (?_Each[headers_key, String]? extra_headers) -> Enumerable[[headers_key, String], void]
19
19
 
20
20
  def get: (headers_key field) -> Array[String]
21
21
  def key?: (headers_key downcased_key) -> bool
data/sig/options.rbs CHANGED
@@ -5,68 +5,67 @@ 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
9
+ type timeout = Hash[timeout_type, Numeric?]
10
+
8
11
  def self.new: (options) -> instance
9
12
  | () -> instance
10
13
 
14
+ # headers
15
+ attr_reader uri: URI?
16
+ def uri=: (uri) -> void
17
+
11
18
  # headers
12
19
  attr_reader headers: Headers?
13
20
  def headers=: (headers) -> void
14
- def with_headers: (headers) -> instance
15
21
 
16
22
  # timeout
17
- attr_reader timeout: Timeout?
18
- def timeout=: (Hash[Symbol, untyped] | Timeout) -> void
19
- def with_timeout: (Hash[Symbol, untyped] | Timeout) -> instance
23
+ attr_reader timeout: timeout
24
+ def timeout=: (timeout) -> void
20
25
 
21
26
  # max_concurrent_requests
22
27
  attr_reader max_concurrent_requests: Integer?
23
28
  def max_concurrent_requests=: (Integer) -> void
24
- def with_max_concurrent_requests: (Integer) -> instance
25
29
 
26
30
  # max_requests
27
31
  attr_reader max_requests: Integer?
28
32
  def max_requests=: (Integer) -> void
29
- def with_max_requests: (Integer) -> instance
30
33
 
31
34
  # window_size
32
35
  attr_reader window_size: int?
33
36
  def window_size=: (int) -> void
34
- def with_window_size: (int) -> instance
35
37
 
36
38
  # body_threshold_size
37
39
  attr_reader body_threshold_size: int?
38
40
  def body_threshold_size=: (int) -> void
39
- def with_body_threshold_size: (int) -> instance
40
41
 
41
42
  # transport
42
43
  attr_reader transport: _ToS?
43
44
  def transport=: (_ToS) -> void
44
- def with_transport: (_ToS) -> instance
45
45
 
46
46
  # transport_options
47
47
  attr_reader transport_options: Hash[untyped, untyped]?
48
48
  def transport_options=: (Hash[untyped, untyped]) -> void
49
- def with_transport_options: (Hash[untyped, untyped]) -> instance
49
+
50
+ # addresses
51
+ attr_reader addresses: _ToAry[untyped]?
52
+ def addresses=: (_ToAry[untyped]) -> void
50
53
 
51
54
  # params
52
55
  attr_reader params: Transcoder::urlencoded_input?
53
56
  def params=: (Transcoder::urlencoded_input) -> void
54
- def with_params: (Transcoder::urlencoded_input) -> instance
55
57
 
56
58
  # form
57
59
  attr_reader form: Transcoder::urlencoded_input?
58
60
  def form=: (Transcoder::urlencoded_input) -> void
59
- def with_form: (Transcoder::urlencoded_input) -> instance
60
61
 
61
62
  # json
62
63
  attr_reader json: _ToJson?
63
64
  def json=: (_ToJson) -> void
64
- def with_json: (_ToJson) -> instance
65
65
 
66
66
  # body
67
67
  attr_reader body: bodyIO?
68
68
  def body=: (bodyIO) -> void
69
- def with_body: (bodyIO) -> instance
70
69
 
71
70
  # ssl
72
71
 
@@ -79,32 +78,27 @@ module HTTPX
79
78
  # request_class
80
79
  attr_reader request_class: singleton(Request)
81
80
  def request_class=: (singleton(Request)) -> void
82
- def with_request_class: (singleton(Request)) -> instance
83
81
 
84
82
  # io
85
- attr_reader io: _ToIO?
86
- def io=: (_ToIO) -> void
87
- def with_io: (_ToIO) -> instance
83
+ type io_option = _ToIO | Hash[String, _ToIO]
84
+ attr_reader io: io_option?
85
+ def io=: (io_option) -> void
88
86
 
89
87
  # fallback_protocol
90
88
  attr_reader fallback_protocol: String?
91
89
  def fallback_protocol=: (String) -> void
92
- def with_fallback_protocol: (String) -> instance
93
90
 
94
91
  # debug
95
92
  attr_reader debug: _IOLogger?
96
93
  def debug=: (_IOLogger) -> void
97
- def with_debug: (_IOLogger) -> instance
98
94
 
99
95
  # debug_level
100
96
  attr_reader debug_level: Integer?
101
97
  def debug_level=: (Integer) -> void
102
- def with_debug_level: (Integer) -> instance
103
98
 
104
99
  # persistent
105
100
  attr_reader persistent: bool?
106
101
  def persistent=: (bool) -> void
107
- def with_persistent: (bool) -> instance
108
102
 
109
103
  def ==: (untyped other) -> bool
110
104
  def merge: (_ToHash other) -> instance
@@ -7,6 +7,8 @@ module HTTPX
7
7
 
8
8
  def self.load_dependencies: (singleton(Session)) -> void
9
9
 
10
+ def self.configure: (singleton(Session)) -> void
11
+
10
12
  def self.extra_options: (Options) -> (Options)
11
13
 
12
14
  module InstanceMethods
@@ -43,7 +43,6 @@ module HTTPX
43
43
  interface _SigV4Options
44
44
  def sigv4_signer: () -> Signer?
45
45
  def sigv4_signer=: (Signer) -> Signer
46
- def with_sigv4_signer: (Signer) -> instance
47
46
  end
48
47
 
49
48
  def self.extra_options: (Options) -> (Options & _SigV4Options)
@@ -3,6 +3,8 @@ module HTTPX
3
3
  module BasicAuthentication
4
4
  def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
+ def self.configure: (singleton(Session)) -> void
7
+
6
8
  module InstanceMethods
7
9
  def basic_authentication: (string user, string password) -> instance
8
10
  end
@@ -1,13 +1,13 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Compression
4
- extend Registry[Symbol, Class]
4
+ type encodings_registry = Registry[Symbol, Class]
5
5
 
6
6
  type deflatable = _Reader | _ToS
7
7
 
8
8
  interface _Deflater
9
- def deflate: (deflatable, _Writer, chunk_size: Integer) -> void
10
- | (deflatable, _Writer, chunk_size: Integer) { (String) -> void } -> void
9
+ def deflate: (deflatable, ?_Writer, ?chunk_size: Integer) -> _ToS
10
+ | (deflatable, ?_Writer, ?chunk_size: Integer) { (String) -> void } -> _ToS
11
11
  end
12
12
 
13
13
  interface _Inflater
@@ -16,12 +16,14 @@ module HTTPX
16
16
  def initialize: (Numeric bytesize) -> untyped
17
17
  end
18
18
 
19
- def self.load_dependencies: (singleton(Session)) -> void
19
+ def self.configure: (singleton(Session)) -> void
20
20
 
21
21
  interface _CompressionOptions
22
22
  def compression_threshold_size: () -> _Integer?
23
23
  def compression_threshold_size=: (int) -> int
24
- def with_compression_threshold_size: (int) -> instance
24
+
25
+ def encodings: () -> encodings_registry?
26
+ def encodings=: (encodings_registry) -> encodings_registry
25
27
  end
26
28
 
27
29
  def self.extra_options: (Options) -> (Options & _CompressionOptions)
@@ -3,7 +3,7 @@ module HTTPX
3
3
  module Compression
4
4
  module Brotli
5
5
  def self.load_dependencies: (singleton(Session)) -> void
6
- def self.configure: (*untyped) -> void
6
+ def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
9
  def self?.decoder: (Numeric bytesize) -> Inflater
@@ -3,7 +3,7 @@ module HTTPX
3
3
  module Compression
4
4
  module Deflate
5
5
  def self.load_dependencies: (singleton(Session)) -> void
6
- def self.configure: (*untyped) -> void
6
+ def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
9
  def self?.inflater: (Numeric bytesize) -> GZIP::Inflater
@@ -3,7 +3,7 @@ module HTTPX
3
3
  module Compression
4
4
  module GZIP
5
5
  def self.load_dependencies: (singleton(Session)) -> void
6
- def self.configure: (*untyped) -> void
6
+ def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
9
  def self?.inflater: (Numeric bytesize) -> Inflater
@@ -6,7 +6,6 @@ module HTTPX
6
6
  interface _CookieOptions
7
7
  def cookies: () -> Jar?
8
8
  def cookies=: (jar) -> Jar
9
- def with_cookies: (jar) -> instance
10
9
  end
11
10
 
12
11
  def self.extra_options: (Options) -> (Options & _CookieOptions)
@@ -6,7 +6,6 @@ module HTTPX
6
6
  interface _DigestOptions
7
7
  def digest: () -> Digest?
8
8
  def digest=: (Digest) -> Digest
9
- def with_digest: (Digest) -> instance
10
9
  end
11
10
 
12
11
  def self.extra_options: (Options) -> (Options & _DigestOptions)
@@ -6,11 +6,9 @@ module HTTPX
6
6
  interface _ExpectOptions
7
7
  def expect_timeout: () -> Integer?
8
8
  def expect_timeout=: (int) -> Integer
9
- def with_expect_timeout: (int) -> instance
10
9
 
11
10
  def expect_threshold_size: () -> Integer?
12
11
  def expect_threshold_size=: (int) -> Integer
13
- def with_expect_threshold_size: (int) -> instance
14
12
  end
15
13
 
16
14
  def self.extra_options: (Options) -> (Options & _ExpectOptions)
@@ -9,11 +9,9 @@ module HTTPX
9
9
  interface _FollowRedirectsOptions
10
10
  def max_redirects: () -> Integer?
11
11
  def max_redirects=: (int) -> Integer
12
- def with_max_redirects: (int) -> instance
13
12
 
14
13
  def follow_insecure_redirects: () -> bool?
15
14
  def follow_insecure_redirects=: (bool) -> bool
16
- def with_follow_insecure_redirects: (bool) -> instance
17
15
  end
18
16
 
19
17
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
data/sig/plugins/h2c.rbs CHANGED
@@ -1,23 +1,18 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module H2C
4
- def self.load_dependencies: (singleton(Session)) -> void
5
-
6
- module InstanceMethods
7
- VALID_H2C_METHODS: Array[Symbol]
8
-
9
- private
4
+ VALID_H2C_VERBS: Array[Symbol]
10
5
 
11
- def valid_h2c_upgrade_request: (Request) -> bool
12
- def valid_h2c_upgrade?: (Request, Response, Options) -> bool
13
- end
6
+ def self.load_dependencies: (*untyped) -> void
7
+ def self.configure: (singleton(Session)) -> void
8
+ def self.call: (Connection, Request, response) -> void
14
9
 
15
10
  class H2CParser < Connection::HTTP2
16
11
  def upgrade: (Request, Response) -> void
17
12
  end
18
13
 
19
14
  module ConnectionMethods
20
- def upgrade: (Request, Response) -> void
15
+ def upgrade_to_h2c: (Request, Response) -> void
21
16
  end
22
17
  end
23
18
 
@@ -6,7 +6,6 @@ module HTTPX
6
6
  interface _PersistentOptions
7
7
  def persistent: () -> bool?
8
8
  def persistent=: (bool) -> bool
9
- def with_persistent: (bool) -> instance
10
9
  end
11
10
 
12
11
  def self.extra_options: (Options) -> (Options & _PersistentOptions)
@@ -28,7 +28,6 @@ module HTTPX
28
28
  interface _ProxyOptions
29
29
  def proxy: () -> proxyParam?
30
30
  def proxy=: (Parameters | _ToHash) -> proxyParam
31
- def with_proxy: (Parameters | _ToHash) -> instance
32
31
  end
33
32
 
34
33
  def self.extra_options: (Options) -> (Options & _ProxyOptions)
@@ -12,19 +12,15 @@ module HTTPX
12
12
  interface _RetriesOptions
13
13
  def retry_after: () -> Numeric?
14
14
  def retry_after=: (Numeric) -> Numeric
15
- def with_retry_after: (Numeric) -> instance
16
15
 
17
16
  def max_retries: () -> Integer?
18
17
  def max_retries=: (int) -> Integer
19
- def with_max_retries: (int) -> instance
20
18
 
21
19
  def retry_change_requests: () -> bool?
22
20
  def retry_change_requests=: (bool) -> bool
23
- def with_retry_change_requests: (bool) -> instance
24
21
 
25
22
  def retry_on: () -> _RetryCallback?
26
23
  def retry_on=: (_RetryCallback) -> _RetryCallback
27
- def with_retry_on: (_RetryCallback) -> instance
28
24
  end
29
25
 
30
26
  def self.extra_options: (Options) -> (Options & _RetriesOptions)
@@ -1,4 +1,21 @@
1
1
  module HTTPX
2
+ class StreamResponse
3
+ include _ToS
4
+
5
+ def each: () { (String) -> void } -> void
6
+ | () -> Enumerable[String]
7
+
8
+ def each_line: () { (String) -> void } -> void
9
+ | () -> Enumerable[String]
10
+
11
+ def on_chunk: (string) -> void
12
+
13
+ private
14
+
15
+ def response: () -> response
16
+ def initialize: (Request, Session, Array[Connection]) -> untyped
17
+ end
18
+
2
19
  module Plugins
3
20
  module Stream
4
21
  module InstanceMethods
@@ -16,22 +33,6 @@ module HTTPX
16
33
  def stream: () -> StreamResponse?
17
34
  end
18
35
 
19
- class StreamResponse
20
- include _ToS
21
-
22
- def each: () { (String) -> void } -> void
23
- | () -> Enumerable[String]
24
-
25
- def each_line: () { (String) -> void } -> void
26
- | () -> Enumerable[String]
27
-
28
- def on_chunk: (string) -> void
29
-
30
- private
31
-
32
- def response: () -> response
33
- def initialize: (Request, Session) -> untyped
34
- end
35
36
  end
36
37
 
37
38
  type sessionStream = Session & Plugins::Stream::InstanceMethods
@@ -0,0 +1,23 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Upgrade
4
+ type handlers_registry = Registry[Symbol, Class]
5
+
6
+ def self.configure: (singleton(Session)) -> void
7
+
8
+ interface _UpgradeOptions
9
+ def upgrade_handlers: () -> handlers_registry?
10
+ def upgrade_handlers=: (handlers_registry) -> handlers_registry
11
+ end
12
+
13
+ def self.extra_options: (Options) -> (Options & _UpgradeOptions)
14
+
15
+ module ConnectionMethods
16
+ attr_reader upgrade_protocol: Symbol?
17
+ attr_reader hijacked: boolish
18
+
19
+ def hijack_io: () -> void
20
+ end
21
+ end
22
+ end
23
+ end
data/sig/request.rbs CHANGED
@@ -11,7 +11,8 @@ module HTTPX
11
11
  attr_reader body: Body
12
12
  attr_reader state: Symbol
13
13
  attr_reader options: Options
14
- attr_reader response: Response?
14
+ attr_reader response: response?
15
+ attr_reader drain_error: StandardError?
15
16
 
16
17
  def initialize: (verb | String, uri, ?options?) -> untyped
17
18
 
@@ -21,7 +22,7 @@ module HTTPX
21
22
 
22
23
  def scheme: () -> ("http" | "https")
23
24
 
24
- def response=: (Response response) -> void
25
+ def response=: (response) -> void
25
26
 
26
27
  def path: () -> String
27
28
 
@@ -39,6 +40,10 @@ module HTTPX
39
40
 
40
41
  def expects?: () -> boolish
41
42
 
43
+ def trailers: () -> Headers
44
+
45
+ def trailers?: () -> boolish
46
+
42
47
  class Body
43
48
  def initialize: (Headers, Options) -> untyped
44
49
  def each: () { (String) -> void } -> void
data/sig/response.rbs CHANGED
@@ -37,6 +37,8 @@ module HTTPX
37
37
  include _ToStr
38
38
 
39
39
  @state: :idle | :memory | :buffer
40
+ @threshold_size: Integer
41
+ @window_size: Integer
40
42
 
41
43
  def each: () { (String) -> void } -> void
42
44
  | () -> Enumerable[String]
@@ -45,10 +47,11 @@ module HTTPX
45
47
  def empty?: () -> bool
46
48
  def copy_to: (_ToPath | _Writer destination) -> void
47
49
  def close: () -> void
50
+ def closed?: () -> bool
48
51
 
49
52
  private
50
53
 
51
- def initialize: (Response, ?threshold_size: Integer, ?window_size: Integer) -> untyped
54
+ def initialize: (Response, options) -> untyped
52
55
  def rewind: () -> void
53
56
  def transition: () -> void
54
57
  end