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

Feature Request: Allow turning off automatic redirect following #55

Open
dustindclark opened this issue Apr 7, 2019 · 0 comments
Open

Comments

@dustindclark
Copy link

I know automatically following permanent redirects follows the spec, but I use RestBuilder extensively for integration testing. It would be nice to turn this off so that redirects can be properly tested.

My current workaround looks like this:

RestBuilder restBuilder = new RestBuilder()
restBuilder.restTemplate = new RestTemplate(new HttpRequestFactoryWithoutRedirectFollowing())

and here's the ClientHttpRequestFactory implementation:

class HttpRequestFactoryWithoutRedirectFollowing extends SimpleClientHttpRequestFactory {
    @Override
    protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
        super.prepareConnection(connection, httpMethod)
        connection.setInstanceFollowRedirects(false)
    }
}

Instead, I think it would be cleaner to turn this off via configuration (similiar to other connection properties). For example:

RestBuilder restBuilder = new RestBuilder(followRedirects: false)
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

No branches or pull requests

1 participant