httpx 0.11.2 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/doc/release_notes/0_11_1.md +5 -1
  4. data/doc/release_notes/0_11_3.md +5 -0
  5. data/doc/release_notes/0_12_0.md +55 -0
  6. data/doc/release_notes/0_13_0.md +58 -0
  7. data/doc/release_notes/0_13_1.md +5 -0
  8. data/doc/release_notes/0_13_2.md +9 -0
  9. data/lib/httpx.rb +2 -1
  10. data/lib/httpx/adapters/faraday.rb +4 -6
  11. data/lib/httpx/altsvc.rb +1 -0
  12. data/lib/httpx/chainable.rb +2 -2
  13. data/lib/httpx/connection.rb +80 -28
  14. data/lib/httpx/connection/http1.rb +19 -6
  15. data/lib/httpx/connection/http2.rb +32 -25
  16. data/lib/httpx/io.rb +16 -3
  17. data/lib/httpx/io/ssl.rb +35 -24
  18. data/lib/httpx/io/tcp.rb +50 -28
  19. data/lib/httpx/io/tls.rb +218 -0
  20. data/lib/httpx/io/tls/box.rb +365 -0
  21. data/lib/httpx/io/tls/context.rb +199 -0
  22. data/lib/httpx/io/tls/ffi.rb +390 -0
  23. data/lib/httpx/io/udp.rb +31 -7
  24. data/lib/httpx/io/unix.rb +27 -12
  25. data/lib/httpx/options.rb +11 -23
  26. data/lib/httpx/parser/http1.rb +4 -4
  27. data/lib/httpx/plugins/aws_sdk_authentication.rb +81 -0
  28. data/lib/httpx/plugins/aws_sigv4.rb +219 -0
  29. data/lib/httpx/plugins/compression.rb +20 -8
  30. data/lib/httpx/plugins/compression/brotli.rb +8 -6
  31. data/lib/httpx/plugins/compression/deflate.rb +4 -7
  32. data/lib/httpx/plugins/compression/gzip.rb +2 -2
  33. data/lib/httpx/plugins/digest_authentication.rb +1 -1
  34. data/lib/httpx/plugins/follow_redirects.rb +1 -1
  35. data/lib/httpx/plugins/h2c.rb +43 -58
  36. data/lib/httpx/plugins/internal_telemetry.rb +93 -0
  37. data/lib/httpx/plugins/multipart.rb +2 -0
  38. data/lib/httpx/plugins/multipart/encoder.rb +4 -9
  39. data/lib/httpx/plugins/proxy.rb +1 -1
  40. data/lib/httpx/plugins/proxy/http.rb +1 -1
  41. data/lib/httpx/plugins/proxy/socks4.rb +8 -0
  42. data/lib/httpx/plugins/proxy/socks5.rb +8 -0
  43. data/lib/httpx/plugins/push_promise.rb +3 -2
  44. data/lib/httpx/plugins/retries.rb +2 -2
  45. data/lib/httpx/plugins/stream.rb +6 -6
  46. data/lib/httpx/plugins/upgrade.rb +84 -0
  47. data/lib/httpx/plugins/upgrade/h2.rb +54 -0
  48. data/lib/httpx/pool.rb +14 -6
  49. data/lib/httpx/registry.rb +1 -7
  50. data/lib/httpx/request.rb +11 -1
  51. data/lib/httpx/resolver/https.rb +3 -11
  52. data/lib/httpx/resolver/native.rb +7 -3
  53. data/lib/httpx/response.rb +14 -7
  54. data/lib/httpx/selector.rb +5 -0
  55. data/lib/httpx/session.rb +25 -2
  56. data/lib/httpx/transcoder/body.rb +3 -5
  57. data/lib/httpx/version.rb +1 -1
  58. data/sig/chainable.rbs +2 -1
  59. data/sig/connection/http1.rbs +3 -2
  60. data/sig/connection/http2.rbs +5 -3
  61. data/sig/options.rbs +7 -20
  62. data/sig/plugins/aws_sdk_authentication.rbs +17 -0
  63. data/sig/plugins/aws_sigv4.rbs +64 -0
  64. data/sig/plugins/compression.rbs +5 -3
  65. data/sig/plugins/compression/brotli.rbs +1 -1
  66. data/sig/plugins/compression/deflate.rbs +1 -1
  67. data/sig/plugins/compression/gzip.rbs +1 -1
  68. data/sig/plugins/cookies.rbs +0 -1
  69. data/sig/plugins/digest_authentication.rbs +0 -1
  70. data/sig/plugins/expect.rbs +0 -2
  71. data/sig/plugins/follow_redirects.rbs +0 -2
  72. data/sig/plugins/h2c.rbs +5 -10
  73. data/sig/plugins/persistent.rbs +0 -1
  74. data/sig/plugins/proxy.rbs +0 -1
  75. data/sig/plugins/push_promise.rbs +1 -1
  76. data/sig/plugins/retries.rbs +0 -4
  77. data/sig/plugins/upgrade.rbs +23 -0
  78. data/sig/response.rbs +3 -1
  79. metadata +24 -2
@@ -44,11 +44,9 @@ module HTTPX::Transcoder
44
44
  end
45
45
 
46
46
  def method_missing(meth, *args, &block)
47
- if @raw.respond_to?(meth)
48
- @raw.__send__(meth, *args, &block)
49
- else
50
- super
51
- end
47
+ return super unless @raw.respond_to?(meth)
48
+
49
+ @raw.__send__(meth, *args, &block)
52
50
  end
53
51
  end
54
52
 
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.11.2"
4
+ VERSION = "0.13.2"
5
5
  end
data/sig/chainable.rbs CHANGED
@@ -18,7 +18,8 @@ module HTTPX
18
18
  | (:cookies) -> Plugins::sessionCookies
19
19
  | (:expect) -> Session
20
20
  | (:follow_redirects) -> Plugins::sessionFollowRedirects
21
- | (:h2c) -> Plugins::sessionH2C
21
+ | (:upgrade) -> Session
22
+ | (:h2c) -> Session
22
23
  | (:multipart) -> Session
23
24
  | (:persistent) -> Plugins::sessionPersistent
24
25
  | (:proxy) -> Plugins::sessionProxy
@@ -4,6 +4,7 @@ module HTTPX
4
4
  include Loggable
5
5
 
6
6
  attr_reader pending: Array[Request]
7
+ attr_reader requests: Array[Request]
7
8
 
8
9
  @options: Options
9
10
  @max_concurrent_requests: Integer
@@ -31,7 +32,7 @@ module HTTPX
31
32
 
32
33
  def on_headers: (Hash[String, Array[String]] headers) -> void
33
34
 
34
- def on_trailers: (Array[String, String] headers) -> void
35
+ def on_trailers: (Hash[String, Array[String]] headers) -> void
35
36
 
36
37
  def on_data: (string chunk) -> void
37
38
 
@@ -51,7 +52,7 @@ module HTTPX
51
52
 
52
53
  def disable_pipelining: () -> void
53
54
 
54
- def set_request_headers: (Request) -> void
55
+ def set_protocol_headers: (Request) -> void
55
56
 
56
57
  def headline_uri: (Request) -> String
57
58
 
@@ -3,7 +3,7 @@ module HTTPX
3
3
  include Callbacks
4
4
  include Loggable
5
5
 
6
- attr_reader streams: Hash[HTTP2Next::Stream, Response]
6
+ attr_reader streams: Hash[Request, HTTP2Next::Stream]
7
7
  attr_reader pending: Array[Request]
8
8
 
9
9
  @options: Options
@@ -13,7 +13,7 @@ module HTTPX
13
13
  @pings: Array[String]
14
14
  @buffer: Buffer
15
15
 
16
- def interests: () -> io_interests
16
+ def interests: () -> io_interests?
17
17
 
18
18
  def close: () -> void
19
19
 
@@ -23,6 +23,8 @@ module HTTPX
23
23
 
24
24
  def <<: (String) -> void
25
25
 
26
+ def can_buffer_more_requests: () -> bool
27
+
26
28
  def send: (Request) -> void
27
29
 
28
30
  def consume: () -> void
@@ -41,7 +43,7 @@ module HTTPX
41
43
 
42
44
  def headline_uri: (Request) -> String
43
45
 
44
- def set_request_headers: (Request) -> void
46
+ def set_protocol_headers: (Request) -> void
45
47
 
46
48
  def handle: (Request request, HTTP2Next::Stream stream) -> void
47
49
 
data/sig/options.rbs CHANGED
@@ -11,62 +11,54 @@ module HTTPX
11
11
  # headers
12
12
  attr_reader headers: Headers?
13
13
  def headers=: (headers) -> void
14
- def with_headers: (headers) -> instance
15
14
 
16
15
  # timeout
17
16
  attr_reader timeout: Timeout?
18
17
  def timeout=: (Hash[Symbol, untyped] | Timeout) -> void
19
- def with_timeout: (Hash[Symbol, untyped] | Timeout) -> instance
20
18
 
21
19
  # max_concurrent_requests
22
20
  attr_reader max_concurrent_requests: Integer?
23
21
  def max_concurrent_requests=: (Integer) -> void
24
- def with_max_concurrent_requests: (Integer) -> instance
25
22
 
26
23
  # max_requests
27
24
  attr_reader max_requests: Integer?
28
25
  def max_requests=: (Integer) -> void
29
- def with_max_requests: (Integer) -> instance
30
26
 
31
27
  # window_size
32
28
  attr_reader window_size: int?
33
29
  def window_size=: (int) -> void
34
- def with_window_size: (int) -> instance
35
30
 
36
31
  # body_threshold_size
37
32
  attr_reader body_threshold_size: int?
38
33
  def body_threshold_size=: (int) -> void
39
- def with_body_threshold_size: (int) -> instance
40
34
 
41
35
  # transport
42
36
  attr_reader transport: _ToS?
43
37
  def transport=: (_ToS) -> void
44
- def with_transport: (_ToS) -> instance
45
38
 
46
39
  # transport_options
47
40
  attr_reader transport_options: Hash[untyped, untyped]?
48
41
  def transport_options=: (Hash[untyped, untyped]) -> void
49
- def with_transport_options: (Hash[untyped, untyped]) -> instance
42
+
43
+ # addresses
44
+ attr_reader addresses: _ToAry[untyped]?
45
+ def addresses=: (_ToAry[untyped]) -> void
50
46
 
51
47
  # params
52
48
  attr_reader params: Transcoder::urlencoded_input?
53
49
  def params=: (Transcoder::urlencoded_input) -> void
54
- def with_params: (Transcoder::urlencoded_input) -> instance
55
50
 
56
51
  # form
57
52
  attr_reader form: Transcoder::urlencoded_input?
58
53
  def form=: (Transcoder::urlencoded_input) -> void
59
- def with_form: (Transcoder::urlencoded_input) -> instance
60
54
 
61
55
  # json
62
56
  attr_reader json: _ToJson?
63
57
  def json=: (_ToJson) -> void
64
- def with_json: (_ToJson) -> instance
65
58
 
66
59
  # body
67
60
  attr_reader body: bodyIO?
68
61
  def body=: (bodyIO) -> void
69
- def with_body: (bodyIO) -> instance
70
62
 
71
63
  # ssl
72
64
 
@@ -79,32 +71,27 @@ module HTTPX
79
71
  # request_class
80
72
  attr_reader request_class: singleton(Request)
81
73
  def request_class=: (singleton(Request)) -> void
82
- def with_request_class: (singleton(Request)) -> instance
83
74
 
84
75
  # io
85
- attr_reader io: _ToIO?
86
- def io=: (_ToIO) -> void
87
- def with_io: (_ToIO) -> instance
76
+ type io_option = _ToIO | Hash[String, _ToIO]
77
+ attr_reader io: io_option?
78
+ def io=: (io_option) -> void
88
79
 
89
80
  # fallback_protocol
90
81
  attr_reader fallback_protocol: String?
91
82
  def fallback_protocol=: (String) -> void
92
- def with_fallback_protocol: (String) -> instance
93
83
 
94
84
  # debug
95
85
  attr_reader debug: _IOLogger?
96
86
  def debug=: (_IOLogger) -> void
97
- def with_debug: (_IOLogger) -> instance
98
87
 
99
88
  # debug_level
100
89
  attr_reader debug_level: Integer?
101
90
  def debug_level=: (Integer) -> void
102
- def with_debug_level: (Integer) -> instance
103
91
 
104
92
  # persistent
105
93
  attr_reader persistent: bool?
106
94
  def persistent=: (bool) -> void
107
- def with_persistent: (bool) -> instance
108
95
 
109
96
  def ==: (untyped other) -> bool
110
97
  def merge: (_ToHash other) -> instance
@@ -0,0 +1,17 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module AwsSdkAuthentication
4
+ class Credentials
5
+ include _SigV4Credentials
6
+ end
7
+
8
+ def self.load_dependencies: (singleton(Session)) -> void
9
+
10
+ def self.extra_options: (Options) -> (Options)
11
+
12
+ module InstanceMethods
13
+ def aws_sdk_authentication: (**untyped) -> instance
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ module HTTPX
2
+ module Plugins
3
+
4
+ interface _SigV4Credentials
5
+ def username: () -> String
6
+ def password: () -> String
7
+ def security_token: () -> String?
8
+ end
9
+
10
+ module AWSSigV4
11
+
12
+ Credentials: _SigV4Credentials
13
+
14
+
15
+ class Signer
16
+
17
+ def sign!: (Request) -> void
18
+
19
+ private
20
+
21
+ def initialize: (
22
+ service: String,
23
+ region: String,
24
+ ?credentials: _SigV4Credentials,
25
+ ?username: String,
26
+ ?password: String,
27
+ ?security_token: String,
28
+ ?provider_prefix: String,
29
+ ?header_provider_field: String,
30
+ ?unsigned_headers: Array[String],
31
+ ?apply_checksum_header: bool,
32
+ ?algorithm: String
33
+ ) -> untyped
34
+
35
+
36
+ def sha256_hexdigest: (bodyIO value) -> String
37
+
38
+ def hmac: (String key, String value) -> String
39
+ def hexhmac: (String key, String value) -> String
40
+ end
41
+
42
+
43
+ interface _SigV4Options
44
+ def sigv4_signer: () -> Signer?
45
+ def sigv4_signer=: (Signer) -> Signer
46
+ end
47
+
48
+ def self.extra_options: (Options) -> (Options & _SigV4Options)
49
+ def self.load_dependencies: (singleton(Session)) -> void
50
+
51
+ module InstanceMethods
52
+ def aws_sigv4_authentication: (**untyped) -> instance
53
+ end
54
+
55
+ module RequestMethods
56
+ def canonical_path: () -> String
57
+
58
+ def canonical_query: () -> String
59
+ end
60
+ end
61
+
62
+ type awsSigV4Session = Session & Plugins::AWSSigV4::InstanceMethods
63
+ end
64
+ end
@@ -1,7 +1,7 @@
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
 
@@ -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)
@@ -11,7 +11,7 @@ module HTTPX
11
11
  module InstanceMethods
12
12
  private
13
13
 
14
- def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
14
+ def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
15
15
  def __on_promise_request: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
16
16
  def __on_promise_response: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
17
17
  end
@@ -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)