@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); }
/** 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); }
/** * @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); }
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; } }; }
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); }
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); }
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); }
@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); }
@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); }
public DefaultRedirectStrategyAdaptor(final RedirectHandler handler) { super(); this.handler = handler; }
public RedirectHandler getHandler() { return this.handler; }
/** * @deprecated (4.1) do not use */ @Deprecated protected RedirectHandler createRedirectHandler() { return new DefaultRedirectHandler(); }
/** * @deprecated (4.1) do not use */ @Deprecated public synchronized final RedirectHandler getRedirectHandler() { return createRedirectHandler(); }
/** * @deprecated (4.1) do not use */ @Deprecated public synchronized void setRedirectHandler(final RedirectHandler handler) { this.redirectStrategy = new DefaultRedirectStrategyAdaptor(handler); }
public void setRedirectHandler(RedirectHandler customRedirectHandler) { this.httpClient.setRedirectHandler(customRedirectHandler); }
protected final RedirectHandler createRedirectHandler() { return new e(this); }
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); }
public void setRedirectHandler(RedirectHandler redirecthandler) { c.setRedirectHandler(redirecthandler); }
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); } }
public RedirectHandler getRedirectHandler() { return redirectHandler; }
public synchronized final RedirectHandler getRedirectHandler() { if (redirectHandler == null) { redirectHandler = createRedirectHandler(); } return redirectHandler; }
public synchronized void setRedirectHandler(final RedirectHandler redirectHandler) { this.redirectHandler = redirectHandler; }
@Override protected RedirectHandler createRedirectHandler() { return new DefaultRedirectHandler(); }
/** @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; }
public void setRedirectHandler(RedirectHandler redirectHandler) { this.client.setRedirectHandler(redirectHandler); }
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(); }
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(); }
/** * 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); }