httpx 0.16.1 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/doc/release_notes/0_17_0.md +49 -0
  4. data/doc/release_notes/0_18_0.md +69 -0
  5. data/doc/release_notes/0_18_1.md +12 -0
  6. data/doc/release_notes/0_18_2.md +10 -0
  7. data/lib/httpx/adapters/datadog.rb +1 -1
  8. data/lib/httpx/adapters/faraday.rb +5 -3
  9. data/lib/httpx/adapters/webmock.rb +9 -3
  10. data/lib/httpx/altsvc.rb +2 -2
  11. data/lib/httpx/chainable.rb +4 -4
  12. data/lib/httpx/connection/http1.rb +23 -14
  13. data/lib/httpx/connection/http2.rb +35 -17
  14. data/lib/httpx/connection.rb +74 -76
  15. data/lib/httpx/domain_name.rb +1 -1
  16. data/lib/httpx/extensions.rb +50 -4
  17. data/lib/httpx/headers.rb +1 -1
  18. data/lib/httpx/io/ssl.rb +5 -1
  19. data/lib/httpx/io/tls.rb +7 -7
  20. data/lib/httpx/loggable.rb +5 -5
  21. data/lib/httpx/options.rb +35 -13
  22. data/lib/httpx/parser/http1.rb +10 -6
  23. data/lib/httpx/plugins/aws_sdk_authentication.rb +42 -18
  24. data/lib/httpx/plugins/aws_sigv4.rb +9 -11
  25. data/lib/httpx/plugins/compression.rb +5 -3
  26. data/lib/httpx/plugins/cookies/jar.rb +1 -1
  27. data/lib/httpx/plugins/digest_authentication.rb +4 -4
  28. data/lib/httpx/plugins/expect.rb +7 -3
  29. data/lib/httpx/plugins/grpc/message.rb +2 -2
  30. data/lib/httpx/plugins/grpc.rb +3 -3
  31. data/lib/httpx/plugins/h2c.rb +7 -3
  32. data/lib/httpx/plugins/internal_telemetry.rb +8 -8
  33. data/lib/httpx/plugins/multipart/decoder.rb +187 -0
  34. data/lib/httpx/plugins/multipart/mime_type_detector.rb +3 -3
  35. data/lib/httpx/plugins/multipart/part.rb +2 -2
  36. data/lib/httpx/plugins/multipart.rb +16 -2
  37. data/lib/httpx/plugins/ntlm_authentication.rb +4 -4
  38. data/lib/httpx/plugins/proxy/ssh.rb +11 -4
  39. data/lib/httpx/plugins/proxy.rb +6 -4
  40. data/lib/httpx/plugins/response_cache/store.rb +55 -0
  41. data/lib/httpx/plugins/response_cache.rb +88 -0
  42. data/lib/httpx/plugins/retries.rb +36 -14
  43. data/lib/httpx/plugins/stream.rb +3 -4
  44. data/lib/httpx/pool.rb +39 -13
  45. data/lib/httpx/registry.rb +1 -1
  46. data/lib/httpx/request.rb +12 -13
  47. data/lib/httpx/resolver/https.rb +5 -7
  48. data/lib/httpx/resolver/native.rb +4 -2
  49. data/lib/httpx/resolver/resolver_mixin.rb +2 -1
  50. data/lib/httpx/resolver/system.rb +2 -0
  51. data/lib/httpx/resolver.rb +2 -2
  52. data/lib/httpx/response.rb +60 -44
  53. data/lib/httpx/selector.rb +16 -19
  54. data/lib/httpx/session.rb +22 -15
  55. data/lib/httpx/session2.rb +1 -1
  56. data/lib/httpx/timers.rb +84 -0
  57. data/lib/httpx/transcoder/body.rb +2 -1
  58. data/lib/httpx/transcoder/form.rb +20 -0
  59. data/lib/httpx/transcoder/json.rb +12 -0
  60. data/lib/httpx/transcoder.rb +62 -1
  61. data/lib/httpx/utils.rb +10 -2
  62. data/lib/httpx/version.rb +1 -1
  63. data/lib/httpx.rb +1 -0
  64. data/sig/buffer.rbs +2 -2
  65. data/sig/chainable.rbs +7 -1
  66. data/sig/connection/http1.rbs +15 -4
  67. data/sig/connection/http2.rbs +19 -5
  68. data/sig/connection.rbs +15 -9
  69. data/sig/headers.rbs +19 -18
  70. data/sig/options.rbs +13 -5
  71. data/sig/parser/http1.rbs +3 -3
  72. data/sig/plugins/aws_sdk_authentication.rbs +22 -4
  73. data/sig/plugins/aws_sigv4.rbs +12 -3
  74. data/sig/plugins/basic_authentication.rbs +1 -1
  75. data/sig/plugins/multipart.rbs +64 -8
  76. data/sig/plugins/proxy.rbs +6 -6
  77. data/sig/plugins/response_cache.rbs +35 -0
  78. data/sig/plugins/retries.rbs +3 -0
  79. data/sig/pool.rbs +6 -0
  80. data/sig/request.rbs +11 -8
  81. data/sig/resolver/native.rbs +2 -1
  82. data/sig/resolver/resolver_mixin.rbs +1 -1
  83. data/sig/resolver/system.rbs +3 -1
  84. data/sig/response.rbs +11 -4
  85. data/sig/selector.rbs +8 -6
  86. data/sig/session.rbs +8 -14
  87. data/sig/timers.rbs +32 -0
  88. data/sig/transcoder/form.rbs +1 -0
  89. data/sig/transcoder/json.rbs +1 -0
  90. data/sig/transcoder.rbs +5 -4
  91. data/sig/utils.rbs +4 -0
  92. metadata +18 -17
data/sig/request.rbs CHANGED
@@ -1,12 +1,13 @@
1
1
  module HTTPX
2
2
  class Request
3
+ extend Forwardable
3
4
  include Callbacks
4
5
 
5
- METHODS: Array[verb]
6
+ METHODS: Array[Symbol]
6
7
  USER_AGENT: String
7
8
 
8
- attr_reader verb: verb
9
- attr_reader uri: URI::HTTP | URI::HTTPS
9
+ attr_reader verb: Symbol
10
+ attr_reader uri: URI::Generic
10
11
  attr_reader headers: Headers
11
12
  attr_reader body: Body
12
13
  attr_reader state: Symbol
@@ -14,13 +15,13 @@ module HTTPX
14
15
  attr_reader response: response?
15
16
  attr_reader drain_error: StandardError?
16
17
 
17
- def initialize: (verb | String, generic_uri, ?options?) -> untyped
18
+ def initialize: (Symbol | String, generic_uri, ?options) -> untyped
18
19
 
19
20
  def interests: () -> (:r | :w)
20
21
 
21
- def merge_headers: (_Each[[headers_key, headers_value]]) -> void
22
+ def merge_headers: (_Each[[String, headers_value]]) -> void
22
23
 
23
- def scheme: () -> ("http" | "https")
24
+ def scheme: () -> String
24
25
 
25
26
  def response=: (response) -> void
26
27
 
@@ -49,6 +50,7 @@ module HTTPX
49
50
  def each: () { (String) -> void } -> void
50
51
  | () -> Enumerable[String]
51
52
 
53
+ def rewind: () -> void
52
54
  def empty?: () -> bool
53
55
  def bytesize: () -> Numeric
54
56
  def stream: (Transcoder::_Encoder) -> bodyIO
@@ -59,8 +61,9 @@ module HTTPX
59
61
  end
60
62
 
61
63
  class ProcIO
62
- include _Writer
63
- def initialize: (^(_ToS) -> void) -> untyped
64
+ def initialize: (^(String) -> void) -> untyped
65
+
66
+ def write: (String data) -> Integer
64
67
  end
65
68
  end
66
69
  end
@@ -19,7 +19,8 @@ module HTTPX
19
19
  @queries: Hash[String, Connection]
20
20
  @read_buffer: String
21
21
  @write_buffer: Buffer
22
- @state: :idle | :open | :closed
22
+
23
+ attr_reader state: Symbol
23
24
 
24
25
  def closed?: () -> bool
25
26
 
@@ -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,9 @@ 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
+
8
+ attr_reader state: Symbol
7
9
 
8
10
  def closed?: () -> true
9
11
 
data/sig/response.rbs CHANGED
@@ -1,6 +1,8 @@
1
1
  module HTTPX
2
2
  interface _Response
3
- def raise_for_status: () -> void
3
+ def raise_for_status: () -> self
4
+
5
+ def error: () -> StandardError?
4
6
  end
5
7
 
6
8
  class Response
@@ -22,16 +24,22 @@ module HTTPX
22
24
  def close: () -> void
23
25
  def uri: () -> URI::Generic
24
26
 
25
- def merge_headers: (_Each[[headers_key, headers_value]]) -> void
27
+ def merge_headers: (_Each[[String, headers_value]]) -> void
26
28
  def bodyless?: () -> bool
27
29
  def content_type: () -> ContentType
28
30
  def complete?: () -> bool
29
31
 
32
+ def json: (?json_options opts) -> untyped
33
+
34
+ def form: () -> Hash[String, untyped]
35
+
30
36
  private
31
37
 
32
38
  def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
33
39
  def no_data?: () -> bool
34
40
 
41
+ def decode:(String format, ?untyped options) -> untyped
42
+
35
43
  class Body
36
44
  include _Reader
37
45
  include _ToS
@@ -73,7 +81,7 @@ module HTTPX
73
81
 
74
82
  private
75
83
 
76
- def initialize: (String?, String?) -> untyped
84
+ def initialize: (String? header_value) -> void
77
85
  end
78
86
 
79
87
  class ErrorResponse
@@ -83,7 +91,6 @@ module HTTPX
83
91
  @options: Options
84
92
 
85
93
  attr_reader request: Request
86
- attr_reader error: Exception
87
94
 
88
95
  def status: () -> (Integer | _ToS)
89
96
 
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
data/sig/timers.rbs ADDED
@@ -0,0 +1,32 @@
1
+ module HTTPX
2
+ class Timers
3
+ @interval: Array[Interval]
4
+
5
+ def after: (Numeric interval_in_secs) { () -> void } -> void
6
+
7
+ def wait_interval: () -> Numeric?
8
+
9
+ def fire: (?StandardError error) -> void
10
+
11
+ def cancel: () -> void
12
+
13
+ private
14
+
15
+ def initialize: () -> void
16
+
17
+ class Interval
18
+ include Comparable
19
+
20
+ attr_reader interval: Numeric
21
+
22
+ def to_f: () -> Float
23
+
24
+ def <<: (^() -> void) -> void
25
+
26
+ def elapse: (Numeric elapsed) -> Numeric
27
+ private
28
+
29
+ def initialize: (Numeric interval) -> void
30
+ end
31
+ end
32
+ 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
data/sig/utils.rbs CHANGED
@@ -4,6 +4,10 @@ module HTTPX
4
4
 
5
5
  def self?.parse_retry_after: (String) -> Numeric
6
6
 
7
+ def self?.now: () -> Numeric
8
+
9
+ def self?.elapsed_time: (Numeric monotonic_time) -> Numeric
10
+
7
11
  def self?.to_uri: (generic_uri uri) -> URI::Generic
8
12
  end
9
13
  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.18.2
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-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.1
27
- - !ruby/object:Gem::Dependency
28
- name: timers
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  description: A client library for making HTTP requests from Ruby.
42
28
  email:
43
29
  - cardoso_tiago@hotmail.com
@@ -75,6 +61,10 @@ extra_rdoc_files:
75
61
  - doc/release_notes/0_15_4.md
76
62
  - doc/release_notes/0_16_0.md
77
63
  - doc/release_notes/0_16_1.md
64
+ - doc/release_notes/0_17_0.md
65
+ - doc/release_notes/0_18_0.md
66
+ - doc/release_notes/0_18_1.md
67
+ - doc/release_notes/0_18_2.md
78
68
  - doc/release_notes/0_1_0.md
79
69
  - doc/release_notes/0_2_0.md
80
70
  - doc/release_notes/0_2_1.md
@@ -129,6 +119,10 @@ files:
129
119
  - doc/release_notes/0_15_4.md
130
120
  - doc/release_notes/0_16_0.md
131
121
  - doc/release_notes/0_16_1.md
122
+ - doc/release_notes/0_17_0.md
123
+ - doc/release_notes/0_18_0.md
124
+ - doc/release_notes/0_18_1.md
125
+ - doc/release_notes/0_18_2.md
132
126
  - doc/release_notes/0_1_0.md
133
127
  - doc/release_notes/0_2_0.md
134
128
  - doc/release_notes/0_2_1.md
@@ -199,6 +193,7 @@ files:
199
193
  - lib/httpx/plugins/h2c.rb
200
194
  - lib/httpx/plugins/internal_telemetry.rb
201
195
  - lib/httpx/plugins/multipart.rb
196
+ - lib/httpx/plugins/multipart/decoder.rb
202
197
  - lib/httpx/plugins/multipart/encoder.rb
203
198
  - lib/httpx/plugins/multipart/mime_type_detector.rb
204
199
  - lib/httpx/plugins/multipart/part.rb
@@ -211,6 +206,8 @@ files:
211
206
  - lib/httpx/plugins/proxy/ssh.rb
212
207
  - lib/httpx/plugins/push_promise.rb
213
208
  - lib/httpx/plugins/rate_limiter.rb
209
+ - lib/httpx/plugins/response_cache.rb
210
+ - lib/httpx/plugins/response_cache/store.rb
214
211
  - lib/httpx/plugins/retries.rb
215
212
  - lib/httpx/plugins/stream.rb
216
213
  - lib/httpx/plugins/upgrade.rb
@@ -229,6 +226,7 @@ files:
229
226
  - lib/httpx/selector.rb
230
227
  - lib/httpx/session.rb
231
228
  - lib/httpx/session2.rb
229
+ - lib/httpx/timers.rb
232
230
  - lib/httpx/transcoder.rb
233
231
  - lib/httpx/transcoder/body.rb
234
232
  - lib/httpx/transcoder/chunker.rb
@@ -275,6 +273,7 @@ files:
275
273
  - sig/plugins/proxy/ssh.rbs
276
274
  - sig/plugins/push_promise.rbs
277
275
  - sig/plugins/rate_limiter.rbs
276
+ - sig/plugins/response_cache.rbs
278
277
  - sig/plugins/retries.rbs
279
278
  - sig/plugins/stream.rbs
280
279
  - sig/plugins/upgrade.rbs
@@ -289,6 +288,7 @@ files:
289
288
  - sig/response.rbs
290
289
  - sig/selector.rbs
291
290
  - sig/session.rbs
291
+ - sig/timers.rbs
292
292
  - sig/transcoder.rbs
293
293
  - sig/transcoder/body.rbs
294
294
  - sig/transcoder/chunker.rbs
@@ -304,6 +304,7 @@ metadata:
304
304
  documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
305
305
  source_code_uri: https://gitlab.com/honeyryderchuck/httpx
306
306
  homepage_uri: https://honeyryderchuck.gitlab.io/httpx/
307
+ rubygems_mfa_required: 'true'
307
308
  post_install_message:
308
309
  rdoc_options: []
309
310
  require_paths:
@@ -319,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
320
  - !ruby/object:Gem::Version
320
321
  version: '0'
321
322
  requirements: []
322
- rubygems_version: 3.2.15
323
+ rubygems_version: 3.2.22
323
324
  signing_key:
324
325
  specification_version: 4
325
326
  summary: HTTPX, to the future, and beyond