本文整理汇总了Java中ch.boye.httpclientandroidlib.client.params.ClientPNames类的典型用法代码示例。如果您正苦于以下问题:Java ClientPNames类的具体用法?Java ClientPNames怎么用?Java ClientPNames使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientPNames类属于ch.boye.httpclientandroidlib.client.params包,在下文中一共展示了ClientPNames类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import ch.boye.httpclientandroidlib.client.params.ClientPNames; //导入依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
final String method = request.getRequestLine().getMethod();
if (method.equalsIgnoreCase("CONNECT")) {
return;
}
// Add default headers
@SuppressWarnings("unchecked")
Collection<? extends Header> defHeaders = (Collection<? extends Header>)
request.getParams().getParameter(ClientPNames.DEFAULT_HEADERS);
if (defHeaders == null) {
defHeaders = this.defaultHeaders;
}
if (defHeaders != null) {
for (final Header defHeader : defHeaders) {
request.addHeader(defHeader);
}
}
}
示例2: determineRoute
import ch.boye.httpclientandroidlib.client.params.ClientPNames; //导入依赖的package包/类
private HttpRoute determineRoute(
final HttpHost target,
final HttpRequest request,
final HttpContext context) throws HttpException {
HttpHost host = target;
if (host == null) {
host = (HttpHost) request.getParams().getParameter(ClientPNames.DEFAULT_HOST);
}
return this.routePlanner.determineRoute(host, request, context);
}
示例3: DefaultRequestDirector
import ch.boye.httpclientandroidlib.client.params.ClientPNames; //导入依赖的package包/类
/**
* @since 4.2
*/
public DefaultRequestDirector(
final HttpClientAndroidLog 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);
}
示例4: determineRoute
import ch.boye.httpclientandroidlib.client.params.ClientPNames; //导入依赖的package包/类
/**
* Determines the route for a request.
* Called by {@link #execute}
* to determine the route for either the original or a followup request.
*
* @param targetHost the target host for the request.
* Implementations may accept <code>null</code>
* if they can still determine a route, for example
* to a default target or by inspecting the request.
* @param request the request to execute
* @param context the context to use for the execution,
* never <code>null</code>
*
* @return the route the request should take
*
* @throws HttpException in case of a problem
*/
protected HttpRoute determineRoute(final HttpHost targetHost,
final HttpRequest request,
final HttpContext context)
throws HttpException {
return this.routePlanner.determineRoute(
targetHost != null ? targetHost : (HttpHost) request.getParams()
.getParameter(ClientPNames.DEFAULT_HOST),
request, context);
}