class CustomClientHttpRequestFactory extends SimpleClientHttpRequestFactory {


    @Override
    protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {<FILL_FUNCTION_BODY>}
}

        super.prepareConnection(connection, httpMethod);
        // Use custom ClientHttpRequestFactory to set followRedirects false.
        connection.setInstanceFollowRedirects(false);
    
<no_super_class>