httpx 1.8.1 → 1.8.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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_8_2.md +30 -0
  3. data/doc/release_notes/1_8_3.md +9 -0
  4. data/doc/release_notes/1_8_4.md +13 -0
  5. data/lib/httpx/adapters/webmock.rb +2 -1
  6. data/lib/httpx/buffer.rb +5 -0
  7. data/lib/httpx/callbacks.rb +2 -2
  8. data/lib/httpx/chainable.rb +2 -2
  9. data/lib/httpx/connection/http1.rb +1 -1
  10. data/lib/httpx/connection/http2.rb +69 -17
  11. data/lib/httpx/connection.rb +58 -14
  12. data/lib/httpx/errors.rb +3 -0
  13. data/lib/httpx/io/ssl.rb +18 -8
  14. data/lib/httpx/options.rb +21 -12
  15. data/lib/httpx/plugins/auth.rb +6 -5
  16. data/lib/httpx/plugins/cookies/cookie.rb +1 -1
  17. data/lib/httpx/plugins/cookies.rb +2 -2
  18. data/lib/httpx/plugins/follow_redirects.rb +28 -14
  19. data/lib/httpx/plugins/grpc/call.rb +4 -4
  20. data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -2
  21. data/lib/httpx/plugins/oauth.rb +4 -2
  22. data/lib/httpx/plugins/persistent.rb +15 -0
  23. data/lib/httpx/plugins/proxy/http.rb +27 -6
  24. data/lib/httpx/plugins/proxy.rb +13 -7
  25. data/lib/httpx/plugins/retries.rb +26 -9
  26. data/lib/httpx/plugins/server_sent_events.rb +2 -2
  27. data/lib/httpx/plugins/stream.rb +2 -2
  28. data/lib/httpx/plugins/tracing.rb +20 -7
  29. data/lib/httpx/request/body.rb +8 -5
  30. data/lib/httpx/request.rb +8 -5
  31. data/lib/httpx/resolver/multi.rb +2 -2
  32. data/lib/httpx/resolver/native.rb +4 -0
  33. data/lib/httpx/resolver/resolver.rb +2 -2
  34. data/lib/httpx/response/body.rb +2 -2
  35. data/lib/httpx/response.rb +7 -7
  36. data/lib/httpx/selector.rb +1 -1
  37. data/lib/httpx/session.rb +7 -3
  38. data/lib/httpx/transcoder/chunker.rb +2 -2
  39. data/lib/httpx/transcoder/json.rb +8 -9
  40. data/lib/httpx/transcoder/utils/deflater.rb +1 -2
  41. data/lib/httpx/version.rb +1 -1
  42. data/sig/connection/http2.rbs +15 -1
  43. data/sig/connection.rbs +4 -2
  44. data/sig/errors.rbs +2 -2
  45. data/sig/io/ssl.rbs +5 -0
  46. data/sig/plugins/auth.rbs +3 -3
  47. data/sig/plugins/persistent.rbs +4 -0
  48. data/sig/plugins/proxy/http.rbs +2 -0
  49. data/sig/plugins/retries.rbs +4 -2
  50. data/sig/plugins/tracing.rbs +1 -1
  51. data/sig/request.rbs +2 -1
  52. metadata +8 -2
@@ -24,8 +24,8 @@ module HTTPX::Transcoder
24
24
  yield "0#{CRLF}"
25
25
  end
26
26
 
27
- def respond_to_missing?(meth, *args)
28
- @raw.respond_to?(meth, *args) || super
27
+ def respond_to_missing?(...)
28
+ @raw.respond_to?(...) || super
29
29
  end
30
30
  end
31
31
 
@@ -51,21 +51,20 @@ module HTTPX::Transcoder
51
51
  method(:json_load)
52
52
  end
53
53
 
54
- # rubocop:disable Style/SingleLineMethods
54
+ # rubocop:disable-next Style/SingleLineMethods
55
55
  if defined?(MultiJson)
56
- def json_load(*args); MultiJson.load(*args); end
57
- def json_dump(*args); MultiJson.dump(*args); end
56
+ def json_load(...); MultiJson.load(...); end
57
+ def json_dump(...); MultiJson.dump(...); end
58
58
  elsif defined?(Oj)
59
- def json_load(response, *args); Oj.load(response.to_s, *args); end
59
+ def json_load(response, ...); Oj.load(response.to_s, ...); end
60
60
  def json_dump(obj, options = {}); Oj.dump(obj, { mode: :compat }.merge(options)); end
61
61
  elsif defined?(Yajl)
62
- def json_load(response, *args); Yajl::Parser.new(*args).parse(response.to_s); end
63
- def json_dump(*args); Yajl::Encoder.encode(*args); end
62
+ def json_load(response, ...); Yajl::Parser.new(...).parse(response.to_s); end
63
+ def json_dump(...); Yajl::Encoder.encode(...); end
64
64
  else
65
65
  require "json"
66
- def json_load(*args); ::JSON.parse(*args); end
67
- def json_dump(*args); ::JSON.generate(*args); end
66
+ def json_load(...); ::JSON.parse(...); end
67
+ def json_dump(...); ::JSON.generate(...); end
68
68
  end
69
- # rubocop:enable Style/SingleLineMethods
70
69
  end
71
70
  end
@@ -55,7 +55,7 @@ module HTTPX
55
55
 
56
56
  private
57
57
 
58
- # rubocop:disable Naming/MemoizedInstanceVariableName
58
+ # rubocop:disable-next Naming/MemoizedInstanceVariableName
59
59
  def buffer_deflate!
60
60
  return @buffer if defined?(@buffer)
61
61
 
@@ -68,7 +68,6 @@ module HTTPX
68
68
 
69
69
  @buffer = buffer
70
70
  end
71
- # rubocop:enable Naming/MemoizedInstanceVariableName
72
71
  end
73
72
  end
74
73
  end
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "1.8.1"
4
+ VERSION = "1.8.4"
5
5
  end
@@ -116,11 +116,25 @@ module HTTPX
116
116
  end
117
117
 
118
118
  class GoawayError < Error
119
- def initialize: (?Symbol code) -> void
119
+ UNRECOVERABLE_ERRORS: Array[Symbol]
120
+
121
+ @code: Symbol
122
+
123
+ def initialize: (Symbol code, Integer last_stream_id) -> void
124
+
125
+ def last_stream_id: () -> Numeric
126
+
127
+ def unrecoverable?: () -> bool
120
128
  end
121
129
 
122
130
  class PingError < Error
123
131
  def initialize: () -> void
124
132
  end
133
+
134
+ class RstStreamError < Error
135
+ end
136
+
137
+ class RefusedStreamError < Error
138
+ end
125
139
  end
126
140
  end
data/sig/connection.rbs CHANGED
@@ -32,10 +32,11 @@ module HTTPX
32
32
  attr_accessor current_session: Session?
33
33
  attr_accessor family: Integer?
34
34
 
35
+ attr_reader read_buffer: Buffer
36
+ attr_reader write_buffer: Buffer
37
+
35
38
 
36
39
  @window_size: Integer
37
- @read_buffer: Buffer
38
- @write_buffer: Buffer
39
40
  @inflight: Integer
40
41
  @max_concurrent_requests: Integer?
41
42
  @keep_alive_timeout: interval?
@@ -46,6 +47,7 @@ module HTTPX
46
47
  @response_received_at: Float
47
48
  @exhausted: bool
48
49
  @cloned: bool
50
+ @previously_exhausted_with_error: bool
49
51
  @coalesced_connection: instance?
50
52
  @altsvc_connection: instance?
51
53
  @sibling: instance?
data/sig/errors.rbs CHANGED
@@ -31,9 +31,9 @@ module HTTPX
31
31
 
32
32
  class RequestTimeoutError < TimeoutError
33
33
  attr_reader request: Request
34
- attr_reader response: response?
34
+ attr_reader response: untyped
35
35
 
36
- def initialize: (Request request, response? response, interval timeout) -> void
36
+ def initialize: (Request request, untyped response, interval timeout) -> void
37
37
  end
38
38
 
39
39
  class ReadTimeoutError < RequestTimeoutError
data/sig/io/ssl.rbs CHANGED
@@ -9,6 +9,7 @@ module HTTPX
9
9
  @ctx: OpenSSL::SSL::SSLContext
10
10
  @verify_hostname: bool
11
11
  @sni_hostname: String
12
+ @session_new_cb: (^(OpenSSL::SSL::Session sess) -> void)?
12
13
 
13
14
  attr_writer ssl_session: OpenSSL::SSL::Session?
14
15
 
@@ -24,5 +25,9 @@ module HTTPX
24
25
 
25
26
  # :nocov:
26
27
  def try_ssl_connect: () -> void
28
+
29
+ private
30
+
31
+ def init_session_new_cb: () -> void
27
32
  end
28
33
  end
data/sig/plugins/auth.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Auth
4
- type auth_header_value_type = String | ^(Request request) -> string
4
+ type auth_header_value_type = String | ^(?Request request, ?bool should_regenerate) -> string
5
5
 
6
6
  interface _AuthOptions
7
7
  def auth_header_value: () -> auth_header_value_type?
@@ -18,7 +18,7 @@ module HTTPX
18
18
  @auth_header_value_mtx: Thread::Mutex
19
19
  @skip_auth_header_value: bool
20
20
 
21
- def authorization: (?string token, ?auth_header_type: string) ?{ (Request) -> string } -> instance
21
+ def authorization: (?string token, ?auth_header_type: string) ?{ (?Request, ?bool) -> string } -> instance
22
22
 
23
23
  def bearer_auth: (?string token) ?{ (Request) -> string } -> instance
24
24
 
@@ -28,7 +28,7 @@ module HTTPX
28
28
 
29
29
  private
30
30
 
31
- def generate_auth_token: () -> String?
31
+ def generate_auth_token: (Request & RequestMethods request, bool should_regenerate) -> String?
32
32
 
33
33
  def dynamic_auth_token?: (auth_header_value_type auth_header_value) -> boolish
34
34
  end
@@ -1,6 +1,8 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Persistent
4
+ SAFE_REONNECTABLE_ERRORS: Array[singleton(StandardError)]
5
+
4
6
  def self.load_dependencies: (singleton(Session)) -> void
5
7
 
6
8
  def self.extra_options: (Options) -> (Options)
@@ -9,6 +11,8 @@ module HTTPX
9
11
  private
10
12
 
11
13
  def reconnectable_error?: (StandardError error) -> bool
14
+
15
+ def safe_reconnectable_error?: (StandardError error) -> bool
12
16
  end
13
17
  end
14
18
 
@@ -12,6 +12,8 @@ module HTTPX
12
12
  end
13
13
 
14
14
  module ConnectionMethods
15
+ @tunnel_parser: Connection::HTTP1 | Connection::HTTP2
16
+
15
17
  def __http_proxy_connect: (Connection::_Parser parser) -> void
16
18
  def __http_on_connect: (top, Response) -> void
17
19
  end
@@ -45,9 +45,11 @@ module HTTPX
45
45
 
46
46
  def try_partial_retry: (retriesRequest request, retriesResponse response) -> void
47
47
 
48
- def prepare_to_retry: (Request & RequestMethods request, retriesResponse response) -> void
48
+ def prepare_to_retry: (retriesRequest request, retriesResponse response) -> void
49
49
 
50
- def when_to_retry: (Request & RequestMethods request, retriesResponse response, retriesOptions options) -> Numeric?
50
+ def can_reconnect?: (retriesRequest request, retriesResponse response) -> bool
51
+
52
+ def when_to_retry: (retriesRequest request, retriesResponse response, retriesOptions options) -> Numeric?
51
53
  end
52
54
 
53
55
  module RequestMethods
@@ -30,7 +30,7 @@ module HTTPX
30
30
  end
31
31
 
32
32
  module ConnectionMethods
33
- @init_time: Time
33
+ @init_time: Time?
34
34
  end
35
35
 
36
36
  type retriesRequest = Request & RequestMethods
data/sig/request.rbs CHANGED
@@ -32,10 +32,11 @@ module HTTPX
32
32
  @query: String?
33
33
  @drainer: Enumerator[String, void]?
34
34
  @started: bool
35
+ @complete: bool
35
36
 
36
37
  def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
37
38
 
38
- def complete!: (?response response) -> void
39
+ def complete!: (?response response) -> bool
39
40
 
40
41
  def started?: () -> bool
41
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
@@ -170,6 +170,9 @@ extra_rdoc_files:
170
170
  - doc/release_notes/1_7_8.md
171
171
  - doc/release_notes/1_8_0.md
172
172
  - doc/release_notes/1_8_1.md
173
+ - doc/release_notes/1_8_2.md
174
+ - doc/release_notes/1_8_3.md
175
+ - doc/release_notes/1_8_4.md
173
176
  files:
174
177
  - LICENSE.txt
175
178
  - README.md
@@ -312,6 +315,9 @@ files:
312
315
  - doc/release_notes/1_7_8.md
313
316
  - doc/release_notes/1_8_0.md
314
317
  - doc/release_notes/1_8_1.md
318
+ - doc/release_notes/1_8_2.md
319
+ - doc/release_notes/1_8_3.md
320
+ - doc/release_notes/1_8_4.md
315
321
  - lib/httpx.rb
316
322
  - lib/httpx/adapters/datadog.rb
317
323
  - lib/httpx/adapters/faraday.rb
@@ -557,7 +563,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
557
563
  - !ruby/object:Gem::Version
558
564
  version: '0'
559
565
  requirements: []
560
- rubygems_version: 3.6.9
566
+ rubygems_version: 4.0.16
561
567
  specification_version: 4
562
568
  summary: HTTPX, to the future, and beyond
563
569
  test_files: []