httpx 1.1.0 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ef9f0a027f7a313547ca11bce6cf2c5a3eb72075b2cee0be13448d4aa7ec2b6
4
- data.tar.gz: 0021a6c5e4968dd68cb23a157c5ce0dd84021bf134eb6c8227c5b145772e5812
3
+ metadata.gz: 39a2d410f391dedb077e3704edeafde92786201ebd7b1d3e4e2f6aa7e254797b
4
+ data.tar.gz: bdcc46a37c8cc4ba8edd11355c5dc439a7401569c8ef014c7ca45ac22e97d284
5
5
  SHA512:
6
- metadata.gz: 14687b4930aff7fef833058a27d5b26e4a9c327fcbf779f88d3b2b7766a861a26845285054ccde501a5a8296fdfc3c87a5f7e56eafc58fabeecd383512d36e8c
7
- data.tar.gz: 95ee1b01958d2c680e194baa2f3136464c775038e9cd87d7d712d88998f48bbd385d6f3cc1173d2bda023102c4ca4661221aabd03d0d8a0a62e3006a79694851
6
+ metadata.gz: df50d7db27a18a2f7d610e12b618fc1a8ab2d18a6a1f3bbd70054a4fdab9bec8a8e428115696d5f042f28c7409e7539eaca0f3798d13bc6ab98d88e43d41808d
7
+ data.tar.gz: 63563a10039713d75e6d3d795ddfc08f91a46c2f73225b9987e96acbed9e23d0c5e69154589afbf0163ec69ff99eb9c34f517fb9d360ad7f951a06fb5569ce95
@@ -0,0 +1,17 @@
1
+ # 1.1.1
2
+
3
+ ## improvements
4
+
5
+ * (Re-)enabling default retries in DNS name queries; this had been disabled as a result of revamping timouts, and resulted in queries only being sent once, which is very little for UDP-related traffic, and breaks if using DNs rate-limiting software. Retries the query just once, for now.
6
+
7
+ ## bugfixes
8
+
9
+ * reset timers when adding new intervals, as these may be added as a result on after-select connection handling, and must wait for the next tick cycle (before the patch, they were triggering too soon).
10
+ * fixed "on close" callback leak on connection reuse, which caused linear performance regression in benchmarks performing one request per connection.
11
+ * fixed hanging connection whan an HTTP/1.1 emitted a "connection: close" header but the server would not emit one (it closes the connection now).
12
+ * fixed recursive dns cached lookups which may have already expired, and created nil entries in the returned address list.
13
+ * dns system resolver is now able to retry on failure.
14
+
15
+ ## chore
16
+
17
+ * remove duplicated callback unregitering connections.
@@ -181,7 +181,7 @@ module HTTPX
181
181
  if response.is_a?(ErrorResponse)
182
182
  disable
183
183
  else
184
- manage_connection(response)
184
+ manage_connection(request, response)
185
185
  end
186
186
 
187
187
  if exhausted?
@@ -224,7 +224,7 @@ module HTTPX
224
224
 
225
225
  private
226
226
 
227
- def manage_connection(response)
227
+ def manage_connection(request, response)
228
228
  connection = response.headers["connection"]
229
229
  case connection
230
230
  when /keep-alive/i
@@ -254,7 +254,7 @@ module HTTPX
254
254
  disable
255
255
  when nil
256
256
  # In HTTP/1.1, it's keep alive by default
257
- return if response.version == "1.1"
257
+ return if response.version == "1.1" && request.headers["connection"] != "close"
258
258
 
259
259
  disable
260
260
  end
@@ -273,7 +273,7 @@ module HTTPX
273
273
  end
274
274
 
275
275
  def timeout
276
- return @timeout if defined?(@timeout)
276
+ return @timeout if @timeout
277
277
 
278
278
  return @options.timeout[:connect_timeout] if @state == :idle
279
279
 
@@ -518,7 +518,6 @@ module HTTPX
518
518
  else
519
519
  transition(:closing)
520
520
  transition(:closed)
521
- emit(:reset)
522
521
 
523
522
  @parser.reset if @parser
524
523
  transition(:idle)
@@ -617,7 +616,7 @@ module HTTPX
617
616
  def purge_after_closed
618
617
  @io.close if @io
619
618
  @read_buffer.clear
620
- remove_instance_variable(:@timeout) if defined?(@timeout)
619
+ @timeout = nil
621
620
  end
622
621
 
623
622
  def build_socket(addrs = nil)
@@ -76,7 +76,6 @@ module HTTPX
76
76
  else
77
77
  transition(:closing)
78
78
  transition(:closed)
79
- emit(:reset)
80
79
 
81
80
  parser.reset if @parser
82
81
  transition(:idle)
data/lib/httpx/pool.rb CHANGED
@@ -223,9 +223,6 @@ module HTTPX
223
223
  @connected_connections += 1
224
224
  end
225
225
  select_connection(connection)
226
- connection.on(:close) do
227
- unregister_connection(connection)
228
- end
229
226
  end
230
227
 
231
228
  def unregister_connection(connection)
@@ -62,8 +62,11 @@ module HTTPX
62
62
  addresses.first.to_s != connection.origin.host.to_s
63
63
  log { "resolver: A response, applying resolution delay..." }
