org.apache.http.client.RedirectStrategy Java Examples

The following examples show how to use org.apache.http.client.RedirectStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientConfigTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testGetAndSetRedirectStrategy()
{
    RedirectStrategy redirectStrategy = mock(RedirectStrategy.class);
    config.setRedirectStrategy(redirectStrategy);
    assertEquals(redirectStrategy, config.getRedirectStrategy());
}
 
Example #2
Source File: HttpClientCustomConfigFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public HttpClientCustomConfigFacetImpl(
    final HttpClientManager httpClientManager,
    final Map<String, AutoBlockConfiguration> autoBlockConfiguration,
    final Map<String, RedirectStrategy> redirectStrategy,
    final RequestHeaderAuthenticationStrategy requestHeaderAuthenticationStrategy)
{
  super(httpClientManager, autoBlockConfiguration, redirectStrategy);
  this.requestHeaderAuthenticationStrategy = requestHeaderAuthenticationStrategy;
}
 
Example #3
Source File: HttpClientFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
HttpClientFacetImpl(final HttpClientManager httpClientManager,
                    final Map<String, AutoBlockConfiguration> autoBlockConfiguration,
                    final Map<String, RedirectStrategy> redirectStrategy,
                    final Config config) {
  this(httpClientManager, autoBlockConfiguration, redirectStrategy);
  this.config = checkNotNull(config);
  checkNotNull(autoBlockConfiguration.get(DEFAULT));
}
 
Example #4
Source File: HttpClientFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public HttpClientFacetImpl(final HttpClientManager httpClientManager,
                           final Map<String, AutoBlockConfiguration> autoBlockConfiguration,
                           final Map<String, RedirectStrategy> redirectStrategy)
{
  this.httpClientManager = checkNotNull(httpClientManager);
  this.autoBlockConfiguration = checkNotNull(autoBlockConfiguration);
  this.redirectStrategy = checkNotNull(redirectStrategy);
}
 
Example #5
Source File: HttpClientConfigurationData.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void setRedirectStrategy(@Nullable final RedirectStrategy redirectStrategy) {
  this.redirectStrategy = redirectStrategy;
}
 
Example #6
Source File: HttpClientManager.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public HttpClientBuilderFacade setRedirect( RedirectStrategy redirectStrategy ) {
  this.redirectStrategy = redirectStrategy;
  return this;
}
 
Example #7
Source File: HttpClientManager.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public HttpClientBuilderFacade setRedirect( RedirectStrategy redirectStrategy ) {
  this.redirectStrategy = redirectStrategy;
  return this;
}
 
Example #8
Source File: HttpClientFactory.java    From SeimiCrawler with Apache License 2.0 4 votes vote down vote up
public static HttpClientBuilder cliBuilder(int timeout) {
    HttpRequestRetryHandler retryHander = new HttpRequestRetryHandler() {
        @Override
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            if (executionCount > 3) {
                // Do not retry if over max retry count
                return false;
            }
            if (exception instanceof java.net.SocketTimeoutException) {
                //特殊处理
                return true;
            }
            if (exception instanceof InterruptedIOException) {
                // Timeout
                return true;
            }
            if (exception instanceof UnknownHostException) {
                // Unknown host
                return false;
            }

            if (exception instanceof SSLException) {
                // SSL handshake exception
                return false;
            }
            HttpClientContext clientContext = HttpClientContext.adapt(context);
            HttpRequest request = clientContext.getRequest();
            boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
            if (idempotent) {
                // Retry if the request is considered idempotent
                return true;
            }
            return false;
        }
    };
    RedirectStrategy redirectStrategy = new SeimiRedirectStrategy();
    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).setSocketTimeout(timeout).build();
    PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = HttpClientConnectionManagerProvider.getHcPoolInstance();
    return HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(poolingHttpClientConnectionManager)
            .setRedirectStrategy(redirectStrategy).setRetryHandler(retryHander);
}
 
Example #9
Source File: HttpClientFacetImpl.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
protected RedirectStrategy getRedirectStrategy() {
  return this.redirectStrategy.get(getRepository().getFormat().getValue());
}
 
Example #10
Source File: HttpClientConfiguration.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Nullable
RedirectStrategy getRedirectStrategy();
 
Example #11
Source File: ConfigurationCustomizer.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Apply redirect strategy to plan.
 */
private void apply(final RedirectStrategy redirectStrategy, final HttpClientPlan plan) {
  plan.getClient().setRedirectStrategy(redirectStrategy);
}
 
Example #12
Source File: HttpClientConfig.java    From vividus with Apache License 2.0 4 votes vote down vote up
public RedirectStrategy getRedirectStrategy()
{
    return redirectStrategy;
}
 
Example #13
Source File: HttpClientConfigurationData.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@Nullable
public RedirectStrategy getRedirectStrategy() {
  return redirectStrategy;
}
 
Example #14
Source File: OrientHttpClientConfiguration.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public void setRedirectStrategy(@Nullable final RedirectStrategy redirectStrategy) {
  this.redirectStrategy = redirectStrategy;
}
 
Example #15
Source File: OrientHttpClientConfiguration.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Nullable
public RedirectStrategy getRedirectStrategy() {
  return redirectStrategy;
}
 
Example #16
Source File: MemoryHttpClientConfigurationStore.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public void setRedirectStrategy(@Nullable final RedirectStrategy redirectStrategy) {
  this.redirectStrategy = redirectStrategy;
}
 
Example #17
Source File: MemoryHttpClientConfigurationStore.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Nullable
public RedirectStrategy getRedirectStrategy() {
  return redirectStrategy;
}
 
Example #18
Source File: SimpleHttpClientFactoryBean.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
 
Example #19
Source File: SimpleHttpClientFactoryBean.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
 
Example #20
Source File: HttpClientManager.java    From hop with Apache License 2.0 4 votes vote down vote up
public HttpClientBuilderFacade setRedirect( RedirectStrategy redirectStrategy ) {
  this.redirectStrategy = redirectStrategy;
  return this;
}
 
Example #21
Source File: HttpClientConfig.java    From vividus with Apache License 2.0 4 votes vote down vote up
public void setRedirectStrategy(RedirectStrategy redirectStrategy)
{
    this.redirectStrategy = redirectStrategy;
}
 
Example #22
Source File: HttpClientConfiguration.java    From nexus-public with Eclipse Public License 1.0 votes vote down vote up
void setRedirectStrategy(@Nullable final RedirectStrategy redirectStrategy);