Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#215 Add followRedirects support to the Akka Http backend #228

Conversation

2m
Copy link

@2m 2m commented Jan 24, 2018

This adds followRedirects support to the Akka Http backend.

While adding tests for the followRedirects functionality I noticed some inconsistent behaviour of the Ahc backend. Therefore some of the tests are marked as pending for the Ahc backend.

This PR builds on top of #227 (which builds on top of #208 in itself) and therefore should be rebased and retargeted to master after #227 is merged.

Fixes #215

return CompletableFuture.completedFuture(response);
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this into Akka itself? even if only working on the high level API it'd be nice anyway to have it there?

cc @jrudolph

if (redirectsLeft < 1) {
Future.failed(new IllegalStateException("Maximum redirect reached: " + MaxRedirects))
} else if (response.status.isRedirection() && config.followRedirects) {
val location = response.header[Location].get.uri

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs explicit handling of missing Location header to improve the error message in that case.

val redirectUri =
if (location.isRelative)
if (location.path.startsWithSlash)
request.uri.withPath(location.path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use location.resolveAgainst(request.uri) instead.

@2m
Copy link
Author

2m commented Feb 18, 2018

Closing the akka-http backend related tickets for now. These will be handled in the future.

@2m 2m closed this Feb 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants