class Async::HTTP::RelativeLocation

def call(request)

def call(request)
	hops = 0
	
	# We need to cache the body as it might be submitted multiple times.
	request.finish
	
	while hops <= @maximum_hops
		response = super(request)
		
		if response.redirection?
			hops += 1
			response.finish
			
			location = response.headers['location']
			uri = URI.parse(location)
			
			if uri.absolute?
				return response
			else
				request.path = Reference[request.path] + location
			end
			
			unless response.preserve_method?
				request.method = DEFAULT_METHOD
			end
		else
			return response
		end
	end
	
	raise TooManyRedirects, "Redirected #{hops} times, exceeded maximum!"
end