httpx 1.6.2 → 1.6.3

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_6_3.md +47 -0
  3. data/lib/httpx/adapters/sentry.rb +1 -1
  4. data/lib/httpx/connection/http1.rb +9 -9
  5. data/lib/httpx/connection/http2.rb +14 -15
  6. data/lib/httpx/connection.rb +115 -102
  7. data/lib/httpx/extensions.rb +0 -14
  8. data/lib/httpx/io/ssl.rb +1 -1
  9. data/lib/httpx/loggable.rb +12 -2
  10. data/lib/httpx/options.rb +20 -0
  11. data/lib/httpx/plugins/callbacks.rb +15 -1
  12. data/lib/httpx/plugins/digest_auth.rb +1 -1
  13. data/lib/httpx/plugins/proxy/http.rb +37 -9
  14. data/lib/httpx/plugins/response_cache/file_store.rb +1 -0
  15. data/lib/httpx/plugins/response_cache.rb +13 -2
  16. data/lib/httpx/plugins/stream_bidi.rb +15 -6
  17. data/lib/httpx/pool.rb +53 -19
  18. data/lib/httpx/request.rb +3 -13
  19. data/lib/httpx/resolver/https.rb +35 -19
  20. data/lib/httpx/resolver/multi.rb +8 -27
  21. data/lib/httpx/resolver/native.rb +46 -38
  22. data/lib/httpx/resolver/resolver.rb +45 -28
  23. data/lib/httpx/resolver/system.rb +63 -39
  24. data/lib/httpx/selector.rb +35 -20
  25. data/lib/httpx/session.rb +18 -28
  26. data/lib/httpx/transcoder/deflate.rb +13 -8
  27. data/lib/httpx/transcoder/utils/body_reader.rb +1 -2
  28. data/lib/httpx/transcoder/utils/deflater.rb +1 -2
  29. data/lib/httpx/version.rb +1 -1
  30. data/sig/connection.rbs +12 -3
  31. data/sig/loggable.rbs +5 -1
  32. data/sig/options.rbs +5 -1
  33. data/sig/plugins/callbacks.rbs +3 -0
  34. data/sig/plugins/stream_bidi.rbs +3 -5
  35. data/sig/resolver/https.rbs +2 -0
  36. data/sig/resolver/multi.rbs +0 -9
  37. data/sig/resolver/native.rbs +0 -2
  38. data/sig/resolver/resolver.rbs +9 -8
  39. data/sig/resolver/system.rbs +4 -2
  40. data/sig/selector.rbs +2 -0
  41. data/sig/session.rbs +5 -3
  42. metadata +3 -1
@@ -10,15 +10,20 @@ module HTTPX
10
10
  def deflate(chunk)
11
11
  @deflater ||= Zlib::Deflate.new
12
12
 
13
- if chunk.nil?
14
- unless @deflater.closed?
15
- last = @deflater.finish
16
- @deflater.close
17
- last.empty? ? nil : last
18
- end
19
- else
20
- @deflater.deflate(chunk)
13
+ unless chunk.nil?
14
+ chunk = @deflater.deflate(chunk)
15
+
16
+ # deflate call may return nil, while still
17
+ # retaining the last chunk in the deflater.
18
+ return chunk unless chunk.empty?
21
19
  end
20
+
21
+ return if @deflater.closed?
22
+
23
+ last = @deflater.finish
24
+ @deflater.close
25
+
26
+ last unless last.empty?
22
27
  end
23
28
  end
24
29
 
@@ -28,8 +28,7 @@ module HTTPX
28
28
  begin
29
29
  chunk = @body.next
30
30
  if outbuf
31
- outbuf.clear.force_encoding(Encoding::BINARY)
32
- outbuf << chunk
31
+ outbuf.replace(chunk)
33
32
  else
34
33
  outbuf = chunk
35
34
  end
@@ -31,8 +31,7 @@ module HTTPX
31
31
  return unless compressed_chunk
32
32
 
33
33
  if outbuf
34
- outbuf.clear.force_encoding(Encoding::BINARY)
35
- outbuf << compressed_chunk
34
+ outbuf.replace(compressed_chunk)
36
35
  else
37
36
  compressed_chunk
38
37
  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.6.2"
4
+ VERSION = "1.6.3"
5
5
  end
data/sig/connection.rbs CHANGED
@@ -46,6 +46,7 @@ module HTTPX
46
46
  @exhausted: bool
47
47
  @cloned: bool
48
48
  @coalesced_connection: instance?
49
+ @altsvc_connection: instance?
49
50
  @sibling: instance?
50
51
  @main_sibling: bool
51
52
 
@@ -66,6 +67,8 @@ module HTTPX
66
67
 
67
68
  def coalesce!: (instance connection) -> void
68
69
 
70
+ def coalesced?: () -> boolish
71
+
69
72
  def coalescable?: (Connection connection) -> bool
70
73
 
71
74
  def create_idle: (?Hash[Symbol, untyped] options) -> instance
@@ -76,7 +79,9 @@ module HTTPX
76
79
 
77
80
  def connecting?: () -> bool
78
81
 
79
- def io_connected?: () -> bool
82
+ def current_context?: () -> bool
83
+
84
+ def io_connected?: () -> boolish
80
85
 
81
86
  def inflight?: () -> boolish
82
87
 
@@ -90,6 +95,8 @@ module HTTPX
90
95
 
91
96
  def close: () -> void
92
97
 
98
+ def force_close: (?bool delete_pending) -> void
99
+
93
100
  def force_reset: (?bool cloned) -> void
94
101
 
95
102
  def reset: () -> void
@@ -112,6 +119,8 @@ module HTTPX
112
119
 
113
120
  def disconnect: () -> void
114
121
 
122
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
123
+
115
124
  private
116
125
 
117
126
  def initialize: (http_uri uri, Options options) -> void
@@ -130,6 +139,8 @@ module HTTPX
130
139
 
131
140
  def send_request_to_parser: (Request request) -> void
132
141
 
142
+ def enqueue_pending_requests_from_parser: (HTTP1 | HTTP2 parser) -> void
143
+
133
144
  def build_parser: (?String protocol) -> (Object & _Parser)
134
145
 
135
146
  def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
@@ -142,8 +153,6 @@ module HTTPX
142
153
 
143
154
  def build_socket: (?Array[Resolver::Entry]? addrs) -> (TCP | SSL | UNIX)
144
155
 
145
- def on_error: (HTTPX::TimeoutError | Error | StandardError error, ?Request? request) -> void
146
-
147
156
  def handle_error: (StandardError error, ?Request? request) -> void
148
157
 
149
158
  def close_sibling: () -> void
data/sig/loggable.rbs CHANGED
@@ -12,6 +12,10 @@ module HTTPX
12
12
 
13
13
  def log_exception: (Exception error, ?level: Integer, ?color: Symbol, ?debug_level: Integer, ?debug: _IOLogger?) -> void
14
14
 
15
- def log_redact: (_ToS text, ?bool should_redact) -> String
15
+ def log_redact_headers: (_ToS text) -> String
16
+
17
+ def log_redact_body: (_ToS text) -> String
18
+
19
+ def log_redact: (_ToS text, bool should_redact) -> String
16
20
  end
17
21
  end
data/sig/options.rbs CHANGED
@@ -17,9 +17,11 @@ module HTTPX
17
17
 
18
18
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
19
19
  REQUEST_BODY_IVARS: Array[Symbol]
20
+ USER_AGENT: String
20
21
 
21
22
  type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
22
23
  type timeout = Hash[timeout_type, Numeric?]
24
+ type redact_value = :headers | :body | bool
23
25
 
24
26
  def self.new: (?options) -> instance
25
27
 
@@ -146,6 +148,8 @@ module HTTPX
146
148
 
147
149
  def initialize: (?options options) -> void
148
150
 
151
+ def do_initialize: (?options options) -> void
152
+
149
153
  def access_option: (Hash[Symbol, untyped] | Object | nil obj, Symbol k, Hash[Symbol, Symbol]? ivar_map) -> untyped
150
154
 
151
155
  # integer
@@ -175,7 +179,7 @@ module HTTPX
175
179
  def option_io: (io_option value) -> io_option
176
180
  def option_fallback_protocol: (String value) -> String
177
181
  def option_debug: (_IOLogger value) -> _IOLogger
178
- def option_debug_redact: (bool value) -> bool
182
+ def option_debug_redact: (redact_value value) -> redact_value
179
183
  def option_compress_request_body: (bool value) -> bool
180
184
  def option_decompress_response_body: (bool value) -> bool
181
185
  def option_persistent: (bool value) -> bool
@@ -31,6 +31,9 @@ module HTTPX
31
31
 
32
32
  def emit_or_callback_error: (*untyped) -> void
33
33
  end
34
+
35
+ module ConnectionMethods
36
+ end
34
37
  end
35
38
 
36
39
  type sessionCallbacks = Session & Callbacks::InstanceMethods
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.extra_options: (Options) -> (Options)
7
7
 
8
- class HTTP2Bidi < Connection::HTTP2
8
+ module HTTP2Methods
9
9
  @lock: Thread::Mutex
10
10
 
11
11
  private
@@ -24,6 +24,8 @@ module HTTPX
24
24
  end
25
25
 
26
26
  class Signal
27
+ attr_reader error: Exception?
28
+
27
29
  @closed: bool
28
30
  @pipe_read: IO
29
31
  @pipe_write: IO
@@ -55,10 +57,6 @@ module HTTPX
55
57
 
56
58
  module ConnectionMethods
57
59
  @write_buffer: BidiBuffer
58
-
59
- private
60
-
61
- def parser_type: (String protocol) -> (singleton(Connection::HTTP1) | singleton(Connection::HTTP2) | singleton(HTTP2Bidi))
62
60
  end
63
61
 
64
62
  end
@@ -40,6 +40,8 @@ module HTTPX
40
40
  def decode_response_body: (Response) -> dns_decoding_response
41
41
 
42
42
  def reset_hostname: (String hostname, ?reset_candidates: bool) -> Connection?
43
+
44
+ def close_or_resolve: (?bool should_deactivate) -> void
43
45
  end
44
46
  end
45
47
  end
@@ -8,7 +8,6 @@ module HTTPX
8
8
  @current_selector: Selector?
9
9
  @current_session: Session?
10
10
  @resolver_options: Hash[Symbol, untyped]
11
- # @errors: Hash[Symbol, untyped]
12
11
 
13
12
  def current_selector=: (Selector s) -> void
14
13
 
@@ -16,14 +15,6 @@ module HTTPX
16
15
 
17
16
  def closed?: () -> bool
18
17
 
19
- def empty?: () -> bool
20
-
21
- def timeout: () -> Numeric?
22
-
23
- def close: () -> void
24
-
25
- def connections: () -> Array[Connection]
26
-
27
18
  def early_resolve: (Connection connection) -> bool
28
19
 
29
20
  def lazy_resolve: (Connection connection) -> void
@@ -64,8 +64,6 @@ module HTTPX
64
64
 
65
65
  def transition: (Symbol nextstate) -> void
66
66
 
67
- def handle_error: (NativeResolveError | StandardError) -> void
68
-
69
67
  def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
70
68
 
71
69
  def close_or_resolve: () -> void
@@ -1,7 +1,6 @@
1
1
  module HTTPX
2
2
  module Resolver
3
3
  class Resolver
4
- include Callbacks
5
4
  include Loggable
6
5
 
7
6
  include _Selectable
@@ -26,7 +25,9 @@ module HTTPX
26
25
 
27
26
  def close: () -> void
28
27
 
29
- alias terminate close
28
+ def terminate: () -> void
29
+
30
+ def force_close: (*untyped args) -> void
30
31
 
31
32
  def closed?: () -> bool
32
33
 
@@ -36,8 +37,12 @@ module HTTPX
36
37
 
37
38
  def emit_addresses: (Connection connection, ip_family family, Array[ipaddr], ?bool early_resolve) -> void
38
39
 
40
+ def handle_error: (ResolveError | StandardError) -> void
41
+
39
42
  def self.multi?: () -> bool
40
43
 
44
+ def early_resolve: (Connection connection, ?hostname: String) -> bool
45
+
41
46
  private
42
47
 
43
48
  def resolve: (?Connection connection, ?String hostname) -> void
@@ -46,19 +51,15 @@ module HTTPX
46
51
 
47
52
  def initialize: (ip_family family, Options options) -> void
