httpx 0.20.5 → 0.21.1

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/README.md +44 -26
  3. data/doc/release_notes/0_13_0.md +1 -1
  4. data/doc/release_notes/0_21_0.md +96 -0
  5. data/doc/release_notes/0_21_1.md +12 -0
  6. data/lib/httpx/connection/http1.rb +2 -1
  7. data/lib/httpx/connection.rb +47 -3
  8. data/lib/httpx/errors.rb +18 -0
  9. data/lib/httpx/extensions.rb +8 -4
  10. data/lib/httpx/io/unix.rb +1 -1
  11. data/lib/httpx/options.rb +7 -3
  12. data/lib/httpx/plugins/circuit_breaker/circuit.rb +76 -0
  13. data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +44 -0
  14. data/lib/httpx/plugins/circuit_breaker.rb +115 -0
  15. data/lib/httpx/plugins/cookies.rb +1 -1
  16. data/lib/httpx/plugins/expect.rb +1 -1
  17. data/lib/httpx/plugins/multipart/decoder.rb +1 -1
  18. data/lib/httpx/plugins/proxy.rb +7 -1
  19. data/lib/httpx/plugins/retries.rb +1 -1
  20. data/lib/httpx/plugins/webdav.rb +78 -0
  21. data/lib/httpx/request.rb +15 -25
  22. data/lib/httpx/resolver/https.rb +2 -7
  23. data/lib/httpx/resolver/native.rb +19 -8
  24. data/lib/httpx/response.rb +27 -9
  25. data/lib/httpx/timers.rb +3 -0
  26. data/lib/httpx/transcoder/form.rb +1 -1
  27. data/lib/httpx/transcoder/json.rb +19 -3
  28. data/lib/httpx/transcoder/xml.rb +57 -0
  29. data/lib/httpx/transcoder.rb +1 -0
  30. data/lib/httpx/version.rb +1 -1
  31. data/sig/buffer.rbs +1 -1
  32. data/sig/chainable.rbs +1 -0
  33. data/sig/connection.rbs +12 -4
  34. data/sig/errors.rbs +13 -0
  35. data/sig/io.rbs +6 -0
  36. data/sig/options.rbs +4 -1
  37. data/sig/plugins/circuit_breaker.rbs +61 -0
  38. data/sig/plugins/compression/brotli.rbs +1 -1
  39. data/sig/plugins/compression/deflate.rbs +1 -1
  40. data/sig/plugins/compression/gzip.rbs +3 -3
  41. data/sig/plugins/compression.rbs +1 -1
  42. data/sig/plugins/multipart.rbs +1 -1
  43. data/sig/plugins/proxy/socks5.rbs +3 -2
  44. data/sig/plugins/proxy.rbs +1 -1
  45. data/sig/registry.rbs +5 -4
  46. data/sig/request.rbs +7 -1
  47. data/sig/resolver/native.rbs +5 -2
  48. data/sig/response.rbs +3 -1
  49. data/sig/timers.rbs +1 -1
  50. data/sig/transcoder/json.rbs +4 -1
  51. data/sig/transcoder/xml.rbs +21 -0
  52. data/sig/transcoder.rbs +2 -2
  53. data/sig/utils.rbs +2 -2
  54. metadata +15 -3
data/sig/connection.rbs CHANGED
@@ -28,7 +28,7 @@ module HTTPX
28
28
  attr_reader options: Options
29
29
  attr_writer timers: Timers
30
30
 
31
- @origins: Array[URI::Generic]
31
+ @type: io_type
32
32
  @window_size: Integer
33
33
  @read_buffer: Buffer
34
34
  @write_buffer: Buffer
@@ -40,7 +40,7 @@ module HTTPX
40
40
 
41
41
  def addresses=: (Array[ipaddr]) -> void
42
42
 
43
- def match?: (URI::Generic, options) -> bool
43
+ def match?: (URI::Generic uri, Options options) -> bool
44
44
 
45
45
  def mergeable?: (Connection) -> bool
46
46
 
@@ -54,13 +54,15 @@ module HTTPX
54
54
 
55
55
  def match_altsvcs?: (URI::Generic uri) -> bool
56
56
 
57
+ def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
58
+
57
59
  def connecting?: () -> bool
58
60
 
59
61
  def inflight?: () -> boolish
60
62
 
61
63
  def interests: () -> io_interests?
62
64
 
63
- def to_io: () -> IO
65
+ def to_io: () -> ::IO
64
66
 
65
67
  def call: () -> void
66
68
 
@@ -77,7 +79,7 @@ module HTTPX
77
79
 
78
80
  private
79
81
 
80
- def initialize: (String, URI::Generic, options) -> untyped
82
+ def initialize: (io_type, URI::Generic, options) -> untyped
81
83
 
82
84
  def connect: () -> void
83
85
 
@@ -103,5 +105,11 @@ module HTTPX
103
105
  def handle_error: (StandardError) -> void
104
106
 
105
107
  def purge_after_closed: () -> void
108
+
109
+ def set_request_timeouts: (Request request) -> void
110
+
111
+ def write_timeout_callback: (Request request, Numeric write_timeout) -> void
112
+
113
+ def read_timeout_callback: (Request request, Numeric read_timeout, ?singleton(RequestTimeoutError) error_type) -> void
106
114
  end
107
115
  end
data/sig/errors.rbs CHANGED
@@ -23,6 +23,19 @@ module HTTPX
23
23
  class ResolveTimeoutError < TimeoutError
24
24
  end
25
25
 
26
+ class RequestTimeoutError < TimeoutError
27
+ attr_reader request: Request
28
+ attr_reader response: response?
29
+
30
+ def initialize: (Request request, response? response, Numeric timeout) -> void
31
+ end
32
+
33
+ class ReadTimeoutError < RequestTimeoutError
34
+ end
35
+
36
+ class WriteTimeoutError < RequestTimeoutError
37
+ end
38
+
26
39
  class ResolveError < Error
27
40
  end
28
41
 
data/sig/io.rbs ADDED
@@ -0,0 +1,6 @@
1
+ module HTTPX
2
+ type io_type = "udp" | "tcp" | "ssl" | "unix"
3
+
4
+ module IO
5
+ end
6
+ end
data/sig/options.rbs CHANGED
@@ -10,7 +10,7 @@ module HTTPX
10
10
  SETTINGS_TIMEOUT: Integer
11
11
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
12
12
 
13
- type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout
13
+ type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout | :read_timeout | :write_timeout | :request_timeout
14
14
  type timeout = Hash[timeout_type, Numeric]
15
15
 
16
16
  def self.new: (?options) -> instance
@@ -65,6 +65,9 @@ module HTTPX
65
65
  # body
66
66
  attr_reader origin: URI::Generic?
67
67
 
68
+ # base_path
69
+ attr_reader base_path: String?
70
+
68
71
  # ssl
69
72
 
70
73
  # http2_settings
@@ -0,0 +1,61 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module CircuitBreaker
4
+
5
+ class CircuitStore
6
+ @circuits: Hash[String, Circuit]
7
+
8
+ def try_open: (generic_uri uri, response response) -> void
9
+
10
+ def try_respond: (Request request) -> response?
11
+
12
+ private
13
+
14
+ def get_circuit_for_uri: (generic_uri uri) -> Circuit
15
+
16
+ def initialize: (Options & _CircuitOptions options) -> void
17
+ end
18
+
19
+ class Circuit
20
+ @state: :closed | :open | :half_open
21
+ @max_attempts: Integer
22
+ @reset_attempts_in: Float
23
+ @break_in: Float
24
+ @circuit_breaker_half_open_drip_rate: Float
25
+ @attempts: Integer
26
+
27
+ @response: response?
28
+ @opened_at: Float?
29
+ @attempted_at: Float?
30
+
31
+ def respond: () -> response?
32
+
33
+ def try_open: (response) -> void
34
+
35
+ def try_close: () -> void
36
+
37
+ private
38
+
39
+ def initialize: (Integer max_attempts, Float reset_attempts_in, Float break_in, Float circuit_breaker_half_open_drip_rate) -> void
40
+ end
41
+
42
+ interface _CircuitOptions
43
+ def circuit_breaker_max_attempts: () -> Integer
44
+ def circuit_breaker_reset_attempts_in: () -> Float
45
+ def circuit_breaker_break_in: () -> Float
46
+ def circuit_breaker_half_open_drip_rate: () -> Float
47
+ def circuit_breaker_break_on: () -> (^(Response) -> boolish | nil)
48
+ end
49
+
50
+ def self.load_dependencies: (singleton(Session)) -> void
51
+ def self.extra_options: (Options) -> (Options & _CircuitOptions)
52
+
53
+ module InstanceMethods
54
+ @circuit_store: CircuitStore
55
+ end
56
+
57
+ end
58
+
59
+ type sessionCircuitBreaker = Session & CircuitBreaker::InstanceMethods
60
+ end
61
+ end
@@ -6,7 +6,7 @@ module HTTPX
6
6
  def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
- def self?.decoder: (Numeric bytesize) -> Inflater
9
+ def self?.decoder: (Integer | Float bytesize) -> Inflater
10
10
 
11
11
  module Deflater
12
12
  extend _Deflater
@@ -6,7 +6,7 @@ module HTTPX
6
6
  def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
- def self?.inflater: (Numeric bytesize) -> GZIP::Inflater
9
+ def self?.inflater: (Integer | Float bytesize) -> GZIP::Inflater
10
10
 
11
11
  module Deflater
12
12
  extend _Deflater
@@ -6,15 +6,15 @@ module HTTPX
6
6
  def self.configure: (singleton(Session)) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
9
- def self?.inflater: (Numeric bytesize) -> Inflater
9
+ def self?.inflater: (Integer | Float bytesize) -> Inflater
10
10
 
11
11
  class Deflater
12
12
  include _Deflater
13
13
 
14
14
  @compressed_chunk: String
15
-
15
+
16
16
  private
17
-
17
+
18
18
  def initialize: () -> untyped
19
19
  def write: (string) -> void
20
20
  def compressed_chunk: () -> String
@@ -13,7 +13,7 @@ module HTTPX
13
13
  interface _Inflater
14
14
  def inflate: (string) -> String
15
15
 
16
- def initialize: (Numeric bytesize) -> untyped
16
+ def initialize: (Integer | Float bytesize) -> untyped
17
17
  end
18
18
 
19
19
  def self.configure: (singleton(Session)) -> void
@@ -61,7 +61,7 @@ module HTTPX
61
61
  @boundary: String
62
62
  @intermediate_boundary: String
63
63
 
64
- def call: (Response response, untyped) -> Hash[String, untyped]
64
+ def call: (Response response, *untyped) -> Hash[String, untyped]
65
65
 
66
66
  private
67
67
 
@@ -4,14 +4,15 @@ module HTTPX
4
4
  module Plugins
5
5
  module Proxy
6
6
  module Socks5
7
-
7
+ VERSION: Integer
8
+
8
9
  module ConnectionMethods
9
10
  def __socks5_proxy_connect: () -> void
10
11
  def __socks5_on_packet: (String packet) -> void
11
12
  def __socks5_check_version: (int) -> void
12
13
  def __on_socks5_error: (string) -> void
13
14
  end
14
-
15
+
15
16
  class SocksParser
16
17
  include Callbacks
17
18
 
@@ -21,7 +21,7 @@ module HTTPX
21
21
 
22
22
  private
23
23
 
24
- def initialize: (uri: generic_uri, ?scheme: String, ?username: String, ?password: String, **extra) -> untyped
24
+ def initialize: (uri: generic_uri, ?scheme: String, ?username: String, ?password: String, **untyped) -> untyped
25
25
  end
26
26
 
27
27
  def self.configure: (singleton(Session)) -> void
data/sig/registry.rbs CHANGED
@@ -1,12 +1,13 @@
1
- module HTTPX::Registry[T, V]
1
+ module HTTPX::Registry[unchecked out T, unchecked out V]
2
2
  class Error < HTTPX::Error
3
3
  end
4
4
 
5
5
  # type registrable = Symbol | String | Class
6
6
 
7
- def self.registry: (T tag) -> Class
8
- | () -> Hash[T, V]
9
- def self.register: (T tag, V handler) -> void
7
+ def self.registry: [T, V] (T) -> Class
8
+ | [T, V] () -> Hash[T, V]
9
+
10
+ def self.register: [T, V] (T tag, V handler) -> void
10
11
 
11
12
  def registry: (?T tag) -> V
12
13
  end
data/sig/request.rbs CHANGED
@@ -50,6 +50,12 @@ module HTTPX
50
50
 
51
51
  def trailers?: () -> boolish
52
52
 
53
+ def read_timeout: () -> Numeric
54
+
55
+ def write_timeout: () -> Numeric
56
+
57
+ def request_timeout: () -> Numeric
58
+
53
59
  class Body
54
60
  @headers: Headers
55
61
  @body: body_encoder?
@@ -61,7 +67,7 @@ module HTTPX
61
67
 
62
68
  def rewind: () -> void
63
69
  def empty?: () -> bool
64
- def bytesize: () -> Numeric
70
+ def bytesize: () -> (Integer | Float)
65
71
  def stream: (Transcoder::_Encoder) -> bodyIO
66
72
  def unbounded_body?: () -> bool
67
73
  def chunked?: () -> bool
@@ -10,7 +10,10 @@ module HTTPX
10
10
  @family: ip_family
11
11
  @options: Options
12
12
  @ns_index: Integer
13
- @nameserver: String
13
+ @nameserver: Array[String]?
14
+ @ndots: Integer
15
+ @start_timeout: Float?
16
+ @search: Array[String]
14
17
  @_timeouts: Array[Numeric]
15
18
  @timeouts: Hash[String, Array[Numeric]]
16
19
  @connections: Array[Connection]
@@ -37,7 +40,7 @@ module HTTPX
37
40
 
38
41
  def consume: () -> void
39
42
 
40
- def do_retry: (?Numeric loop_time) -> void
43
+ def do_retry: (?Numeric? loop_time) -> void
41
44
 
42
45
  def dread: (Integer) -> void
43
46
  | () -> void
data/sig/response.rbs CHANGED
@@ -1,5 +1,7 @@
1
1
  module HTTPX
2
2
  interface _Response
3
+ def finished?: () -> bool
4
+
3
5
  def raise_for_status: () -> self
4
6
 
5
7
  def error: () -> StandardError?
@@ -61,7 +63,7 @@ module HTTPX
61
63
  def each: () { (String) -> void } -> void
62
64
  | () -> Enumerable[String]
63
65
 
64
- def bytesize: () -> Numeric
66
+ def bytesize: () -> (Integer | Float)
65
67
  def empty?: () -> bool
66
68
  def copy_to: (String | File | _Writer destination) -> void
67
69
  def close: () -> void
data/sig/timers.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  class Timers
3
3
  @intervals: Array[Interval]
4
- @next_interval_at: Numeric
4
+ @next_interval_at: Float
5
5
 
6
6
  def after: (Numeric interval_in_secs) { () -> void } -> void
7
7
 
@@ -5,6 +5,9 @@ module HTTPX::Transcoder
5
5
  def self?.encode: (_ToJson json) -> Encoder
6
6
  def self?.decode: (HTTPX::Response response) -> _Decoder
7
7
 
8
+ def self?.json_load: (string source, ?json_options) -> untyped
9
+ def self?.json_dump: (_ToJson obj, *untyped) -> String
10
+
8
11
  class Encoder
9
12
  extend Forwardable
10
13
  include _Encoder
@@ -17,7 +20,7 @@ module HTTPX::Transcoder
17
20
 
18
21
  private
19
22
 
20
- def initialize: (_ToJson json) -> untyped
23
+ def initialize: (_ToJson json) -> void
21
24
  end
22
25
  end
23
26
  end
@@ -0,0 +1,21 @@
1
+ module HTTPX::Transcoder
2
+ module XML
3
+
4
+ def self?.encode: (untyped xml) -> Encoder
5
+ def self?.decode: (HTTPX::Response response) -> _Decoder
6
+
7
+ class Encoder
8
+ @raw: untyped # can be nokogiri object
9
+
10
+ def content_type: () -> String
11
+
12
+ def bytesize: () -> (Integer | Float)
13
+
14
+ def to_s: () -> String
15
+
16
+ private
17
+
18
+ def initialize: (String xml) -> void
19
+ end
20
+ end
21
+ end
data/sig/transcoder.rbs CHANGED
@@ -18,11 +18,11 @@ module HTTPX
18
18
  end
19
19
 
20
20
  interface _Encoder
21
- def bytesize: () -> Numeric
21
+ def bytesize: () -> (Integer | Float)
22
22
  end
23
23
 
24
24
  interface _Decoder
25
- def call: (Response response, untyped options) -> untyped
25
+ def call: (Response response, *untyped) -> untyped
26
26
  end
27
27
  end
28
28
  end
data/sig/utils.rbs CHANGED
@@ -4,9 +4,9 @@ module HTTPX
4
4
 
5
5
  def self?.parse_retry_after: (String) -> Numeric
6
6
 
7
- def self?.now: () -> Numeric
7
+ def self?.now: () -> Float
8
8
 
9
- def self?.elapsed_time: (Numeric monotonic_time) -> Numeric
9
+ def self?.elapsed_time: (Integer | Float monotonic_time) -> Float
10
10
 
11
11
  def self?.to_uri: (generic_uri uri) -> URI::Generic
12
12
  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.20.5
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -86,6 +86,8 @@ extra_rdoc_files:
86
86
  - doc/release_notes/0_20_3.md
87
87
  - doc/release_notes/0_20_4.md
88
88
  - doc/release_notes/0_20_5.md
89
+ - doc/release_notes/0_21_0.md
90
+ - doc/release_notes/0_21_1.md
89
91
  - doc/release_notes/0_2_0.md
90
92
  - doc/release_notes/0_2_1.md
91
93
  - doc/release_notes/0_3_0.md
@@ -164,6 +166,8 @@ files:
164
166
  - doc/release_notes/0_20_3.md
165
167
  - doc/release_notes/0_20_4.md
166
168
  - doc/release_notes/0_20_5.md
169
+ - doc/release_notes/0_21_0.md
170
+ - doc/release_notes/0_21_1.md
167
171
  - doc/release_notes/0_2_0.md
168
172
  - doc/release_notes/0_2_1.md
169
173
  - doc/release_notes/0_3_0.md
@@ -217,6 +221,9 @@ files:
217
221
  - lib/httpx/plugins/aws_sdk_authentication.rb
218
222
  - lib/httpx/plugins/aws_sigv4.rb
219
223
  - lib/httpx/plugins/basic_authentication.rb
224
+ - lib/httpx/plugins/circuit_breaker.rb
225
+ - lib/httpx/plugins/circuit_breaker/circuit.rb
226
+ - lib/httpx/plugins/circuit_breaker/circuit_store.rb
220
227
  - lib/httpx/plugins/compression.rb
221
228
  - lib/httpx/plugins/compression/brotli.rb
222
229
  - lib/httpx/plugins/compression/deflate.rb
@@ -253,6 +260,7 @@ files:
253
260
  - lib/httpx/plugins/stream.rb
254
261
  - lib/httpx/plugins/upgrade.rb
255
262
  - lib/httpx/plugins/upgrade/h2.rb
263
+ - lib/httpx/plugins/webdav.rb
256
264
  - lib/httpx/pmatch_extensions.rb
257
265
  - lib/httpx/pool.rb
258
266
  - lib/httpx/punycode.rb
@@ -275,6 +283,7 @@ files:
275
283
  - lib/httpx/transcoder/chunker.rb
276
284
  - lib/httpx/transcoder/form.rb
277
285
  - lib/httpx/transcoder/json.rb
286
+ - lib/httpx/transcoder/xml.rb
278
287
  - lib/httpx/utils.rb
279
288
  - lib/httpx/version.rb
280
289
  - sig/buffer.rbs
@@ -287,6 +296,7 @@ files:
287
296
  - sig/errors.rbs
288
297
  - sig/headers.rbs
289
298
  - sig/httpx.rbs
299
+ - sig/io.rbs
290
300
  - sig/loggable.rbs
291
301
  - sig/options.rbs
292
302
  - sig/parser/http1.rbs
@@ -298,6 +308,7 @@ files:
298
308
  - sig/plugins/aws_sdk_authentication.rbs
299
309
  - sig/plugins/aws_sigv4.rbs
300
310
  - sig/plugins/basic_authentication.rbs
311
+ - sig/plugins/circuit_breaker.rbs
301
312
  - sig/plugins/compression.rbs
302
313
  - sig/plugins/compression/brotli.rbs
303
314
  - sig/plugins/compression/deflate.rbs
@@ -342,6 +353,7 @@ files:
342
353
  - sig/transcoder/chunker.rbs
343
354
  - sig/transcoder/form.rbs
344
355
  - sig/transcoder/json.rbs
356
+ - sig/transcoder/xml.rbs
345
357
  - sig/utils.rbs
346
358
  homepage: https://gitlab.com/honeyryderchuck/httpx
347
359
  licenses:
@@ -368,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
368
380
  - !ruby/object:Gem::Version
369
381
  version: '0'
370
382
  requirements: []
371
- rubygems_version: 3.3.7
383
+ rubygems_version: 3.2.32
372
384
  signing_key:
373
385
  specification_version: 4
374
386
  summary: HTTPX, to the future, and beyond