Created
November 21, 2013 13:48
-
-
Save hamnis/7581821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.http; | |
import org.apache.http.client.config.RequestConfig; | |
import org.codehaus.httpcache4j.HTTPHost; | |
public class NotRedirectingHttpClientFactory extends HttpClientFactory { | |
@Override | |
protected RequestConfig requestConfig(HTTPHost proxyHost, ConnectionConfiguration config) { | |
RequestConfig c = super.requestConfig(proxyHost, config); | |
RequestConfig.Builder builder = RequestConfig.copy(c); | |
builder.setRedirectsEnabled(false); | |
return builder.build(); | |
} | |
public static CloseableHttpClient defaultClient() { | |
HttpClientBuilder builder = HttpClientBuilder.create(); | |
return new NotRedirectingHttpClientFactory().configure(builder, new ResolverConfiguration()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment