本文整理汇总了Java中org.apache.http.client.RequestDirector类的典型用法代码示例。如果您正苦于以下问题:Java RequestDirector类的具体用法?Java RequestDirector怎么用?Java RequestDirector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestDirector类属于org.apache.http.client包,在下文中一共展示了RequestDirector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emulateRequest
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
public HttpResponse emulateRequest(HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext, RequestDirector requestDirector) throws HttpException, IOException {
if (logHttpRequests) {
System.out.println(" <-- " + httpRequest.getRequestLine());
}
HttpResponse httpResponse = findResponse(httpRequest);
if (logHttpRequests) {
System.out.println(" --> " + (httpResponse == null ? null : httpResponse.getStatusLine().getStatusCode()));
}
if (httpResponse == null) {
throw new RuntimeException("Unexpected call to execute, no pending responses are available. See Robolectric.addPendingResponse(). Request was: " +
httpRequest.getRequestLine().getMethod() + " " + httpRequest.getRequestLine().getUri());
} else {
HttpParams params = httpResponse.getParams();
if (HttpConnectionParams.getConnectionTimeout(params) < 0) {
throw new ConnectTimeoutException("Socket is not connected");
} else if (HttpConnectionParams.getSoTimeout(params) < 0) {
throw new ConnectTimeoutException("The operation timed out");
}
}
addRequestInfo(new HttpRequestInfo(httpRequest, httpHost, httpContext, requestDirector));
addHttpResponse(httpResponse);
return httpResponse;
}
示例2: getRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
/** 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);
}
示例3: getRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
/** 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);
}
示例4: createClientRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
/**
* @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);
}
示例5: AndroidHttpClient
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
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;
}
};
}
示例6: createClientRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
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);
}
示例7: createClientRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
@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);
}
示例8: createClientRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
@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);
}
示例9: createClientRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
@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);
}
示例10: HttpRequestInfo
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
public HttpRequestInfo(HttpRequest httpRequest, HttpHost httpHost, HttpContext httpContext, RequestDirector requestDirector) {
this.httpRequest = httpRequest;
this.httpHost = httpHost;
this.httpContext = httpContext;
this.requestDirector = requestDirector;
}
示例11: getRequestDirector
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
public RequestDirector getRequestDirector() {
return requestDirector;
}
示例12: getHttpClient
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
/** @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;
}
示例13: getHttpClient
import org.apache.http.client.RequestDirector; //导入依赖的package包/类
/** @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;
}