本文整理汇总了Java中org.apache.http.impl.execchain.ClientExecChain类的典型用法代码示例。如果您正苦于以下问题:Java ClientExecChain类的具体用法?Java ClientExecChain怎么用?Java ClientExecChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientExecChain类属于org.apache.http.impl.execchain包,在下文中一共展示了ClientExecChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InternalHttpClient
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的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;
}
示例2: decorateProtocolExec_uses_subspan_option_value_at_time_of_creation_not_time_of_execution
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@DataProvider(value = {
"true",
"false"
}, splitBy = "\\|")
@Test
public void decorateProtocolExec_uses_subspan_option_value_at_time_of_creation_not_time_of_execution(
boolean subspanOptionOn
) throws IOException, HttpException {
// given
builder = WingtipsHttpClientBuilder.create(subspanOptionOn);
Span parentSpan = Tracer.getInstance().startRequestWithRootSpan("someParentSpan");
SpanCapturingClientExecChain origCec = spy(new SpanCapturingClientExecChain());
// when
ClientExecChain result = builder.decorateProtocolExec(origCec);
// Set builder's subspan option to the opposite of what it was when the ClientExecChain was decorated.
builder.setSurroundCallsWithSubspan(!subspanOptionOn);
// then
// Even though the *builder's* subspan option has been flipped, the ClientExecChain should still execute with
// the subspan option value from when the ClientExecChain was originally decorated.
verifyDecoratedClientExecChainPerformsTracingLogic(
result, origCec, parentSpan, subspanOptionOn
);
}
示例3: CachingExec
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
public CachingExec(
final ClientExecChain backend,
final HttpCache cache,
final CacheConfig config,
final AsynchronousValidator asynchRevalidator) {
super();
Args.notNull(backend, "HTTP backend");
Args.notNull(cache, "HttpCache");
this.cacheConfig = config != null ? config : CacheConfig.DEFAULT;
this.backend = backend;
this.responseCache = cache;
this.validityPolicy = new CacheValidityPolicy();
this.responseGenerator = new CachedHttpResponseGenerator(this.validityPolicy);
this.cacheableRequestPolicy = new CacheableRequestPolicy();
this.suitabilityChecker = new CachedResponseSuitabilityChecker(this.validityPolicy, this.cacheConfig);
this.conditionalRequestBuilder = new ConditionalRequestBuilder();
this.responseCompliance = new ResponseProtocolCompliance();
this.requestCompliance = new RequestProtocolCompliance(this.cacheConfig.isWeakETagOnPutDeleteAllowed());
this.responseCachingPolicy = new ResponseCachingPolicy(
this.cacheConfig.getMaxObjectSize(), this.cacheConfig.isSharedCache(),
this.cacheConfig.isNeverCacheHTTP10ResponsesWithQuery(), this.cacheConfig.is303CachingEnabled());
this.asynchRevalidator = asynchRevalidator;
}
示例4: createCachingExecChain
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@Override
public CachingExec createCachingExecChain(final ClientExecChain mockBackend,
final HttpCache mockCache, final CacheValidityPolicy mockValidityPolicy,
final ResponseCachingPolicy mockResponsePolicy,
final CachedHttpResponseGenerator mockResponseGenerator,
final CacheableRequestPolicy mockRequestPolicy,
final CachedResponseSuitabilityChecker mockSuitabilityChecker,
final ConditionalRequestBuilder mockConditionalRequestBuilder,
final ResponseProtocolCompliance mockResponseProtocolCompliance,
final RequestProtocolCompliance mockRequestProtocolCompliance,
final CacheConfig config, final AsynchronousValidator asyncValidator) {
return impl = new CachingExec(
mockBackend,
mockCache,
mockValidityPolicy,
mockResponsePolicy,
mockResponseGenerator,
mockRequestPolicy,
mockSuitabilityChecker,
mockConditionalRequestBuilder,
mockResponseProtocolCompliance,
mockRequestProtocolCompliance,
config,
asyncValidator);
}
示例5: setUp
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@Before
public void setUp() {
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
body = HttpTestUtils.makeBody(entityLength);
request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
context = HttpCacheContext.create();
context.setTargetHost(host);
originResponse = Proxies.enhanceResponse(HttpTestUtils.make200Response());
config = CacheConfig.custom()
.setMaxCacheEntries(MAX_ENTRIES)
.setMaxObjectSize(MAX_BYTES)
.build();
cache = new BasicHttpCache(config);
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
mockCache = EasyMock.createNiceMock(HttpCache.class);
impl = createCachingExecChain(mockBackend, cache, config);
}
示例6: emptyMockCacheExpectsNoPuts
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
protected void emptyMockCacheExpectsNoPuts() throws Exception {
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
mockCache = EasyMock.createNiceMock(HttpCache.class);
impl = new CachingExec(mockBackend, mockCache, config);
EasyMock.expect(mockCache.getCacheEntry(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class)))
.andReturn(null).anyTimes();
EasyMock.expect(mockCache.getVariantCacheEntriesWithEtags(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class)))
.andReturn(new HashMap<String,Variant>()).anyTimes();
mockCache.flushCacheEntriesFor(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class));
EasyMock.expectLastCall().anyTimes();
mockCache.flushCacheEntriesFor(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class));
EasyMock.expectLastCall().anyTimes();
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class));
EasyMock.expectLastCall().anyTimes();
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class), EasyMock.isA(HttpResponse.class));
EasyMock.expectLastCall().anyTimes();
}
示例7: createMainExec
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
/**
* Produces an instance of {@link ClientExecChain} to be used as a main exec.
* <p>
* Default implementation produces an instance of {@link MainClientExec}
* </p>
* <p>
* For internal use.
* </p>
*
* @since 4.4
*/
protected ClientExecChain createMainExec(
final HttpRequestExecutor requestExec,
final HttpClientConnectionManager connManager,
final ConnectionReuseStrategy reuseStrategy,
final ConnectionKeepAliveStrategy keepAliveStrategy,
final HttpProcessor proxyHttpProcessor,
final AuthenticationStrategy targetAuthStrategy,
final AuthenticationStrategy proxyAuthStrategy,
final UserTokenHandler userTokenHandler)
{
return new MainClientExec(
requestExec,
connManager,
reuseStrategy,
keepAliveStrategy,
proxyHttpProcessor,
targetAuthStrategy,
proxyAuthStrategy,
userTokenHandler);
}
示例8: setup
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的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));
}
示例9: TracingClientExec
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
public TracingClientExec(
ClientExecChain clientExecChain,
RedirectStrategy redirectStrategy,
boolean redirectHandlingDisabled,
Tracer tracer,
List<ApacheClientSpanDecorator> spanDecorators) {
this.requestExecutor = clientExecChain;
this.redirectStrategy = redirectStrategy;
this.redirectHandlingDisabled = redirectHandlingDisabled;
this.tracer = tracer;
this.spanDecorators = new ArrayList<>(spanDecorators);
}
示例10: decorateProtocolExec
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@Override
protected ClientExecChain decorateProtocolExec(final ClientExecChain protocolExec) {
final boolean myHttpClientSurroundCallsWithSubspan = surroundCallsWithSubspan;
return new ClientExecChain() {
@Override
@SuppressWarnings("TryFinallyCanBeTryWithResources")
public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request,
HttpClientContext clientContext,
HttpExecutionAware execAware) throws IOException, HttpException {
Tracer tracer = Tracer.getInstance();
Span spanAroundCall = null;
if (myHttpClientSurroundCallsWithSubspan) {
// Will start a new trace if necessary, or a subspan if a trace is already in progress.
spanAroundCall = tracer.startSpanInCurrentContext(getSubspanSpanName(request), SpanPurpose.CLIENT);
}
try {
propagateTracingHeaders(request, tracer.getCurrentSpan());
return protocolExec.execute(route, request, clientContext, execAware);
}
finally {
if (spanAroundCall != null) {
// Span.close() contains the logic we want - if the spanAroundCall was an overall span (new
// trace) then tracer.completeRequestSpan() will be called, otherwise it's a subspan and
// tracer.completeSubSpan() will be called.
spanAroundCall.close();
}
}
}
};
}
示例11: decorateProtocolExec_works_as_expected
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@DataProvider(value = {
"true | true | true",
"false | true | true",
"true | false | true",
"false | false | true",
"true | true | false",
"false | true | false",
"true | false | false",
"false | false | false"
}, splitBy = "\\|")
@Test
public void decorateProtocolExec_works_as_expected(
boolean subspanOptionOn, boolean parentSpanExists, boolean throwExceptionInInnerChain
) throws IOException, HttpException {
// given
builder = WingtipsHttpClientBuilder.create(subspanOptionOn);
RuntimeException exceptionToThrowInInnerChain = (throwExceptionInInnerChain)
? new RuntimeException("kaboom")
: null;
SpanCapturingClientExecChain origCec = spy(new SpanCapturingClientExecChain(exceptionToThrowInInnerChain));
Span parentSpan = null;
if (parentSpanExists) {
parentSpan = Tracer.getInstance().startRequestWithRootSpan("someParentSpan");
}
// when
ClientExecChain result = builder.decorateProtocolExec(origCec);
// then
verifyDecoratedClientExecChainPerformsTracingLogic(
result, origCec, parentSpan, subspanOptionOn
);
}
示例12: setUp
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setUp() {
mockRequestPolicy = createNiceMock(CacheableRequestPolicy.class);
mockValidityPolicy = createNiceMock(CacheValidityPolicy.class);
mockBackend = createNiceMock(ClientExecChain.class);
mockCache = createNiceMock(HttpCache.class);
mockSuitabilityChecker = createNiceMock(CachedResponseSuitabilityChecker.class);
mockResponsePolicy = createNiceMock(ResponseCachingPolicy.class);
mockHandler = createNiceMock(ResponseHandler.class);
mockUriRequest = createNiceMock(HttpUriRequest.class);
mockCacheEntry = createNiceMock(HttpCacheEntry.class);
mockResponseGenerator = createNiceMock(CachedHttpResponseGenerator.class);
mockCachedResponse = createNiceMock(CloseableHttpResponse.class);
mockConditionalRequestBuilder = createNiceMock(ConditionalRequestBuilder.class);
mockConditionalRequest = createNiceMock(HttpRequest.class);
mockStatusLine = createNiceMock(StatusLine.class);
mockResponseProtocolCompliance = createNiceMock(ResponseProtocolCompliance.class);
mockRequestProtocolCompliance = createNiceMock(RequestProtocolCompliance.class);
mockStorage = createNiceMock(HttpCacheStorage.class);
config = CacheConfig.DEFAULT;
asyncValidator = new AsynchronousValidator(config);
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/stuff",
HttpVersion.HTTP_1_1));
context = HttpCacheContext.create();
context.setTargetHost(host);
entry = HttpTestUtils.makeCacheEntry();
impl = createCachingExecChain(mockBackend, mockCache, mockValidityPolicy,
mockResponsePolicy, mockResponseGenerator, mockRequestPolicy, mockSuitabilityChecker,
mockConditionalRequestBuilder, mockResponseProtocolCompliance,
mockRequestProtocolCompliance, config, asyncValidator);
}
示例13: createCachingExecChain
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
public abstract ClientExecChain createCachingExecChain(ClientExecChain backend,
HttpCache responseCache, CacheValidityPolicy validityPolicy,
ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator,
CacheableRequestPolicy cacheableRequestPolicy,
CachedResponseSuitabilityChecker suitabilityChecker,
ConditionalRequestBuilder conditionalRequestBuilder,
ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance,
CacheConfig config, AsynchronousValidator asynchRevalidator);
示例14: setUp
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
@Override
@Before
public void setUp() {
super.setUp();
config = CacheConfig.custom().setMaxObjectSize(MAX_BYTES).build();
if (CACHE_MANAGER.cacheExists(TEST_EHCACHE_NAME)){
CACHE_MANAGER.removeCache(TEST_EHCACHE_NAME);
}
CACHE_MANAGER.addCache(TEST_EHCACHE_NAME);
final HttpCacheStorage storage = new EhcacheHttpCacheStorage(CACHE_MANAGER.getCache(TEST_EHCACHE_NAME));
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
impl = new CachingExec(mockBackend, new HeapResourceFactory(), storage, config);
}
示例15: createAsynchronousValidationRequest
import org.apache.http.impl.execchain.ClientExecChain; //导入依赖的package包/类
private AsynchronousValidationRequest createAsynchronousValidationRequest(final int errorCount) {
final ClientExecChain clientExecChain = mock(ClientExecChain.class);
final CachingExec cachingHttpClient = new CachingExec(clientExecChain);
final AsynchronousValidator mockValidator = new AsynchronousValidator(impl);
final HttpRoute httpRoute = new HttpRoute(new HttpHost("foo.example.com", 80));
final HttpRequestWrapper httpRequestWrapper = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/"));
final HttpClientContext httpClientContext = new HttpClientContext();
return new AsynchronousValidationRequest(mockValidator, cachingHttpClient, httpRoute, httpRequestWrapper,
httpClientContext, null, null, "identifier", errorCount);
}