Java 类org.apache.http.client.RedirectStrategy 实例源码

项目:lams    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            redirectStrategy,
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:java-apache-httpclient    文件:TracingHttpClientBuilder.java   
/**
     * @param redirectStrategy redirect strategy, do not call
     * {@link HttpClientBuilder#disableRedirectHandling()}
     * @param redirectHandlingDisabled disable redirect strategy, do not call
     * {@link org.apache.http.impl.client.HttpClientBuilder#setRedirectStrategy(RedirectStrategy)}
     * @param tracer tracer instance
     * @param spanDecorators decorators
     */
public TracingHttpClientBuilder(
    RedirectStrategy redirectStrategy,
    boolean redirectHandlingDisabled,
    Tracer tracer,
    List<ApacheClientSpanDecorator> spanDecorators) {
    this.redirectStrategy = redirectStrategy;
    this.redirectHandlingDisabled = redirectHandlingDisabled;
    this.tracer = tracer;
    this.spanDecorators = new ArrayList<>(spanDecorators);

    super.setRedirectStrategy(redirectStrategy);
    if (redirectHandlingDisabled) {
        super.disableRedirectHandling();
    }
}
项目:purecloud-iot    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            redirectStrategy,
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:nexus-public    文件:NexusRedirectStrategyTest.java   
@Test
public void doFollowCrossSiteRedirects() throws Exception {
  when(response.getStatusLine()).thenReturn(statusLine);

  final RedirectStrategy underTest = new NexusRedirectStrategy();

  // simple cross redirect
  request = new HttpGet("http://hostA/dir");
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://hostB/dir"));
  assertThat(underTest.isRedirected(request, response, new BasicHttpContext()), is(true));

  // cross redirect to dir (failed coz NEXUS-5744)
  request = new HttpGet("http://hostA/dir/");
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://hostB/dir/"));
  assertThat(underTest.isRedirected(request, response, new BasicHttpContext()), is(true));
}
项目:yunti-speed-test    文件:HttpUtils.java   
/**
 * HTTP GET Without Handling HTTP redirects automatically
 * 
 * @param url
 * @param headers
 * @return CloseableHttpResponse
 */
public static CloseableHttpResponse getWithoutAutoRedirect(String url, Map<String, String> headers) {
    if (url == null) {
        return null;
    }
    HttpGet get = new HttpGet(url);
    addHeaders(get, headers);
    CloseableHttpResponse response = null;
    try {
        client = HttpClients.custom().disableRedirectHandling().build();
        response = visit(get);
        RedirectStrategy rs = DefaultRedirectStrategy.INSTANCE;
        client = HttpClients.custom().setRedirectStrategy(rs).build();
    } catch (Exception e) {
        logger.error(e.getMessage());
        e.printStackTrace();
    }
    return response;
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @since 4.1
 */
public synchronized final RedirectStrategy getRedirectStrategy() {
    if (redirectStrategy == null) {
        redirectStrategy = new DefaultRedirectStrategy();
    }
    return redirectStrategy;
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.2) do not use
 */
@Deprecated 
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @since 4.2
 */
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler,
            params);
}
项目:java-apache-httpclient    文件:TracingClientExec.java   
public TracingClientExec(
    ClientExecChain clientExecChain,
    RedirectStrategy redirectStrategy,
    boolean redirectHandlingDisabled,
    Tracer tracer,
    List<ApacheClientSpanDecorator> spanDecorators) {
  this.requestExecutor = clientExecChain;
  this.redirectStrategy = redirectStrategy;
  this.redirectHandlingDisabled = redirectHandlingDisabled;
  this.tracer = tracer;
  this.spanDecorators = new ArrayList<>(spanDecorators);
}
项目:java-apache-httpclient    文件:TracingHttpClientBuilder.java   
/**
 * @param redirectStrategy redirect strategy, do not call
 * {@link HttpClientBuilder#disableRedirectHandling()}
 * @param redirectHandlingDisabled disable redirect strategy, do not call
 * {@link org.apache.http.impl.client.HttpClientBuilder#setRedirectStrategy(RedirectStrategy)}
 */
public TracingHttpClientBuilder(
    RedirectStrategy redirectStrategy,
    boolean redirectHandlingDisabled) {
    this(redirectStrategy,
        redirectHandlingDisabled,
        GlobalTracer.get(),
        Collections.<ApacheClientSpanDecorator>singletonList(new StandardTags()));
}
项目:hrrs    文件:ApacheHttpClientFactory.java   
private void setRedirectStrategy(HttpClientBuilder httpClientBuilder) {
    RedirectStrategy redirectStrategy = config.getRedirectStrategy().getImplementation();
    if (redirectStrategy == null) {
        httpClientBuilder.disableRedirectHandling();
    } else {
        httpClientBuilder.setRedirectStrategy(redirectStrategy);
    }
}
项目:remote-files-sync    文件:RedirectExec.java   
public RedirectExec(
        final ClientExecChain requestExecutor,
        final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy) {
    super();
    Args.notNull(requestExecutor, "HTTP client request executor");
    Args.notNull(routePlanner, "HTTP route planner");
    Args.notNull(redirectStrategy, "HTTP redirect strategy");
    this.requestExecutor = requestExecutor;
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @since 4.1
 */
public synchronized final RedirectStrategy getRedirectStrategy() {
    if (redirectStrategy == null) {
        redirectStrategy = new DefaultRedirectStrategy();
    }
    return redirectStrategy;
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.2) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @since 4.2
 */
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:RedirectExec.java   
public RedirectExec(
        final ClientExecChain requestExecutor,
        final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy) {
    super();
    Args.notNull(requestExecutor, "HTTP client request executor");
    Args.notNull(routePlanner, "HTTP route planner");
    Args.notNull(redirectStrategy, "HTTP redirect strategy");
    this.requestExecutor = requestExecutor;
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
}
项目:nexus-public    文件:NexusRedirectStrategyTest.java   
@Test
public void doNotFollowRedirectsToDirIndex() throws Exception {
  when(response.getStatusLine()).thenReturn(statusLine);

  final RedirectStrategy underTest = new NexusRedirectStrategy();
  HttpContext httpContext;

  // no location header
  request = new HttpGet("http://localhost/dir/fileA");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_OK);
  assertThat(underTest.isRedirected(request, response, httpContext), is(false));

  // redirect to file
  request = new HttpGet("http://localhost/dir/fileA");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://localhost/dir/fileB"));
  assertThat(underTest.isRedirected(request, response, httpContext), is(true));

  // redirect to dir
  request = new HttpGet("http://localhost/dir");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://localhost/dir/"));
  assertThat(underTest.isRedirected(request, response, httpContext), is(false));
}
项目:Visit    文件:RedirectExec.java   
public RedirectExec(
        final ClientExecChain requestExecutor,
        final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy) {
    super();
    Args.notNull(requestExecutor, "HTTP client request executor");
    Args.notNull(routePlanner, "HTTP route planner");
    Args.notNull(redirectStrategy, "HTTP redirect strategy");
    this.requestExecutor = requestExecutor;
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
}
项目:ZTLib    文件:RedirectExec.java   
public RedirectExec(
        final ClientExecChain requestExecutor,
        final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy) {
    super();
    Args.notNull(requestExecutor, "HTTP client request executor");
    Args.notNull(routePlanner, "HTTP route planner");
    Args.notNull(redirectStrategy, "HTTP redirect strategy");
    this.requestExecutor = requestExecutor;
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
}
项目:BigSemanticsJava    文件:RedirectHttpClient.java   
@Override
protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                      ClientConnectionManager conman,
                                                      ConnectionReuseStrategy reustrat,
                                                      ConnectionKeepAliveStrategy kastrat,
                                                      HttpRoutePlanner rouplan,
                                                      HttpProcessor httpProcessor,
                                                      HttpRequestRetryHandler retryHandler,
                                                      RedirectStrategy redirectStrategy,
                                                      AuthenticationStrategy targetAuthStrategy,
                                                      AuthenticationStrategy proxyAuthStrategy,
                                                      UserTokenHandler userTokenHandler,
                                                      HttpParams params)
{
  return new RedirectRequestDirector(log,
                                     requestExec,
                                     conman,
                                     reustrat,
                                     kastrat,
                                     rouplan,
                                     httpProcessor,
                                     retryHandler,
                                     redirectStrategy,
                                     targetAuthStrategy,
                                     proxyAuthStrategy,
                                     userTokenHandler,
                                     params);
}
项目:BigSemanticsJava    文件:RedirectRequestDirector.java   
public RedirectRequestDirector(Log log,
                               HttpRequestExecutor requestExec,
                               ClientConnectionManager conman,
                               ConnectionReuseStrategy reustrat,
                               ConnectionKeepAliveStrategy kastrat,
                               HttpRoutePlanner rouplan,
                               HttpProcessor httpProcessor,
                               HttpRequestRetryHandler retryHandler,
                               RedirectStrategy redirectStrategy,
                               AuthenticationStrategy targetAuthStrategy,
                               AuthenticationStrategy proxyAuthStrategy,
                               UserTokenHandler userTokenHandler,
                               HttpParams params)
{
  super(log,
        requestExec,
        conman,
        reustrat,
        kastrat,
        rouplan,
        httpProcessor,
        retryHandler,
        redirectStrategy,
        targetAuthStrategy,
        proxyAuthStrategy,
        userTokenHandler,
        params);
}
项目:jspider    文件:HttpClientFactory.java   
protected RedirectStrategy createRedirectStrategy() {
    return new FormatLocationRedirectStrategy();
}
项目:springboot-shiro-cas-mybatis    文件:SimpleHttpClientFactoryBean.java   
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
项目:springboot-shiro-cas-mybatis    文件:SimpleHttpClientFactoryBean.java   
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
项目:springboot-shiro-cas-mybatis    文件:SimpleHttpClientFactoryBean.java   
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
项目:springboot-shiro-cas-mybatis    文件:SimpleHttpClientFactoryBean.java   
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
项目:cas-5.1.0    文件:SimpleHttpClientFactoryBean.java   
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
项目:cas-5.1.0    文件:SimpleHttpClientFactoryBean.java   
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
项目:datarouter    文件:DatarouterHttpClientBuilder.java   
public DatarouterHttpClientBuilder setRedirectStrategy(RedirectStrategy redirectStrategy){
    httpClientBuilder.setRedirectStrategy(redirectStrategy);
    return this;
}
项目:cas-server-4.2.1    文件:SimpleHttpClientFactoryBean.java   
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
项目:cas-server-4.2.1    文件:SimpleHttpClientFactoryBean.java   
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @since 4.1
 */
