本文整理汇总了Java中org.apache.http.client.methods.HttpExecutionAware类的典型用法代码示例。如果您正苦于以下问题:Java HttpExecutionAware类的具体用法?Java HttpExecutionAware怎么用?Java HttpExecutionAware使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpExecutionAware类属于org.apache.http.client.methods包,在下文中一共展示了HttpExecutionAware类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Override
public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext clientContext,
HttpExecutionAware execAware) throws IOException, HttpException {
Proxy proxy = (Proxy) clientContext.getAttribute(VSCrawlerConstant.VSCRAWLER_AVPROXY_KEY);
if (proxy != null) {
proxy.recordUsage();
}
try {
return delegate.execute(route, request, clientContext, execAware);
} catch (IOException ioe) {
if (proxy != null) {
proxy.recordFailed();
}
throw ioe;
}
}
开发者ID:virjar,项目名称:vscrawler,代码行数:17,代码来源:ProxyFeedBackClientExecChain.java
示例2: testPassesOnOrigin401ResponseWithoutWWWAuthenticateHeader
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testPassesOnOrigin401ResponseWithoutWWWAuthenticateHeader() throws Exception {
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HTTP_1_1, 401, "Unauthorized"));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestProtocolDeviations.java
示例3: revalidateCacheEntry
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private CloseableHttpResponse revalidateCacheEntry(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware,
final HttpCacheEntry entry,
final Date now) throws HttpException {
try {
if (asynchRevalidator != null
&& !staleResponseNotAllowed(request, entry, now)
&& validityPolicy.mayReturnStaleWhileRevalidating(entry, now)) {
log.trace("Serving stale with asynchronous revalidation");
final CloseableHttpResponse resp = generateCachedResponse(request, context, entry, now);
asynchRevalidator.revalidateCacheEntry(this, route, request, context, execAware, entry);
return resp;
}
return revalidateCacheEntry(route, request, context, execAware, entry);
} catch (final IOException ioex) {
return handleRevalidationFailure(request, context, entry, now);
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:CachingExec.java
示例4: handleCacheMiss
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private CloseableHttpResponse handleCacheMiss(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
final HttpHost target = context.getTargetHost();
recordCacheMiss(target, request);
if (!mayCallBackend(request)) {
return Proxies.enhanceResponse(
new BasicHttpResponse(
HttpVersion.HTTP_1_1, HttpStatus.SC_GATEWAY_TIMEOUT, "Gateway Timeout"));
}
final Map<String, Variant> variants = getExistingCacheVariants(target, request);
if (variants != null && !variants.isEmpty()) {
return negotiateResponseFromVariants(route, request, context,
execAware, variants);
}
return callBackend(route, request, context, execAware);
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:CachingExec.java
示例5: testPassesOnOrigin407WithoutAProxyAuthenticateHeader
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testPassesOnOrigin407WithoutAProxyAuthenticateHeader() throws Exception {
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HTTP_1_1, 407, "Proxy Authentication Required"));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:TestProtocolDeviations.java
示例6: revalidateCacheEntry
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
/**
* Schedules an asynchronous revalidation
*/
public synchronized void revalidateCacheEntry(
final CachingExec cachingExec,
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware,
final HttpCacheEntry entry) {
// getVariantURI will fall back on getURI if no variants exist
final String uri = cacheKeyGenerator.getVariantURI(context.getTargetHost(), request, entry);
if (!queued.contains(uri)) {
final int consecutiveFailedAttempts = failureCache.getErrorCount(uri);
final AsynchronousValidationRequest revalidationRequest =
new AsynchronousValidationRequest(
this, cachingExec, route, request, context, execAware, entry, uri, consecutiveFailedAttempts);
try {
schedulingStrategy.schedule(revalidationRequest);
queued.add(uri);
} catch (final RejectedExecutionException ree) {
log.debug("Revalidation for [" + uri + "] not scheduled: " + ree);
}
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:28,代码来源:AsynchronousValidator.java
示例7: testDoesNotModifyHeaderOnRequests
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private void testDoesNotModifyHeaderOnRequests(final String headerName)
throws Exception {
final String headerValue = HttpTestUtils.getCanonicalHeaderValue(request, headerName);
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, request, context, null);
verifyMocks();
assertEquals(headerValue,
HttpTestUtils.getCanonicalHeaderValue(cap.getValue(),
headerName));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestProtocolRecommendations.java
示例8: testPostProcessHttpException
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test(expected = HttpException.class)
public void testPostProcessHttpException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
Mockito.when(requestExecutor.execute(
Mockito.eq(route),
Mockito.<HttpRequestWrapper>any(),
Mockito.<HttpClientContext>any(),
Mockito.<HttpExecutionAware>any())).thenReturn(response);
Mockito.doThrow(new HttpException("Ooopsie")).when(httpProcessor).process(
Mockito.same(response), Mockito.<HttpContext>any());
try {
protocolExec.execute(route, request, context, execAware);
} catch (final Exception ex) {
Mockito.verify(response).close();
throw ex;
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestProtocolExec.java
示例9: testStrategyRuntimeException
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testStrategyRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
Mockito.when(requestExecutor.execute(
Mockito.eq(route),
Mockito.<HttpRequestWrapper>any(),
Mockito.<HttpClientContext>any(),
Mockito.<HttpExecutionAware>any())).thenReturn(response);
Mockito.doThrow(new RuntimeException("Ooopsie")).when(retryStrategy).retryRequest(
Mockito.<HttpResponse>any(),
Mockito.anyInt(),
Mockito.<HttpContext>any());
try {
retryExec.execute(route, request, context, execAware);
} catch (final Exception ex) {
Mockito.verify(response).close();
throw ex;
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestServiceUnavailableRetryExec.java
示例10: testPassesOnOrigin405WithoutAllowHeader
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testPassesOnOrigin405WithoutAllowHeader() throws Exception {
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HTTP_1_1, 405, "Method Not Allowed"));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:TestProtocolDeviations.java
示例11: testHigherMajorProtocolVersionsOnRequestSwitchToTunnelBehavior
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testHigherMajorProtocolVersionsOnRequestSwitchToTunnelBehavior() throws Exception {
// tunnel behavior: I don't muck with request or response in
// any way
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 2, 13)));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
eqRequest(request),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:22,代码来源:TestProtocolRequirements.java
示例12: testHigher1_XProtocolVersionsDowngradeTo1_1
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testHigher1_XProtocolVersionsDowngradeTo1_1() throws Exception {
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)));
final HttpRequestWrapper downgraded = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
eqRequest(downgraded),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertTrue(HttpTestUtils.semanticallyTransparent(originResponse, result));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestProtocolRequirements.java
示例13: testRequestsWithLowerProtocolVersionsGetUpgradedTo1_1
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testRequestsWithLowerProtocolVersionsGetUpgradedTo1_1() throws Exception {
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
final HttpRequestWrapper upgraded = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
eqRequest(upgraded),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertTrue(HttpTestUtils.semanticallyTransparent(originResponse, result));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:22,代码来源:TestProtocolRequirements.java
示例14: testLowerOriginResponsesUpgradedToOurVersion1_1
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testLowerOriginResponsesUpgradedToOurVersion1_1() throws Exception {
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 2), HttpStatus.SC_OK, "OK"));
originResponse.setHeader("Date", DateUtils.formatDate(new Date()));
originResponse.setHeader("Server", "MockOrigin/1.0");
originResponse.setEntity(body);
// not testing this internal behavior in this test, just want
// to check the protocol version that comes out the other end
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertEquals(HttpVersion.HTTP_1_1, result.getProtocolVersion());
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestProtocolRequirements.java
示例15: testResponseToA1_0RequestShouldUse1_1
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testResponseToA1_0RequestShouldUse1_1() throws Exception {
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertEquals(HttpVersion.HTTP_1_1, result.getProtocolVersion());
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:TestProtocolRequirements.java
示例16: testForwardsUnknownHeadersOnRequestsFromHigherProtocolVersions
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testForwardsUnknownHeadersOnRequestsFromHigherProtocolVersions() throws Exception {
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)));
request.removeHeaders("Connection");
request.addHeader("X-Unknown-Header", "some-value");
final HttpRequestWrapper downgraded = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
downgraded.removeHeaders("Connection");
downgraded.addHeader("X-Unknown-Header", "some-value");
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
eqRequest(downgraded),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, request, context, null);
verifyMocks();
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:TestProtocolRequirements.java
示例17: testTransferCodingsAreNotSentToAnHTTP_1_0Client
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
@Test
public void testTransferCodingsAreNotSentToAnHTTP_1_0Client() throws Exception {
originResponse.setHeader("Transfer-Encoding", "identity");
request = HttpRequestWrapper.wrap(
new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertNull(result.getFirstHeader("TE"));
Assert.assertNull(result.getFirstHeader("Transfer-Encoding"));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestProtocolRequirements.java
示例18: testOrderOfMultipleHeadersIsPreservedOnRequests
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private void testOrderOfMultipleHeadersIsPreservedOnRequests(final String h, final HttpRequestWrapper request)
throws Exception {
final Capture<HttpRequestWrapper> reqCapture = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.capture(reqCapture),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, request, context, null);
verifyMocks();
final HttpRequest forwarded = reqCapture.getValue();
Assert.assertNotNull(forwarded);
final String expected = HttpTestUtils.getCanonicalHeaderValue(request, h);
final String actual = HttpTestUtils.getCanonicalHeaderValue(forwarded, h);
if (!actual.contains(expected)) {
Assert.assertEquals(expected, actual);
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:TestProtocolRequirements.java
示例19: testOrderOfMultipleHeadersIsPreservedOnResponses
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private void testOrderOfMultipleHeadersIsPreservedOnResponses(final String h) throws Exception {
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
Assert.assertNotNull(result);
Assert.assertEquals(HttpTestUtils.getCanonicalHeaderValue(originResponse, h), HttpTestUtils
.getCanonicalHeaderValue(result, h));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:TestProtocolRequirements.java
示例20: testUnknownResponseStatusCodeIsNotCached
import org.apache.http.client.methods.HttpExecutionAware; //导入依赖的package包/类
private void testUnknownResponseStatusCodeIsNotCached(final int code) throws Exception {
emptyMockCacheExpectsNoPuts();
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HttpVersion.HTTP_1_1, code, "Moo"));
originResponse.setHeader("Date", DateUtils.formatDate(new Date()));
originResponse.setHeader("Server", "MockOrigin/1.0");
originResponse.setHeader("Cache-Control", "max-age=3600");
originResponse.setEntity(body);
EasyMock.expect(
mockBackend.execute(
EasyMock.isA(HttpRoute.class),
EasyMock.isA(HttpRequestWrapper.class),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, request, context, null);
// in particular, there were no storage calls on the cache
verifyMocks();
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:TestProtocolRequirements.java
注:本文中的org.apache.http.client.methods.HttpExecutionAware类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论