httpx 0.13.2 → 0.14.4

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.
Files changed (61) 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 +2 -2
  4. data/doc/release_notes/0_13_1.md +1 -1
  5. data/doc/release_notes/0_14_0.md +79 -0
  6. data/doc/release_notes/0_14_1.md +7 -0
  7. data/doc/release_notes/0_14_2.md +6 -0
  8. data/doc/release_notes/0_14_3.md +5 -0
  9. data/doc/release_notes/0_14_4.md +5 -0
  10. data/lib/httpx.rb +1 -2
  11. data/lib/httpx/callbacks.rb +12 -3
  12. data/lib/httpx/connection.rb +12 -9
  13. data/lib/httpx/connection/http1.rb +40 -15
  14. data/lib/httpx/connection/http2.rb +61 -15
  15. data/lib/httpx/headers.rb +7 -3
  16. data/lib/httpx/idna.rb +15 -0
  17. data/lib/httpx/io/tcp.rb +1 -1
  18. data/lib/httpx/options.rb +91 -56
  19. data/lib/httpx/plugins/aws_sdk_authentication.rb +5 -2
  20. data/lib/httpx/plugins/aws_sigv4.rb +4 -4
  21. data/lib/httpx/plugins/basic_authentication.rb +8 -3
  22. data/lib/httpx/plugins/compression.rb +8 -8
  23. data/lib/httpx/plugins/compression/brotli.rb +4 -3
  24. data/lib/httpx/plugins/compression/deflate.rb +4 -3
  25. data/lib/httpx/plugins/compression/gzip.rb +2 -1
  26. data/lib/httpx/plugins/cookies.rb +3 -7
  27. data/lib/httpx/plugins/digest_authentication.rb +4 -4
  28. data/lib/httpx/plugins/expect.rb +6 -6
  29. data/lib/httpx/plugins/follow_redirects.rb +3 -3
  30. data/lib/httpx/plugins/grpc.rb +247 -0
  31. data/lib/httpx/plugins/grpc/call.rb +62 -0
  32. data/lib/httpx/plugins/grpc/message.rb +85 -0
  33. data/lib/httpx/plugins/multipart/part.rb +2 -2
  34. data/lib/httpx/plugins/proxy.rb +3 -7
  35. data/lib/httpx/plugins/proxy/http.rb +5 -4
  36. data/lib/httpx/plugins/proxy/ssh.rb +3 -3
  37. data/lib/httpx/plugins/rate_limiter.rb +1 -1
  38. data/lib/httpx/plugins/retries.rb +13 -14
  39. data/lib/httpx/plugins/stream.rb +96 -74
  40. data/lib/httpx/plugins/upgrade.rb +4 -4
  41. data/lib/httpx/request.rb +25 -2
  42. data/lib/httpx/response.rb +4 -0
  43. data/lib/httpx/session.rb +17 -7
  44. data/lib/httpx/transcoder/chunker.rb +1 -1
  45. data/lib/httpx/version.rb +1 -1
  46. data/sig/callbacks.rbs +2 -0
  47. data/sig/connection/http1.rbs +5 -1
  48. data/sig/connection/http2.rbs +6 -2
  49. data/sig/headers.rbs +2 -2
  50. data/sig/options.rbs +9 -2
  51. data/sig/plugins/aws_sdk_authentication.rbs +2 -0
  52. data/sig/plugins/basic_authentication.rbs +2 -0
  53. data/sig/plugins/compression.rbs +2 -2
  54. data/sig/plugins/multipart.rbs +1 -1
  55. data/sig/plugins/stream.rbs +17 -16
  56. data/sig/request.rbs +7 -2
  57. data/sig/response.rbs +1 -0
  58. data/sig/session.rbs +4 -0
  59. metadata +19 -7
  60. data/lib/httpx/timeout.rb +0 -67
  61. data/sig/timeout.rbs +0 -29
@@ -20,7 +20,7 @@ module HTTPX::Transcoder
20
20
  @raw.each do |chunk|
21
21
  yield "#{chunk.bytesize.to_s(16)}#{CRLF}#{chunk}#{CRLF}"
22
22
  end
23
- yield "0#{CRLF}#{CRLF}"
23
+ yield "0#{CRLF}"
24
24
  end
25
25
 
26
26
  def respond_to_missing?(meth, *args)
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.13.2"
4
+ VERSION = "0.14.4"
5
5
  end
data/sig/callbacks.rbs CHANGED
@@ -6,8 +6,10 @@ module HTTPX
6
6
  module Callbacks
7
7
  def on: (Symbol) { (*untyped) -> void } -> void
8
8
  def once: (Symbol) { (*untyped) -> void } -> void
9
+ def only: (Symbol) { (*untyped) -> void } -> void
9
10
  def emit: (Symbol, *untyped) -> void
10
11
 
12
+ def callbacks_for?: (Symbol) -> bool
11
13
  def callbacks: () -> Hash[Symbol, Array[_Callable]]
12
14
  | (Symbol) -> Array[_Callable]
13
15
  end
@@ -52,7 +52,7 @@ module HTTPX
52
52
 
53
53
  def disable_pipelining: () -> void
54
54
 
55
- def set_protocol_headers: (Request) -> void
55
+ def set_protocol_headers: (Request) -> _Each[headers_key, String]
56
56
 
57
57
  def headline_uri: (Request) -> String
58
58
 
@@ -60,6 +60,10 @@ module HTTPX
60
60
 
61
61
  def join_headers: (Request request) -> void
62
62
 
63
+ def join_trailers: (Request request) -> void
64
+
65
+ def join_headers2: (_Each[headers_key, String] headers) -> void
66
+
63
67
  def join_body: (Request request) -> void
64
68
 
65
69
  def capitalized: (String field) -> String
@@ -43,7 +43,7 @@ module HTTPX
43
43
 
44
44
  def headline_uri: (Request) -> String
45
45
 
46
- def set_protocol_headers: (Request) -> void
46
+ def set_protocol_headers: (Request) -> _Each[headers_key, String]
47
47
 
48
48
  def handle: (Request request, HTTP2Next::Stream stream) -> void
49
49
 
@@ -53,13 +53,17 @@ module HTTPX
53
53
 
54
54
  def join_headers: (HTTP2Next::Stream stream, Request request) -> void
55
55
 
56
+ def join_trailers: (HTTP2Next::Stream stream, Request request) -> void
57
+
56
58
  def join_body: (HTTP2Next::Stream stream, Request request) -> void
57
59
 
58
60
  def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
59
61
 
62
+ def on_stream_trailers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
63
+
60
64
  def on_stream_data: (HTTP2Next::Stream stream, Request request, string data) -> void
61
65
 
62
- def on_stream_close: (HTTP2Next::Stream stream, Request request, Symbol? error) -> void
66
+ def on_stream_close: (HTTP2Next::Stream stream, Request request, (Symbol | StandardError)? error) -> void
63
67
 
64
68
  def on_frame: (string bytes) -> void
65
69
 
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,16 +5,23 @@ 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
21
 
15
22
  # timeout
16
- attr_reader timeout: Timeout?
17
- def timeout=: (Hash[Symbol, untyped] | Timeout) -> void
23
+ attr_reader timeout: timeout
24
+ def timeout=: (timeout) -> void
18
25
 
19
26
  # max_concurrent_requests
20
27
  attr_reader max_concurrent_requests: Integer?
@@ -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
@@ -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
@@ -6,8 +6,8 @@ module HTTPX
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
@@ -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?] | [_Reader, String])
36
+ def self?.call: (multipart_nested_value) -> ([_Reader, String, String?])
37
37
  end
38
38
 
39
39
  module MimeTypeDetector
@@ -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
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
@@ -47,6 +47,7 @@ module HTTPX
47
47
  def empty?: () -> bool
48
48
  def copy_to: (_ToPath | _Writer destination) -> void
49
49
  def close: () -> void
50
+ def closed?: () -> bool
50
51
 
51
52
  private
52
53
 
data/sig/session.rbs CHANGED
@@ -45,5 +45,9 @@ module HTTPX
45
45
  def build_connection: (URI, Options) -> Connection
46
46
 
47
47
  def send_requests: (*Request, options) -> Array[response]
48
+
49
+ def _send_requests: (Array[Request], options) -> Array[Connection]
50
+
51
+ def receive_requests: (Array[Request], Array[Connection], options) -> Array[response]
48
52
  end
49
53
  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.13.2
4
+ version: 0.14.4
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-04-02 00:00:00.000000000 Z
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: 0.4.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: 0.4.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: timers
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,6 +62,11 @@ extra_rdoc_files:
62
62
  - doc/release_notes/0_13_0.md
63
63
  - doc/release_notes/0_13_1.md
64
64
  - doc/release_notes/0_13_2.md
65
+ - doc/release_notes/0_14_0.md
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
65
70
  - doc/release_notes/0_1_0.md
66
71
  - doc/release_notes/0_2_0.md
67
72
  - doc/release_notes/0_2_1.md
@@ -103,6 +108,11 @@ files:
103
108
  - doc/release_notes/0_13_0.md
104
109
  - doc/release_notes/0_13_1.md
105
110
  - doc/release_notes/0_13_2.md
111
+ - doc/release_notes/0_14_0.md
112
+ - doc/release_notes/0_14_1.md
113
+ - doc/release_notes/0_14_2.md
114
+ - doc/release_notes/0_14_3.md
115
+ - doc/release_notes/0_14_4.md
106
116
  - doc/release_notes/0_1_0.md
107
117
  - doc/release_notes/0_2_0.md
108
118
  - doc/release_notes/0_2_1.md
@@ -140,6 +150,7 @@ files:
140
150
  - lib/httpx/errors.rb
141
151
  - lib/httpx/extensions.rb
142
152
  - lib/httpx/headers.rb
153
+ - lib/httpx/idna.rb
143
154
  - lib/httpx/io.rb
144
155
  - lib/httpx/io/ssl.rb
145
156
  - lib/httpx/io/tcp.rb
@@ -167,6 +178,9 @@ files:
167
178
  - lib/httpx/plugins/digest_authentication.rb
168
179
  - lib/httpx/plugins/expect.rb
169
180
  - lib/httpx/plugins/follow_redirects.rb
181
+ - lib/httpx/plugins/grpc.rb
182
+ - lib/httpx/plugins/grpc/call.rb
183
+ - lib/httpx/plugins/grpc/message.rb
170
184
  - lib/httpx/plugins/h2c.rb
171
185
  - lib/httpx/plugins/internal_telemetry.rb
172
186
  - lib/httpx/plugins/multipart.rb
@@ -196,7 +210,6 @@ files:
196
210
  - lib/httpx/response.rb
197
211
  - lib/httpx/selector.rb
198
212
  - lib/httpx/session.rb
199
- - lib/httpx/timeout.rb
200
213
  - lib/httpx/transcoder.rb
201
214
  - lib/httpx/transcoder/body.rb
202
215
  - lib/httpx/transcoder/chunker.rb
@@ -255,7 +268,6 @@ files:
255
268
  - sig/response.rbs
256
269
  - sig/selector.rbs
257
270
  - sig/session.rbs
258
- - sig/timeout.rbs
259
271
  - sig/transcoder.rbs
260
272
  - sig/transcoder/body.rbs
261
273
  - sig/transcoder/chunker.rbs
@@ -284,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
296
  - !ruby/object:Gem::Version
285
297
  version: '0'
286
298
  requirements: []
287
- rubygems_version: 3.2.3
299
+ rubygems_version: 3.2.15
288
300
  signing_key:
289
301
  specification_version: 4
290
302
  summary: HTTPX, to the future, and beyond
data/lib/httpx/timeout.rb DELETED
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "timeout"
4
-
5
- module HTTPX
6
- class Timeout
7
- CONNECT_TIMEOUT = 60
8
- OPERATION_TIMEOUT = 60
9
- KEEP_ALIVE_TIMEOUT = 20
10
-
11
- def self.new(opts = {})
12
- return opts if opts.is_a?(Timeout)
13
-
14
- super(**opts)
15
- end
16
-
17
- attr_reader :connect_timeout, :operation_timeout, :keep_alive_timeout, :total_timeout
18
-
19
- def initialize(connect_timeout: CONNECT_TIMEOUT,
20
- operation_timeout: OPERATION_TIMEOUT,
21
- keep_alive_timeout: KEEP_ALIVE_TIMEOUT,
22
- total_timeout: nil,
23
- loop_timeout: nil)
24
- @connect_timeout = connect_timeout
25
- @operation_timeout = operation_timeout
26
- @keep_alive_timeout = keep_alive_timeout
27
- @total_timeout = total_timeout
28
-
29
- return unless loop_timeout
30
-
31
- # :nocov:
32
- warn ":loop_timeout is deprecated, use :operation_timeout instead"
33
- @operation_timeout = loop_timeout
34
- # :nocov:
35
- end
36
-
37
- def ==(other)
38
- if other.is_a?(Timeout)
39
- @connect_timeout == other.instance_variable_get(:@connect_timeout) &&
40
- @operation_timeout == other.instance_variable_get(:@operation_timeout) &&
41
- @keep_alive_timeout == other.instance_variable_get(:@keep_alive_timeout) &&
42
- @total_timeout == other.instance_variable_get(:@total_timeout)
43
- else
44
- super
45
- end
46
- end
47
-
48
- def merge(other)
49
- case other
50
- when Hash
51
- timeout = Timeout.new(other)
52
- merge(timeout)
53
- when Timeout
54
- connect_timeout = other.instance_variable_get(:@connect_timeout) || @connect_timeout
55
- operation_timeout = other.instance_variable_get(:@operation_timeout) || @operation_timeout
56
- keep_alive_timeout = other.instance_variable_get(:@keep_alive_timeout) || @keep_alive_timeout
57
- total_timeout = other.instance_variable_get(:@total_timeout) || @total_timeout
58
- Timeout.new(connect_timeout: connect_timeout,
59
- operation_timeout: operation_timeout,
60
- keep_alive_timeout: keep_alive_timeout,
61
- total_timeout: total_timeout)
62
- else
63
- raise ArgumentError, "can't merge with #{other.class}"
64
- end
65
- end
66
- end
67
- end
data/sig/timeout.rbs DELETED
@@ -1,29 +0,0 @@
1
- module HTTPX
2
- class Timeout
3
- CONNECT_TIMEOUT: Numeric
4
- KEEP_ALIVE_TIMEOUT: Numeric
5
- OPERATION_TIMEOUT: Numeric
6
-
7
- attr_reader connect_timeout: Numeric
8
- attr_reader operation_timeout: Numeric
9
- attr_reader total_timeout: Numeric?
10
- attr_reader keep_alive_timeout: Numeric?
11
-
12
- def self.new: (instance | Hash[Symbol, untyped]) -> instance
13
- | () -> instance
14
-
15
- def ==: (untyped other) -> bool
16
-
17
- def merge: (Timeout | Hash[Symbol, untyped]) -> instance
18
-
19
- private
20
-
21
- def initialize: (
22
- ?connect_timeout: Numeric,
23
- ?operation_timeout: Numeric,
24
- ?keep_alive_timeout: Numeric,
25
- ?total_timeout: Numeric | nil,
26
- ?loop_timeout: Numeric | nil
27
- ) -> untyped
28
- end
29
- end