Skip to content

Feature Request: Allow turning off automatic redirect following #55

Description

@dustindclark

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions