Skip to content

Async::HTTP::RelativeLocation doesn't seem to work for absolute URLs #171

@korbin

Description

@korbin

In RelativeLocation, we immediately return if a URI is absolute:

while hops <= @maximum_hops
	response = super(request)
	
	if response.redirection?
		hops += 1
		
		# Get the redirect location:
		unless location = response.headers['location']
			return response
		end
		
		response.finish
		
		uri = URI.parse(location)
		
		if uri.absolute?
			return response
		else
...

Perhaps I am using it wrong, but it seems like this doesn't follow the absolute redirect as it should?

If I change this block, the while loop correctly iterates and the redirect is transparently followed as I would expect:

if uri.absolute?
	endpoint = Endpoint[uri]
	request.scheme = endpoint.scheme
	request.authority = endpoint.authority
	request.path = endpoint.path
else
...

Maybe this isn't the intended behavior (please close this issue and disregard) or I am using the library incorrectly - I didn't see a test for absolute redirects, but the comments seem to indicate that this is a "Client wrapper which transparently handles both relative and absolute redirects to a given maximum number of hops."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions