下面列出了org.apache.http.protocol.HttpProcessor#org.apache.http.client.RedirectHandler 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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 new RequestDirector() {
@Beta
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws HttpException, IOException {
return new BasicHttpResponse(HttpVersion.HTTP_1_1, responseCode, null);
}
};
}
@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);
}
public void setRedirectHandler(RedirectHandler redirecthandler)
{
c.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();
}
/**
* Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
* your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}
/**
* Allows you to set custom RedirectHandler implementation, if the default
* provided doesn't suit your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see cn.openwatch.internal.http.loopj.MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}
/**
* Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
* your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see com.wo2b.sdk.common.util.http.MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}
/**
* Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
* your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see com.loopj.android.http.MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}
/**
* Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
* your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see com.loopj.android.http.MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}
/**
* Allows you to set custom RedirectHandler implementation, if the default provided doesn't suit
* your needs
*
* @param customRedirectHandler RedirectHandler instance
* @see com.loopj.android.http.MyRedirectHandler
*/
public void setRedirectHandler(final RedirectHandler customRedirectHandler) {
httpClient.setRedirectHandler(customRedirectHandler);
}