class Async::HTTP::Proxy

def connect(&block)

Returns:
  • (Socket) - a connected bi-directional socket.
def connect(&block)
	input = Body::Writable.new
	
	response = @client.connect(@address.to_s, @headers, input)
	
	if response.success?
		pipe = Body::Pipe.new(response.body, input)
		
		return pipe.to_io unless block_given?
		
		begin
			yield pipe.to_io
		ensure
			pipe.close
		end
	else
		# This ensures we don't leave a response dangling:
		response.close
		
		raise ConnectFailure, response
	end
end