public synchronized void setRedirectStrategy(final RedirectStrategy strategy) {
    this.redirectStrategy = strategy;
}
项目:aerodrome-for-jet    文件:APIHttpClient.java   
/**
 * Create a redirect and robots.txt strategy 
 * @return strategy 
 */
protected RedirectStrategy createRedirectAndRobotsStrategy()
{
  return new DefaultRedirectHandler(
      getUserAgent(), new RobotDirectives( "*", getCrawlDelay()));
}
项目:cas4.1.9    文件:SimpleHttpClientFactoryBean.java   
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
项目:cas4.1.9    文件:SimpleHttpClientFactoryBean.java   
public void setRedirectionStrategy(final RedirectStrategy redirectionStrategy) {
    this.redirectionStrategy = redirectionStrategy;
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @since 4.1
 */
public synchronized void setRedirectStrategy(final RedirectStrategy strategy) {
    this.redirectStrategy = strategy;
}
项目:purecloud-iot    文件:DefaultRequestDirector.java   
/**
 * @since 4.2
 */
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {

    Args.notNull(log, "Log");
    Args.notNull(requestExec, "Request executor");
    Args.notNull(conman, "Client connection manager");
    Args.notNull(reustrat, "Connection reuse strategy");
    Args.notNull(kastrat, "Connection keep alive strategy");
    Args.notNull(rouplan, "Route planner");
    Args.notNull(httpProcessor, "HTTP protocol processor");
    Args.notNull(retryHandler, "HTTP request retry handler");
    Args.notNull(redirectStrategy, "Redirect strategy");
    Args.notNull(targetAuthStrategy, "Target authentication strategy");
    Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
    Args.notNull(userTokenHandler, "User token handler");
    Args.notNull(params, "HTTP parameters");
    this.log               = log;
    this.authenticator     = new HttpAuthenticator(log);
    this.requestExec        = requestExec;
    this.connManager        = conman;
    this.reuseStrategy      = reustrat;
    this.keepAliveStrategy  = kastrat;
    this.routePlanner       = rouplan;
    this.httpProcessor      = httpProcessor;
    this.retryHandler       = retryHandler;
    this.redirectStrategy   = redirectStrategy;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy  = proxyAuthStrategy;
    this.userTokenHandler   = userTokenHandler;
    this.params             = params;

    if (redirectStrategy instanceof DefaultRedirectStrategyAdaptor) {
        this.redirectHandler = ((DefaultRedirectStrategyAdaptor) redirectStrategy).getHandler();
    } else {
        this.redirectHandler = null;
    }
    if (targetAuthStrategy instanceof AuthenticationStrategyAdaptor) {
        this.targetAuthHandler = ((AuthenticationStrategyAdaptor) targetAuthStrategy).getHandler();
    } else {
        this.targetAuthHandler = null;
    }
    if (proxyAuthStrategy instanceof AuthenticationStrategyAdaptor) {
        this.proxyAuthHandler = ((AuthenticationStrategyAdaptor) proxyAuthStrategy).getHandler();
    } else {
        this.proxyAuthHandler = null;
    }

    this.managedConn = null;

    this.execCount = 0;
    this.redirectCount = 0;
    this.targetAuthState = new AuthState();
    this.proxyAuthState = new AuthState();
    this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
}
项目:openimaj    文件:HttpUtils.java   
/**
 * Read the contents of the given {@link URL} as a
 * {@link ByteArrayInputStream} (i.e. a byte[] in memory wrapped in an
 * {@link InputStream}). If redirects are not being followed, then the
 * result will be null if the URL is redirected.
 *
 * @param url
 *            the URL to read from
 * @param connectionTimeout
 *            amount of time to wait for connection
 * @param readTimeout
 *            amount of time to wait for reading
 * @param redirectStrategy
 *            the redirection strategy
 * @param userAgent
 *            the useragent string
 * @return the content referenced by the URL
 * @throws IOException
 *             if an error occurs
 * @throws IllegalArgumentException
 *             if the URL is not an HTTP(s) URL
 */
public static IndependentPair<HttpEntity, ByteArrayInputStream> readURLAsByteArrayInputStream(URL url,
        int connectionTimeout, int readTimeout, RedirectStrategy redirectStrategy, String userAgent)
        throws IOException
{
    DefaultHttpClient c = null;
    try {
        final HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
        HttpConnectionParams.setSoTimeout(params, readTimeout);
        HttpProtocolParams.setUserAgent(params, userAgent);
        HttpClientParams.setRedirecting(params, redirectStrategy != null);
        final boolean followRedirects = redirectStrategy != null;
        c = new DefaultHttpClient(params);
        if (followRedirects)
            c.setRedirectStrategy(redirectStrategy);
        HttpResponse resp = null;
        try {
            resp = c.execute(new HttpGet(url.toURI()));
        } catch (final URISyntaxException e) {
            throw new IOException(e);
        }

        final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        final InputStream stream = resp.getEntity().getContent();
        final byte[] tempBuffer = new byte[1024];

        // read the rest!
        while (true) {
            final int readThisTime = stream.read(tempBuffer);
            if (readThisTime == -1) {
                break;
            }
            // write to the outStream
            outStream.write(tempBuffer, 0, readThisTime);
        }
        final IndependentPair<HttpEntity, ByteArrayInputStream> toRet = IndependentPair.pair(resp.getEntity(),
                new ByteArrayInputStream(outStream.toByteArray()));
        ;
        return toRet;
    } finally {
        if (c != null)
            c.getConnectionManager().shutdown();
    }

}
项目:pentaho-kettle    文件:HttpClientManager.java   
public HttpClientBuilderFacade setRedirect( RedirectStrategy redirectStrategy ) {
  this.redirectStrategy = redirectStrategy;
  return this;
}
项目:sling-org-apache-sling-testing-clients    文件:SlingClient.java   
/**
 * Assigns {@link RedirectStrategy} instance.
 * <p>Please note this value can be overridden by the {@link #disableRedirectHandling()} method.</p>
 *
 * @param redirectStrategy custom redirect strategy
 * @return this
 */
public final InternalBuilder<T> setRedirectStrategy(final RedirectStrategy redirectStrategy) {
    httpClientBuilder.setRedirectStrategy(redirectStrategy);
    return this;
}