64
64
  @pool.after(0.05) do
65
- # double emission check
66
- emit_resolved_connection(connection, addresses) unless connection.addresses && addresses.intersect?(connection.addresses)
65
+ unless connection.state == :closed ||
66
+ # double emission check
67
+ (connection.addresses && addresses.intersect?(connection.addresses))
68
+ emit_resolved_connection(connection, addresses)
69
+ end
67
70
  end
68
71
  else
69
72
  emit_resolved_connection(connection, addresses)
@@ -164,7 +164,8 @@ module HTTPX
164
164
  def async_resolve(connection, hostname, scheme)
165
165
  families = connection.options.ip_families
166
166
  log { "resolver: query for #{hostname}" }
167
- resolve_timeout = @timeouts[connection.origin.host].first
167
+ timeouts = @timeouts[connection.origin.host]
168
+ resolve_timeout = timeouts.first
168
169
 
169
170
  Thread.start do
170
171
  Thread.current.report_on_exception = false
@@ -191,6 +192,8 @@ module HTTPX
191
192
  end
192
193
  rescue StandardError => e
193
194
  if e.is_a?(Timeout::Error)
195
+ timeouts.shift
196
+ retry unless timeouts.empty?
194
197
  e = ResolveTimeoutError.new(resolve_timeout, e.message)
195
198
  e.set_backtrace(e.backtrace)
196
199
  end
@@ -5,7 +5,7 @@ require "ipaddr"
5
5
 
6
6
  module HTTPX
7
7
  module Resolver
8
- RESOLVE_TIMEOUT = 5
8
+ RESOLVE_TIMEOUT = [2, 3].freeze
9
9
 
10
10
  require "httpx/resolver/resolver"
11
11
  require "httpx/resolver/system"
@@ -87,16 +87,18 @@ module HTTPX
87
87
  def lookup(hostname, ttl)
88
88
  return unless @lookups.key?(hostname)
89
89
 
90
- @lookups[hostname] = @lookups[hostname].select do |address|
90
+ entries = @lookups[hostname] = @lookups[hostname].select do |address|
91
91
  address["TTL"] > ttl
92
92
  end
93
- ips = @lookups[hostname].flat_map do |address|
93
+
94
+ ips = entries.flat_map do |address|
94
95
  if address.key?("alias")
95
96
  lookup(address["alias"], ttl)
96
97
  else
97
98
  IPAddr.new(address["data"])
98
99
  end
99
- end
100
+ end.compact
101
+
100
102
  ips unless ips.empty?
101
103
  end
102
104
 
data/lib/httpx/session.rb CHANGED
@@ -260,7 +260,9 @@ module HTTPX
260
260
  connection.on(:open) do
261
261
  emit(:connection_opened, connection.origin, connection.io.socket)
262
262
  # only run close callback if it opened
263
- connection.on(:close) { emit(:connection_closed, connection.origin, connection.io.socket) }
263
+ end
264
+ connection.on(:close) do
265
+ emit(:connection_closed, connection.origin, connection.io.socket) if connection.used?
264
266
  end
265
267
  catch(:coalesced) do
266
268
  pool.init_connection(connection, options)
data/lib/httpx/timers.rb CHANGED
@@ -24,6 +24,8 @@ module HTTPX
24
24
 
25
25
  interval << callback
26
26
 
27
+ @next_interval_at = nil
28
+
27
29
  interval
28
30
  end
29
31
 
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.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
@@ -59,13 +59,13 @@ module HTTPX
59
59
 
60
60
  def initialize: (Buffer, options) -> untyped
61
61
 
62
- def manage_connection: (Response) -> void
62
+ def manage_connection: (Request request, Response response) -> void
63
63
 
64
64
  def disable: () -> void
65
65
 
66
66
  def disable_pipelining: () -> void
67
67
 
68
- def set_protocol_headers: (Request) -> _Each[[String, String]]
68
+ def set_protocol_headers: (Request request) -> _Each[[String, String]]
69
69
 
70
70
  def handle: (Request request) -> void
71
71
 
data/sig/resolver.rbs CHANGED
@@ -2,7 +2,7 @@ module HTTPX
2
2
  type ipaddr = IPAddr | String
3
3
 
4
4
  module Resolver
5
- RESOLVE_TIMEOUT: Integer
5
+ RESOLVE_TIMEOUT: Array[Integer]
6
6
 
7
7
  @lookup_mutex: Thread::Mutex
8
8
 
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: 1.1.0
4
+ version: 1.1.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: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -132,6 +132,7 @@ extra_rdoc_files:
132
132
  - doc/release_notes/1_0_1.md
133
133
  - doc/release_notes/1_0_2.md
134
134
  - doc/release_notes/1_1_0.md
135
+ - doc/release_notes/1_1_1.md
135
136
  files:
136
137
  - LICENSE.txt
137
138
  - README.md
@@ -235,6 +236,7 @@ files:
235
236
  - doc/release_notes/1_0_1.md
236
237
  - doc/release_notes/1_0_2.md
237
238
  - doc/release_notes/1_1_0.md
239
+ - doc/release_notes/1_1_1.md
238
240
  - lib/httpx.rb
239
241
  - lib/httpx/adapters/datadog.rb
240
242
  - lib/httpx/adapters/faraday.rb