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)
I know automatically following permanent redirects follows the spec, but I use
RestBuilderextensively for integration testing. It would be nice to turn this off so that redirects can be properly tested.My current workaround looks like this:
and here's the ClientHttpRequestFactory implementation:
Instead, I think it would be cleaner to turn this off via configuration (similiar to other connection properties). For example: