httpx 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_17_0.md +49 -0
  3. data/lib/httpx/adapters/webmock.rb +2 -2
  4. data/lib/httpx/chainable.rb +1 -1
  5. data/lib/httpx/connection/http1.rb +15 -9
  6. data/lib/httpx/connection/http2.rb +13 -10
  7. data/lib/httpx/connection.rb +4 -5
  8. data/lib/httpx/headers.rb +1 -1
  9. data/lib/httpx/options.rb +28 -6
  10. data/lib/httpx/parser/http1.rb +10 -6
  11. data/lib/httpx/plugins/digest_authentication.rb +4 -4
  12. data/lib/httpx/plugins/h2c.rb +7 -3
  13. data/lib/httpx/plugins/multipart/decoder.rb +187 -0
  14. data/lib/httpx/plugins/multipart/mime_type_detector.rb +3 -3
  15. data/lib/httpx/plugins/multipart/part.rb +2 -2
  16. data/lib/httpx/plugins/multipart.rb +14 -0
  17. data/lib/httpx/plugins/ntlm_authentication.rb +4 -4
  18. data/lib/httpx/plugins/proxy/ssh.rb +11 -4
  19. data/lib/httpx/plugins/proxy.rb +6 -4
  20. data/lib/httpx/plugins/stream.rb +2 -3
  21. data/lib/httpx/registry.rb +1 -1
  22. data/lib/httpx/request.rb +6 -7
  23. data/lib/httpx/resolver/resolver_mixin.rb +2 -1
  24. data/lib/httpx/response.rb +37 -30
  25. data/lib/httpx/selector.rb +4 -2
  26. data/lib/httpx/session.rb +15 -13
  27. data/lib/httpx/transcoder/form.rb +20 -0
  28. data/lib/httpx/transcoder/json.rb +12 -0
  29. data/lib/httpx/transcoder.rb +62 -1
  30. data/lib/httpx/utils.rb +2 -2
  31. data/lib/httpx/version.rb +1 -1
  32. data/sig/buffer.rbs +2 -2
  33. data/sig/chainable.rbs +6 -1
  34. data/sig/connection/http1.rbs +10 -4
  35. data/sig/connection/http2.rbs +16 -5
  36. data/sig/connection.rbs +4 -4
  37. data/sig/headers.rbs +19 -18
  38. data/sig/options.rbs +13 -5
  39. data/sig/parser/http1.rbs +3 -3
  40. data/sig/plugins/aws_sigv4.rbs +12 -3
  41. data/sig/plugins/basic_authentication.rbs +1 -1
  42. data/sig/plugins/multipart.rbs +64 -8
  43. data/sig/plugins/proxy.rbs +6 -6
  44. data/sig/request.rbs +11 -8
  45. data/sig/resolver/native.rbs +4 -2
  46. data/sig/resolver/resolver_mixin.rbs +1 -1
  47. data/sig/resolver/system.rbs +1 -1
  48. data/sig/response.rbs +8 -2
  49. data/sig/selector.rbs +8 -6
  50. data/sig/session.rbs +8 -14
  51. data/sig/transcoder/form.rbs +1 -0
  52. data/sig/transcoder/json.rbs +1 -0
  53. data/sig/transcoder.rbs +5 -4
  54. metadata +5 -2
@@ -5,6 +5,8 @@ module HTTPX
5
5
  include ResolverMixin
6
6
  include _ToIO
7
7
 
8
+ type state = :idle | :open | :closed
9
+
8
10
  DEFAULTS: Hash[Symbol, untyped]
9
11
  DNS_PORT: Integer
10
12
 
@@ -19,7 +21,7 @@ module HTTPX
19
21
  @queries: Hash[String, Connection]
20
22
  @read_buffer: String
21
23
  @write_buffer: Buffer
22
- @state: :idle | :open | :closed
24
+ @state: state
23
25
 
24
26
  def closed?: () -> bool
25
27
 
@@ -56,7 +58,7 @@ module HTTPX
56
58
 
57
59
  def build_socket: () -> void
58
60
 
59
- def transition: (Symbol nextstate) -> void
61
+ def transition: (state nextstate) -> void
60
62
 
61
63
  def handle_error: (NativeResolveError | StandardError) -> void
62
64
  end
@@ -4,7 +4,7 @@ module HTTPX
4
4
  include Callbacks
5
5
  include Loggable
6
6
 
7
- CHECK_IF_IP: Proc
7
+ CHECK_IF_IP: ^(String name) -> bool
8
8
 
9
9
  def uncache: (Connection) -> void
10
10
 
@@ -3,7 +3,7 @@ module HTTPX
3
3
  class System
4
4
  include ResolverMixin
5
5
 
6
- RESOLV_ERRORS: Array[StandardError] # ResolvError
6
+ RESOLV_ERRORS: Array[singleton(StandardError)] # ResolvError
7
7
 
8
8
  def closed?: () -> true
9
9
 
data/sig/response.rbs CHANGED
@@ -22,16 +22,22 @@ module HTTPX
22
22
  def close: () -> void
23
23
  def uri: () -> URI::Generic
24
24
 
25
- def merge_headers: (_Each[[headers_key, headers_value]]) -> void
25
+ def merge_headers: (_Each[[String, headers_value]]) -> void
26
26
  def bodyless?: () -> bool
27
27
  def content_type: () -> ContentType
28
28
  def complete?: () -> bool
29
29
 
30
+ def json: (?json_options opts) -> untyped
31
+
32
+ def form: () -> Hash[String, untyped]
33
+
30
34
  private
31
35
 
32
36
  def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
33
37
  def no_data?: () -> bool
34
38
 
39
+ def decode:(String format, ?untyped options) -> untyped
40
+
35
41
  class Body
36
42
  include _Reader
37
43
  include _ToS
@@ -73,7 +79,7 @@ module HTTPX
73
79
 
74
80
  private
75
81
 
76
- def initialize: (String?, String?) -> untyped
82
+ def initialize: (String? header_value) -> void
77
83
  end
78
84
 
79
85
  class ErrorResponse
data/sig/selector.rbs CHANGED
@@ -1,20 +1,22 @@
1
1
  module HTTPX
2
2
  class Selector
3
+ type selectable = Connection | Resolver::Native | Resolver::HTTPS
4
+
3
5
  READABLE: Array[Symbol]
4
6
  WRITABLE: Array[Symbol]
5
- @selectables: Array[_ToIO]
7
+ @selectables: Array[selectable]
6
8
 
7
- def register: (_ToIO) -> void
8
- def deregister: (_ToIO) -> void
9
+ def register: (selectable) -> void
10
+ def deregister: (selectable) -> void
9
11
 
10
- def select: (Numeric? interval) { (_ToIO) -> void } -> void
12
+ def select: (Numeric? interval) { (selectable) -> void } -> void
11
13
 
12
14
  private
13
15
 
14
16
  def initialize: () -> untyped
15
17
 
16
- def select_many: (Numeric? interval) { (_ToIO) -> void } -> void
17
- def select_one: (Numeric? interval) { (_ToIO) -> void } -> void
18
+ def select_many: (Numeric? interval) { (selectable) -> void } -> void
19
+ def select_one: (Numeric? interval) { (selectable) -> void } -> void
18
20
  end
19
21
 
20
22
  type io_interests = :r | :w | :rw
data/sig/session.rbs CHANGED
@@ -9,25 +9,19 @@ module HTTPX
9
9
  @responses: Hash[Request, response]
10
10
  @persistent: bool?
11
11
 
12
+ def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
13
+
14
+ def self.default_options: -> Options
15
+
12
16
  def wrap: () { (instance) -> void } -> void
13
17
 
14
18
  def close: (*untyped) -> void
15
19
 
16
- def request: (*Request, **untyped) -> (response | Array[response])
17
- | (*untyped, **untyped) -> (response | Array[response])
18
-
19
20
  def build_request: (String | verb, generic_uri, ?options) -> Request
20
21
 
21
- # def self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
22
- # | (Symbol | Module, ?options) -> singleton(Session)
23
-
24
-
25
-
26
- def self.default_options: -> Options
27
-
28
22
  private
29
23
 
30
- def initialize: (?options) { (instance) -> void } -> untyped
24
+ def initialize: (?options) { (self) -> void } -> untyped
31
25
  | (?options) -> untyped
32
26
 
33
27
  def pool: -> Pool
@@ -49,10 +43,10 @@ module HTTPX
49
43
 
50
44
  def build_connection: (URI::Generic, Options) -> Connection
51
45
 
52
- def send_requests: (*Request, options) -> Array[response]
46
+ def send_requests: (*Request) -> Array[response]
53
47
 
54
- def _send_requests: (Array[Request], Options) -> Array[Connection]
48
+ def _send_requests: (Array[Request]) -> Array[Connection]
55
49
 
56
- def receive_requests: (Array[Request], Array[Connection], options) -> Array[response]
50
+ def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
57
51
  end
58
52
  end
@@ -7,6 +7,7 @@ module HTTPX::Transcoder
7
7
 
8
8
  module Form
9
9
  def self?.encode: (urlencoded_input form) -> Encoder
10
+ def self?.decode: (HTTPX::Response response) -> _Decoder
10
11
 
11
12
  class Encoder
12
13
  extend Forwardable
@@ -1,6 +1,7 @@
1
1
  module HTTPX::Transcoder
2
2
  module JSON
3
3
  def self?.encode: (_ToJson json) -> Encoder
4
+ def self?.decode: (HTTPX::Response response) -> _Decoder
4
5
 
5
6
  class Encoder
6
7
  extend Forwardable
data/sig/transcoder.rbs CHANGED
@@ -6,9 +6,10 @@ module HTTPX
6
6
  | () -> Hash[String, _Encode]
7
7
 
8
8
  def self?.register: (String tag, _Encode handler) -> void
9
-
10
- def self?.normalize_keys: (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> void } -> void
11
- | (_ToS key, untyped value, Proc? cond) { (String, untyped) -> void } -> void
9
+
10
+ def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?(^(untyped value) -> bool | nil) cond) { (String, ?untyped) -> U } -> U
11
+
12
+ def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth) -> void
12
13
 
13
14
  interface _Encode
14
15
  def encode: (untyped payload) -> (_Encoder | _Each[String])
@@ -19,7 +20,7 @@ module HTTPX
19
20
  end
20
21
 
21
22
  interface _Decoder
22
- def decode: (string) -> String
23
+ def call: (Response response, untyped options) -> untyped
23
24
  end
24
25
  end
25
26
  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.16.1
4
+ version: 0.17.0
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-08-09 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -75,6 +75,7 @@ extra_rdoc_files:
75
75
  - doc/release_notes/0_15_4.md
76
76
  - doc/release_notes/0_16_0.md
77
77
  - doc/release_notes/0_16_1.md
78
+ - doc/release_notes/0_17_0.md
78
79
  - doc/release_notes/0_1_0.md
79
80
  - doc/release_notes/0_2_0.md
80
81
  - doc/release_notes/0_2_1.md
@@ -129,6 +130,7 @@ files:
129
130
  - doc/release_notes/0_15_4.md
130
131
  - doc/release_notes/0_16_0.md
131
132
  - doc/release_notes/0_16_1.md
133
+ - doc/release_notes/0_17_0.md
132
134
  - doc/release_notes/0_1_0.md
133
135
  - doc/release_notes/0_2_0.md
134
136
  - doc/release_notes/0_2_1.md
@@ -199,6 +201,7 @@ files:
199
201
  - lib/httpx/plugins/h2c.rb
200
202
  - lib/httpx/plugins/internal_telemetry.rb
201
203
  - lib/httpx/plugins/multipart.rb
204
+ - lib/httpx/plugins/multipart/decoder.rb
202
205
  - lib/httpx/plugins/multipart/encoder.rb
203
206
  - lib/httpx/plugins/multipart/mime_type_detector.rb
204
207
  - lib/httpx/plugins/multipart/part.rb