class Async::HTTP::Client

def connect

def connect
	Async::IO::Address.each(@addresses) do |address|
		# puts "Connecting to #{address} on process #{Process.pid}"
		
		address.connect do |peer|
			stream = Async::IO::Stream.new(peer)
			
			# We only yield for first successful connection.
			
			return yield @protocol_class.new(stream)
		end
	end
end

def get(path, headers = {})

def get(path, headers = {})
	connect do |protocol|
		protocol.send_request(GET, path, headers)
	end
end

def initialize(addresses, protocol_class = Protocol::HTTP11)

def initialize(addresses, protocol_class = Protocol::HTTP11)
	@addresses = addresses
	
	@protocol_class = protocol_class
end