lib/async/http/protocol/http1/client.rb in async-http-0.76.0 vs lib/async/http/protocol/http1/client.rb in async-http-0.77.0
- old
+ new
@@ -1,22 +1,36 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
-require_relative 'connection'
+require_relative "connection"
module Async
module HTTP
module Protocol
module HTTP1
class Client < Connection
+ def initialize(...)
+ super
+
+ @pool = nil
+ end
+
+ attr_accessor :pool
+
+ def closed!
+ super
+
+ if pool = @pool
+ @pool = nil
+ pool.release(self)
+ end
+ end
+
# Used by the client to send requests to the remote server.
def call(request, task: Task.current)
- # We need to keep track of connections which are not in the initial "ready" state.
- @ready = false
-
Console.logger.debug(self) {"#{request.method} #{request.path} #{request.headers.inspect}"}
# Mark the start of the trailers:
trailer = request.headers.trailer!
@@ -52,15 +66,14 @@
else
write_body(@version, body, false, trailer)
end
response = Response.read(self, request)
- @ready = true
return response
rescue
# This will ensure that #reusable? returns false.
- @stream.close
+ self.close
raise
end
end
end