class Async::HTTP::Protocol::HTTP1::Response

def self.read(connection, request)

def self.read(connection, request)
	while parts = connection.read_response(request.method)
		response = self.new(connection, *parts)
		
		if response.final?
			return response
		else
			request.send_interim_response(response.status, response.headers)
		end
	end
end

def connection

def connection
	@connection
end

def hijack!

def hijack!
	@connection.hijack!
end

def hijack?

def hijack?
	@body.nil?
end

def initialize(connection, version, status, reason, headers, body)

@parameter reason [String] HTTP response line reason phrase.
def initialize(connection, version, status, reason, headers, body)
	@connection = connection
	@reason = reason
	
	# Technically, there should never be more than one value for the upgrade header, but we'll just take the first one to avoid complexity.
	protocol = headers.delete(UPGRADE)&.first
	
	super(version, status, headers, body, protocol)
end

def pool=(pool)

def pool=(pool)
	if @connection.idle? or @connection.closed?
		pool.release(@connection)
	else
		@connection.pool = pool
	end
end