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

项目:lams    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:SoundcloudAPI    文件:ApiWrapper.java   
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
项目:paperchains    文件:ApiWrapper.java   
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) 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 RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) 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 RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:FMTech    文件:AndroidHttpClient.java   
private AndroidHttpClient(ClientConnectionManager paramClientConnectionManager, HttpParams paramHttpParams)
{
  this.delegate = new DefaultHttpClient(paramClientConnectionManager, paramHttpParams)
  {
    protected final RequestDirector createClientRequestDirector(HttpRequestExecutor paramAnonymousHttpRequestExecutor, ClientConnectionManager paramAnonymousClientConnectionManager, ConnectionReuseStrategy paramAnonymousConnectionReuseStrategy, ConnectionKeepAliveStrategy paramAnonymousConnectionKeepAliveStrategy, HttpRoutePlanner paramAnonymousHttpRoutePlanner, HttpProcessor paramAnonymousHttpProcessor, HttpRequestRetryHandler paramAnonymousHttpRequestRetryHandler, RedirectHandler paramAnonymousRedirectHandler, AuthenticationHandler paramAnonymousAuthenticationHandler1, AuthenticationHandler paramAnonymousAuthenticationHandler2, UserTokenHandler paramAnonymousUserTokenHandler, HttpParams paramAnonymousHttpParams)
    {
      return new ElegantRequestDirector(paramAnonymousHttpRequestExecutor, paramAnonymousClientConnectionManager, paramAnonymousConnectionReuseStrategy, paramAnonymousConnectionKeepAliveStrategy, paramAnonymousHttpRoutePlanner, paramAnonymousHttpProcessor, paramAnonymousHttpRequestRetryHandler, paramAnonymousRedirectHandler, paramAnonymousAuthenticationHandler1, paramAnonymousAuthenticationHandler2, paramAnonymousUserTokenHandler, paramAnonymousHttpParams);
    }

    protected final HttpContext createHttpContext()
    {
      BasicHttpContext localBasicHttpContext = new BasicHttpContext();
      localBasicHttpContext.setAttribute("http.authscheme-registry", getAuthSchemes());
      localBasicHttpContext.setAttribute("http.cookiespec-registry", getCookieSpecs());
      localBasicHttpContext.setAttribute("http.auth.credentials-provider", getCredentialsProvider());
      return localBasicHttpContext;
    }

    protected final BasicHttpProcessor createHttpProcessor()
    {
      BasicHttpProcessor localBasicHttpProcessor = super.createHttpProcessor();
      localBasicHttpProcessor.addRequestInterceptor(AndroidHttpClient.sThreadCheckInterceptor);
      localBasicHttpProcessor.addRequestInterceptor(new AndroidHttpClient.CurlLogger(AndroidHttpClient.this, (byte)0));
      return localBasicHttpProcessor;
    }
  };
}
项目:FullRobolectricTestSample    文件:ShadowDefaultRequestDirector.java   
public void __constructor__(
    HttpRequestExecutor requestExec,
    ClientConnectionManager conman,
    ConnectionReuseStrategy reustrat,
    ConnectionKeepAliveStrategy kastrat,
    HttpRoutePlanner rouplan,
    HttpProcessor httpProcessor,
    HttpRequestRetryHandler retryHandler,
    RedirectHandler redirectHandler,
    AuthenticationHandler targetAuthHandler,
    AuthenticationHandler proxyAuthHandler,
    UserTokenHandler userTokenHandler,
    HttpParams params) {
  __constructor__(
      LogFactory.getLog(DefaultRequestDirector.class),
      requestExec,
      conman,
      reustrat,
      kastrat,
      rouplan,
      httpProcessor,
      retryHandler,
      redirectHandler,
      targetAuthHandler,
      proxyAuthHandler,
      userTokenHandler,
      params);
}
项目:FullRobolectricTestSample    文件:DefaultRequestDirector.java   
public DefaultRequestDirector(
    final HttpRequestExecutor requestExec,
    final ClientConnectionManager conman,
    final ConnectionReuseStrategy reustrat,
    final ConnectionKeepAliveStrategy kastrat,
    final HttpRoutePlanner rouplan,
    final HttpProcessor httpProcessor,
    final HttpRequestRetryHandler retryHandler,
    final RedirectHandler redirectHandler,
    final AuthenticationHandler targetAuthHandler,
    final AuthenticationHandler proxyAuthHandler,
    final UserTokenHandler userTokenHandler,
    final HttpParams params) {
  this(LogFactory.getLog(DefaultRequestDirector.class),
      requestExec,
      conman,
      reustrat,
      kastrat,
      rouplan,
      httpProcessor,
      retryHandler,
      redirectHandler,
      targetAuthHandler,
      proxyAuthHandler,
      userTokenHandler,
      params);

}
项目:cJUnit-mc626    文件:AbstractHttpClient.java   
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 RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler stateHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            stateHandler,
            params);
}
项目:cJUnit-mc626    文件:DefaultRequestDirector.java   
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);

}
项目:YiBo    文件:LibHttpClient.java   
@Override
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 RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler stateHandler,
        final HttpParams params) {
    return new LibRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            stateHandler,
            params);
}
项目:yibo-library    文件:YiBoHttpClient.java   
@Override
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 RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler stateHandler,
        final HttpParams params) {
    return new YiBoRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            stateHandler,
            params);
}
项目:SecureShareLib    文件:ApiWrapper.java   
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
项目:lams    文件:DefaultRedirectStrategyAdaptor.java   
public DefaultRedirectStrategyAdaptor(final RedirectHandler handler) {
    super();
    this.handler = handler;
}
项目:lams    文件:DefaultRedirectStrategyAdaptor.java   
public RedirectHandler getHandler() {
    return this.handler;
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated 
protected RedirectHandler createRedirectHandler() {
    return new DefaultRedirectHandler();
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated 
public synchronized final RedirectHandler getRedirectHandler() {
    return createRedirectHandler();
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated 
public synchronized void setRedirectHandler(final RedirectHandler handler) {
    this.redirectStrategy = new DefaultRedirectStrategyAdaptor(handler);
}
项目:boohee_v5.6    文件:AsyncHttpClient.java   
public void setRedirectHandler(RedirectHandler customRedirectHandler) {
    this.httpClient.setRedirectHandler(customRedirectHandler);
}
项目:boohee_v5.6    文件:d.java   
protected final RedirectHandler createRedirectHandler() {
    return new e(this);
}
项目:purecloud-iot    文件:DefaultRedirectStrategyAdaptor.java   
public DefaultRedirectStrategyAdaptor(final RedirectHandler handler) {
    super();
    this.handler = handler;
}
项目:purecloud-iot    文件:DefaultRedirectStrategyAdaptor.java   
public RedirectHandler getHandler() {
    return this.handler;
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
protected RedirectHandler createRedirectHandler() {
    return new DefaultRedirectHandler();
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
public synchronized final RedirectHandler getRedirectHandler() {
    return createRedirectHandler();
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
public synchronized void setRedirectHandler(final RedirectHandler handler) {
    this.redirectStrategy = new DefaultRedirectStrategyAdaptor(handler);
}
项目:FMTech    文件:ElegantRequestDirector.java   
public ElegantRequestDirector(HttpRequestExecutor paramHttpRequestExecutor, ClientConnectionManager paramClientConnectionManager, ConnectionReuseStrategy paramConnectionReuseStrategy, ConnectionKeepAliveStrategy paramConnectionKeepAliveStrategy, HttpRoutePlanner paramHttpRoutePlanner, HttpProcessor paramHttpProcessor, HttpRequestRetryHandler paramHttpRequestRetryHandler, RedirectHandler paramRedirectHandler, AuthenticationHandler paramAuthenticationHandler1, AuthenticationHandler paramAuthenticationHandler2, UserTokenHandler paramUserTokenHandler, HttpParams paramHttpParams)
{
  super(paramHttpRequestExecutor, paramClientConnectionManager, paramConnectionReuseStrategy, paramConnectionKeepAliveStrategy, paramHttpRoutePlanner, paramHttpProcessor, paramHttpRequestRetryHandler, paramRedirectHandler, paramAuthenticationHandler1, paramAuthenticationHandler2, paramUserTokenHandler, paramHttpParams);
}
项目:MiBandDecompiled    文件:AsyncHttpClient.java   
public void setRedirectHandler(RedirectHandler redirecthandler)
{
    c.setRedirectHandler(redirecthandler);
}
项目:FullRobolectricTestSample    文件:ShadowDefaultRequestDirector.java   
public void __constructor__(
    Log log,
    HttpRequestExecutor requestExec,
    ClientConnectionManager conman,
    ConnectionReuseStrategy reustrat,
    ConnectionKeepAliveStrategy kastrat,
    HttpRoutePlanner rouplan,
    HttpProcessor httpProcessor,
    HttpRequestRetryHandler retryHandler,
    RedirectHandler redirectHandler,
    AuthenticationHandler targetAuthHandler,
    AuthenticationHandler proxyAuthHandler,
    UserTokenHandler userTokenHandler,
    HttpParams params) {
  this.log = log;
  this.httpRequestExecutor = requestExec;
  this.connectionManager = conman;
  this.connectionReuseStrategy = reustrat;
  this.connectionKeepAliveStrategy = kastrat;
  this.httpRoutePlanner = rouplan;
  this.httpProcessor = httpProcessor;
  this.httpRequestRetryHandler = retryHandler;
  this.redirectHandler = redirectHandler;
  this.targetAuthenticationHandler = targetAuthHandler;
  this.proxyAuthenticationHandler = proxyAuthHandler;
  this.userTokenHandler = userTokenHandler;
  this.httpParams = params;

  try {
    redirector = new org.robolectric.tester.org.apache.http.impl.client.DefaultRequestDirector(
        log,
        requestExec,
        conman,
        reustrat,
        kastrat,
        rouplan,
        httpProcessor,
        retryHandler,
        redirectHandler,
        targetAuthHandler,
        proxyAuthHandler,
        userTokenHandler,
        params
    );
  } catch (IllegalArgumentException ignored) {
    Robolectric.getFakeHttpLayer().interceptHttpRequests(true);
  }
}
项目:FullRobolectricTestSample    文件:ShadowDefaultRequestDirector.java   
public RedirectHandler getRedirectHandler() {
  return redirectHandler;
}
项目:cJUnit-mc626    文件:AbstractHttpClient.java   
public synchronized final RedirectHandler getRedirectHandler() {
    if (redirectHandler == null) {
        redirectHandler = createRedirectHandler();
    }
    return redirectHandler;
}
项目:cJUnit-mc626    文件:AbstractHttpClient.java   
public synchronized void setRedirectHandler(final RedirectHandler redirectHandler) {
    this.redirectHandler = redirectHandler;
}
项目:cJUnit-mc626    文件:DefaultHttpClient.java   
@Override
protected RedirectHandler createRedirectHandler() {
    return new DefaultRedirectHandler();
}
项目:SoundcloudAPI    文件:ApiWrapper.java   
/** @return The HttpClient instance used to make the calls */
public HttpClient getHttpClient() {
    if (httpClient == null) {
        final HttpParams params = getParams();
        HttpClientParams.setRedirecting(params, false);
        HttpProtocolParams.setUserAgent(params, getUserAgent());

        final SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", getSocketFactory(), 80));
        final SSLSocketFactory sslFactory = getSSLSocketFactory();
        registry.register(new Scheme("https", sslFactory, 443));
        httpClient = new DefaultHttpClient(
                new ThreadSafeClientConnManager(params, registry),
                params) {
            {
                setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
                    @Override
                    public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
                        return KEEPALIVE_TIMEOUT;
                    }
                });

                getCredentialsProvider().setCredentials(
                    new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, CloudAPI.REALM, OAUTH_SCHEME),
                    OAuth2Scheme.EmptyCredentials.INSTANCE);

                getAuthSchemes().register(CloudAPI.OAUTH_SCHEME, new OAuth2Scheme.Factory(ApiWrapper.this));

                addResponseInterceptor(new HttpResponseInterceptor() {
                    @Override
                    public void process(HttpResponse response, HttpContext context)
                            throws HttpException, IOException {
                        if (response == null || response.getEntity() == null) return;

                        HttpEntity entity = response.getEntity();
                        Header header = entity.getContentEncoding();
                        if (header != null) {
                            for (HeaderElement codec : header.getElements()) {
                                if (codec.getName().equalsIgnoreCase("gzip")) {
                                    response.setEntity(new GzipDecompressingEntity(entity));
                                    break;
                                }
                            }
                        }
                    }
                });
            }

            @Override protected HttpContext createHttpContext() {
                HttpContext ctxt = super.createHttpContext();
                ctxt.setAttribute(ClientContext.AUTH_SCHEME_PREF,
                        Arrays.asList(CloudAPI.OAUTH_SCHEME, "digest", "basic"));
                return ctxt;
            }

            @Override protected BasicHttpProcessor createHttpProcessor() {
                BasicHttpProcessor processor = super.createHttpProcessor();
                processor.addInterceptor(new OAuth2HttpRequestInterceptor());
                return processor;
            }

            // for testability only
            @Override protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                                  ClientConnectionManager conman,
                                                                  ConnectionReuseStrategy reustrat,
                                                                  ConnectionKeepAliveStrategy kastrat,
                                                                  HttpRoutePlanner rouplan,
                                                                  HttpProcessor httpProcessor,
                                                                  HttpRequestRetryHandler retryHandler,
                                                                  RedirectHandler redirectHandler,
                                                                  AuthenticationHandler targetAuthHandler,
                                                                  AuthenticationHandler proxyAuthHandler,
                                                                  UserTokenHandler stateHandler,
                                                                  HttpParams params) {
                return getRequestDirector(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
                        redirectHandler, targetAuthHandler, proxyAuthHandler, stateHandler, params);
            }
        };
    }
    return httpClient;
}
项目:prey-android-client-master    文件:PreyDefaultHttpClient.java   
public void setRedirectHandler(RedirectHandler redirectHandler) {
    this.client.setRedirectHandler(redirectHandler);
}
项目:paperchains    文件:ApiWrapper.java   
/** @return The HttpClient instance used to make the calls */
public HttpClient getHttpClient() {
    if (httpClient == null) {
        final HttpParams params = getParams();
        HttpClientParams.setRedirecting(params, false);
        HttpProtocolParams.setUserAgent(params, getUserAgent());

        final SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", getSocketFactory(), 80));
        final SSLSocketFactory sslFactory = getSSLSocketFactory();
        registry.register(new Scheme("https", sslFactory, 443));
        httpClient = new DefaultHttpClient(
                new ThreadSafeClientConnManager(params, registry),
                params) {
            {
                setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
                    @Override
                    public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
                        return KEEPALIVE_TIMEOUT;
                    }
                });

                getCredentialsProvider().setCredentials(
                        new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, CloudAPI.REALM, OAUTH_SCHEME),
                        OAuth2Scheme.EmptyCredentials.INSTANCE);

                getAuthSchemes().register(CloudAPI.OAUTH_SCHEME, new OAuth2Scheme.Factory(ApiWrapper.this));

                addResponseInterceptor(new HttpResponseInterceptor() {
                    @Override
                    public void process(HttpResponse response, HttpContext context)
                            throws HttpException, IOException {
                        if (response == null || response.getEntity() == null) return;

                        HttpEntity entity = response.getEntity();
                        Header header = entity.getContentEncoding();
                        if (header != null) {
                            for (HeaderElement codec : header.getElements()) {
                                if (codec.getName().equalsIgnoreCase("gzip")) {
                                    response.setEntity(new GzipDecompressingEntity(entity));
                                    break;
                                }
                            }
                        }
                    }
                });
            }

            @Override protected HttpContext createHttpContext() {
                HttpContext ctxt = super.createHttpContext();
                ctxt.setAttribute(ClientContext.AUTH_SCHEME_PREF,
                        Arrays.asList(CloudAPI.OAUTH_SCHEME, "digest", "basic"));
                return ctxt;
            }

            @Override protected BasicHttpProcessor createHttpProcessor() {
                BasicHttpProcessor processor = super.createHttpProcessor();
                processor.addInterceptor(new OAuth2HttpRequestInterceptor());
                return processor;
            }

            // for testability only
            @Override protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                                            ClientConnectionManager conman,
                                                                            ConnectionReuseStrategy reustrat,
                                                                            ConnectionKeepAliveStrategy kastrat,
                                                                            HttpRoutePlanner rouplan,
                                                                            HttpProcessor httpProcessor,
                                                                            HttpRequestRetryHandler retryHandler,
                                                                            RedirectHandler redirectHandler,
                                                                            AuthenticationHandler targetAuthHandler,
                                                                            AuthenticationHandler proxyAuthHandler,
                                                                            UserTokenHandler stateHandler,
                                                                            HttpParams params) {
                return getRequestDirector(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
                        redirectHandler, targetAuthHandler, proxyAuthHandler, stateHandler, params);
            }
        };
    }
    return httpClient;
}
项目:YiBo    文件:LibRequestDirector.java   
public LibRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {

    if (requestExec == null) {
        throw new IllegalArgumentException("Request executor may not be null.");
    }
    if (conman == null) {
        throw new IllegalArgumentException("Client connection manager may not be null.");
    }
    if (reustrat == null) {
        throw new IllegalArgumentException("Connection reuse strategy may not be null.");
    }
    if (kastrat == null) {
        throw new IllegalArgumentException("Connection keep alive strategy may not be null.");
    }
    if (rouplan == null) {
        throw new IllegalArgumentException("Route planner may not be null.");
    }
    if (httpProcessor == null) {
        throw new IllegalArgumentException("HTTP protocol processor may not be null.");
    }
    if (retryHandler == null) {
        throw new IllegalArgumentException("HTTP request retry handler may not be null.");
    }
    if (redirectHandler == null) {
        throw new IllegalArgumentException("Redirect handler may not be null.");
    }
    if (targetAuthHandler == null) {
        throw new IllegalArgumentException("Target authentication handler may not be null.");
    }
    if (proxyAuthHandler == null) {
        throw new IllegalArgumentException("Proxy authentication handler may not be null.");
    }
    if (userTokenHandler == null) {
        throw new IllegalArgumentException("User token handler may not be null.");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.requestExec       = requestExec;
    this.connManager       = conman;
    this.reuseStrategy     = reustrat;
    this.keepAliveStrategy = kastrat;
    this.routePlanner      = rouplan;
    this.httpProcessor     = httpProcessor;
    this.retryHandler      = retryHandler;
    this.redirectHandler   = redirectHandler;
    this.targetAuthHandler = targetAuthHandler;
    this.proxyAuthHandler  = proxyAuthHandler;
    this.userTokenHandler  = userTokenHandler;
    this.params            = params;

    this.managedConn       = null;

    this.execCount = 0;
    this.redirectCount = 0;
    this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
    this.targetAuthState = new AuthState();
    this.proxyAuthState = new AuthState();
}
项目:yibo-library    文件:YiBoRequestDirector.java   
public YiBoRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {

    if (requestExec == null) {
        throw new IllegalArgumentException("Request executor may not be null.");
    }
    if (conman == null) {
        throw new IllegalArgumentException("Client connection manager may not be null.");
    }
    if (reustrat == null) {
        throw new IllegalArgumentException("Connection reuse strategy may not be null.");
    }
    if (kastrat == null) {
        throw new IllegalArgumentException("Connection keep alive strategy may not be null.");
    }
    if (rouplan == null) {
        throw new IllegalArgumentException("Route planner may not be null.");
    }
    if (httpProcessor == null) {
        throw new IllegalArgumentException("HTTP protocol processor may not be null.");
    }
    if (retryHandler == null) {
        throw new IllegalArgumentException("HTTP request retry handler may not be null.");
    }
    if (redirectHandler == null) {
        throw new IllegalArgumentException("Redirect handler may not be null.");
    }
    if (targetAuthHandler == null) {
        throw new IllegalArgumentException("Target authentication handler may not be null.");
    }
    if (proxyAuthHandler == null) {
        throw new IllegalArgumentException("Proxy authentication handler may not be null.");
    }
    if (userTokenHandler == null) {
        throw new IllegalArgumentException("User token handler may not be null.");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.requestExec       = requestExec;
    this.connManager       = conman;
    this.reuseStrategy     = reustrat;
    this.keepAliveStrategy = kastrat;
    this.routePlanner      = rouplan;
    this.httpProcessor     = httpProcessor;
    this.retryHandler      = retryHandler;
    this.redirectHandler   = redirectHandler;
    this.targetAuthHandler = targetAuthHandler;
    this.proxyAuthHandler  = proxyAuthHandler;
    this.userTokenHandler  = userTokenHandler;
    this.params            = params;

    this.managedConn       = null;

    this.execCount = 0;
    this.redirectCount = 0;
    this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
    this.targetAuthState = new AuthState();
    this.proxyAuthState = new AuthState();
}
项目:SecureShareLib    文件:ApiWrapper.java   
/** @return The HttpClient instance used to make the calls */
public HttpClient getHttpClient() {
    if (httpClient == null) {
        final HttpParams params = getParams();
        HttpClientParams.setRedirecting(params, false);
        HttpProtocolParams.setUserAgent(params, getUserAgent());

        final SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", getSocketFactory(), 80));
        final SSLSocketFactory sslFactory = getSSLSocketFactory();
        registry.register(new Scheme("https", sslFactory, 443));
        httpClient = new DefaultHttpClient(
                new ThreadSafeClientConnManager(params, registry),
                params) {
            {
                setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
                    @Override
                    public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
                        return KEEPALIVE_TIMEOUT;
                    }
                });

                getCredentialsProvider().setCredentials(
                    new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, CloudAPI.REALM, OAUTH_SCHEME),
                    OAuth2Scheme.EmptyCredentials.INSTANCE);

                getAuthSchemes().register(CloudAPI.OAUTH_SCHEME, new OAuth2Scheme.Factory(ApiWrapper.this));

                addResponseInterceptor(new HttpResponseInterceptor() {
                    @Override
                    public void process(HttpResponse response, HttpContext context)
                            throws HttpException, IOException {
                        if (response == null || response.getEntity() == null) return;

                        HttpEntity entity = response.getEntity();
                        Header header = entity.getContentEncoding();
                        if (header != null) {
                            for (HeaderElement codec : header.getElements()) {
                                if (codec.getName().equalsIgnoreCase("gzip")) {
                                    response.setEntity(new GzipDecompressingEntity(entity));
                                    break;
                                }
                            }
                        }
                    }
                });
            }

            @Override protected HttpContext createHttpContext() {
                HttpContext ctxt = super.createHttpContext();
                ctxt.setAttribute(ClientContext.AUTH_SCHEME_PREF,
                        Arrays.asList(CloudAPI.OAUTH_SCHEME, "digest", "basic"));
                return ctxt;
            }

            @Override protected BasicHttpProcessor createHttpProcessor() {
                BasicHttpProcessor processor = super.createHttpProcessor();
                processor.addInterceptor(new OAuth2HttpRequestInterceptor());
                return processor;
            }

            // for testability only
            @Override protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                                  ClientConnectionManager conman,
                                                                  ConnectionReuseStrategy reustrat,
                                                                  ConnectionKeepAliveStrategy kastrat,
                                                                  HttpRoutePlanner rouplan,
                                                                  HttpProcessor httpProcessor,
                                                                  HttpRequestRetryHandler retryHandler,
                                                                  RedirectHandler redirectHandler,
                                                                  AuthenticationHandler targetAuthHandler,
                                                                  AuthenticationHandler proxyAuthHandler,
                                                                  UserTokenHandler stateHandler,
                                                                  HttpParams params) {
                return getRequestDirector(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
                        redirectHandler, targetAuthHandler, proxyAuthHandler, stateHandler, params);
            }
        };
    }
    return httpClient;
}
项目:android-project-gallery    文件:AsyncHttpClient.java   
/**
 * Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
 * your needs
 *
 * @param customRedirectHandler RedirectHandler instance
 * @see com.opencdk.common.util.http.MyRedirectHandler
 */
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
    httpClient.setRedirectHandler(customRedirectHandler);
}