48
53
 
49
- def early_resolve: (Connection connection, ?hostname: String) -> bool
50
-
51
- def set_resolver_callbacks: () -> void
52
-
53
54
  def resolve_connection: (Connection connection) -> void
54
55
 
55
56
  def emit_connection_error: (Connection connection, StandardError error) -> void
56
57
 
57
- def close_resolver: (Resolver resolver) -> void
58
-
59
58
  def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
60
59
 
61
60
  def resolve_error: (String hostname, ?StandardError?) -> (ResolveError | ResolveTimeoutError)
61
+
62
+ def close_or_resolve: () -> void
62
63
  end
63
64
  end
64
65
  end
@@ -16,7 +16,9 @@ module HTTPX
16
16
 
17
17
  attr_reader state: Symbol
18
18
 
19
- def <<: (Connection) -> void
19
+ def initialize: (Options options) -> void
20
+
21
+ def lazy_resolve: (Connection connection) -> void
20
22
 
21
23
  private
22
24
 
@@ -28,7 +30,7 @@ module HTTPX
28
30
 
29
31
  def __addrinfo_resolve: (String host, String scheme) -> Array[Addrinfo]
30
32
 
31
- def initialize: (Options options) -> void
33
+ def close_or_resolve: () -> void
32
34
  end
33
35
  end
34
36
  end
data/sig/selector.rbs CHANGED
@@ -11,6 +11,8 @@ module HTTPX
11
11
  def timeout: () -> Numeric?
12
12
 
13
13
  def handle_socket_timeout: (Numeric interval) -> void
14
+
15
+ def on_error: (StandardError) -> void
14
16
  end
15
17
 
16
18
  class Selector
data/sig/session.rbs CHANGED
@@ -15,6 +15,8 @@ module HTTPX
15
15
  @wrapped: bool
16
16
  @closing: bool
17
17
 
18
+ type resolver = Resolver::Multi | Resolver::Resolver
19
+
18
20
  def wrap: () { (instance) -> void } -> void
19
21
 
20
22
  def close: (?Selector selector) -> void
@@ -23,11 +25,11 @@ module HTTPX
23
25
 
24
26
  def select_connection: (Connection connection, Selector selector) -> void
25
27
 
26
- def pin_connection: (Resolver::Resolver | Connection connection, Selector selector) -> void
28
+ def pin: (resolver | Connection conn_or_resolver, Selector selector) -> void
27
29
 
28
30
  def deselect_connection: (Connection connection, Selector selector, ?bool cloned) -> void
29
31
 
30
- def select_resolver: (Resolver::Native | Resolver::HTTPS resolver, Selector selector) -> void
32
+ def select_resolver: (Resolver::Resolver resolver, Selector selector) -> void
31
33
 
32
34
  def deselect_resolver: (Resolver::Resolver resolver, Selector selector) -> void
33
35
 
@@ -72,7 +74,7 @@ module HTTPX
72
74
 
73
75
  def on_resolver_close: (Resolver::Resolver resolver, Selector selector) -> void
74
76
 
75
- def find_resolver_for: (Connection connection, Selector selector) -> (Resolver::Multi | Resolver::Resolver)
77
+ def find_resolver_for: (Connection connection, Selector selector) -> resolver
76
78
 
77
79
  def coalesce_connections: (Connection conn1, Connection conn2, Selector selector, bool from_pool) -> bool
78
80
 
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.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
@@ -158,6 +158,7 @@ extra_rdoc_files:
158
158
  - doc/release_notes/1_6_0.md
159
159
  - doc/release_notes/1_6_1.md
160
160
  - doc/release_notes/1_6_2.md
161
+ - doc/release_notes/1_6_3.md
161
162
  files:
162
163
  - LICENSE.txt
163
164
  - README.md
@@ -288,6 +289,7 @@ files:
288
289
  - doc/release_notes/1_6_0.md
289
290
  - doc/release_notes/1_6_1.md
290
291
  - doc/release_notes/1_6_2.md
292
+ - doc/release_notes/1_6_3.md
291
293
  - lib/httpx.rb
292
294
  - lib/httpx/adapters/datadog.rb
293
295
  - lib/httpx/adapters/faraday.rb