本文整理汇总了Java中org.apache.http.conn.routing.HttpRoutePlanner类的典型用法代码示例。如果您正苦于以下问题:Java HttpRoutePlanner类的具体用法?Java HttpRoutePlanner怎么用?Java HttpRoutePlanner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpRoutePlanner类属于org.apache.http.conn.routing包,在下文中一共展示了HttpRoutePlanner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultRequestDirector
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
@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);
}
示例2: InternalHttpClient
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
public InternalHttpClient(
final ClientExecChain execChain,
final HttpClientConnectionManager connManager,
final HttpRoutePlanner routePlanner,
final Lookup<CookieSpecProvider> cookieSpecRegistry,
final Lookup<AuthSchemeProvider> authSchemeRegistry,
final CookieStore cookieStore,
final CredentialsProvider credentialsProvider,
final RequestConfig defaultConfig,
final List<Closeable> closeables) {
super();
Args.notNull(execChain, "HTTP client exec chain");
Args.notNull(connManager, "HTTP connection manager");
Args.notNull(routePlanner, "HTTP route planner");
this.execChain = execChain;
this.connManager = connManager;
this.routePlanner = routePlanner;
this.cookieSpecRegistry = cookieSpecRegistry;
this.authSchemeRegistry = authSchemeRegistry;
this.cookieStore = cookieStore;
this.credentialsProvider = credentialsProvider;
this.defaultConfig = defaultConfig;
this.closeables = closeables;
}
示例3: setup
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
execChain = Mockito.mock(ClientExecChain.class);
connManager = Mockito.mock(HttpClientConnectionManager.class);
routePlanner = Mockito.mock(HttpRoutePlanner.class);
cookieSpecRegistry = Mockito.mock(Lookup.class);
authSchemeRegistry = Mockito.mock(Lookup.class);
cookieStore = Mockito.mock(CookieStore.class);
credentialsProvider = Mockito.mock(CredentialsProvider.class);
defaultConfig = RequestConfig.custom().build();
closeable1 = Mockito.mock(Closeable.class);
closeable2 = Mockito.mock(Closeable.class);
client = new InternalHttpClient(execChain, connManager, routePlanner,
cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider,
defaultConfig, Arrays.asList(closeable1, closeable2));
}
示例4: getRequestDirector
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的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);
}
示例5: getRequestDirector
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的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);
}
示例6: createRequestFactory
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
public ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean
trustSelfSignedCerts) {
HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
if (trustSelfSignedCerts) {
httpClientBuilder.setSslcontext(buildSslContext());
httpClientBuilder.setHostnameVerifier(BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
if (httpProxyConfiguration != null) {
HttpHost proxy = new HttpHost(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort());
httpClientBuilder.setProxy(proxy);
if (httpProxyConfiguration.isAuthRequired()) {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort()),
new UsernamePasswordCredentials(httpProxyConfiguration.getUsername(), httpProxyConfiguration
.getPassword()));
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
httpClientBuilder.setRoutePlanner(routePlanner);
}
HttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return requestFactory;
}
示例7: createClientRequestDirector
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的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);
}
示例8: decorateRoutePlanner
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
private void decorateRoutePlanner(CrawlerHttpClient crawlerHttpClient) {
HttpRoutePlanner routePlanner = crawlerHttpClient.getRoutePlanner();
if (!(routePlanner instanceof ProxyBindRoutPlanner)) {
log.warn("自定义了代理发生器,vscrawler的代理功能将不会生效");
return;
}
VSCrawlerRoutePlanner vsCrawlerRoutePlanner = new VSCrawlerRoutePlanner((ProxyBindRoutPlanner) routePlanner,
ipPool, proxyPlanner, this);
crawlerHttpClient.setRoutePlanner(vsCrawlerRoutePlanner);
}
示例9: RedirectExec
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
public RedirectExec(
final ClientExecChain requestExecutor,
final HttpRoutePlanner routePlanner,
final RedirectStrategy redirectStrategy) {
super();
Args.notNull(requestExecutor, "HTTP client request executor");
Args.notNull(routePlanner, "HTTP route planner");
Args.notNull(redirectStrategy, "HTTP redirect strategy");
this.requestExecutor = requestExecutor;
this.routePlanner = routePlanner;
this.redirectStrategy = redirectStrategy;
}
示例10: getRoutePlanner
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
private HttpRoutePlanner getRoutePlanner() {
proxyHostname = Strings.nullToEmpty(proxyHostname);
if (proxyHostname.isEmpty()) {
proxyEnabled = false;
}
if (proxyEnabled) {
HttpHost proxy = new HttpHost(proxyHostname, proxyPort, proxyScheme);
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy) {
@Override
public HttpRoute determineRoute(
final HttpHost host,
final HttpRequest request,
final HttpContext context) throws HttpException {
String hostname = host.getHostName();
if (hostname.equals("127.0.0.1") || hostname.equalsIgnoreCase("localhost")) {
// Return direct route
return new HttpRoute(host);
}
return super.determineRoute(host, request, context);
}
};
return routePlanner;
}
return null;
}
示例11: AndroidHttpClient
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的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;
}
};
}
示例12: createRequestFactory
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
public static ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts, boolean disableRedirectHandling) {
HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
if (trustSelfSignedCerts) {
httpClientBuilder.setSslcontext(buildSslContext());
httpClientBuilder.setHostnameVerifier(BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
if (disableRedirectHandling) {
httpClientBuilder.disableRedirectHandling();
}
if (httpProxyConfiguration != null) {
HttpHost proxy = new HttpHost(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort());
httpClientBuilder.setProxy(proxy);
if (httpProxyConfiguration.isAuthRequired()) {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort()),
new UsernamePasswordCredentials(httpProxyConfiguration.getUsername(), httpProxyConfiguration.getPassword()));
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
httpClientBuilder.setRoutePlanner(routePlanner);
}
HttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return requestFactory;
}
示例13: expectedSendGridBeanWithProxyCreated
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
@Test
public void expectedSendGridBeanWithProxyCreated() {
loadContext("spring.sendgrid.username:user", "spring.sendgrid.password:secret",
"spring.sendgrid.proxy.host:localhost",
"spring.sendgrid.proxy.port:5678");
SendGrid sendGrid = this.context.getBean(SendGrid.class);
CloseableHttpClient client = (CloseableHttpClient) ReflectionTestUtils
.getField(sendGrid, "client");
HttpRoutePlanner routePlanner = (HttpRoutePlanner) ReflectionTestUtils
.getField(client, "routePlanner");
assertThat(routePlanner, instanceOf(DefaultProxyRoutePlanner.class));
}
示例14: __constructor__
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
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);
}
示例15: DefaultRequestDirector
import org.apache.http.conn.routing.HttpRoutePlanner; //导入依赖的package包/类
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);
}