mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-10 12:05:58 +00:00
Added MessageCopier and implementations for HttpRequest and ClassicHttpRequest messages; removed message copy methods from ExecSupport
This commit is contained in:
parent
e8972624ac
commit
9ac5808bdb
@ -31,7 +31,7 @@
|
||||
|
||||
import org.apache.hc.client5.http.cache.HeaderConstants;
|
||||
import org.apache.hc.client5.http.cache.HttpCacheEntry;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.core5.annotation.Contract;
|
||||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
@ -59,7 +59,7 @@ class ConditionalRequestBuilder {
|
||||
*/
|
||||
public ClassicHttpRequest buildConditionalRequest(final ClassicHttpRequest request, final HttpCacheEntry cacheEntry)
|
||||
throws ProtocolException {
|
||||
final ClassicHttpRequest newRequest = ExecSupport.copy(request);
|
||||
final ClassicHttpRequest newRequest = ClassicRequestCopier.INSTANCE.copy(request);
|
||||
newRequest.setHeaders(request.getAllHeaders());
|
||||
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
|
||||
if (eTag != null) {
|
||||
@ -99,7 +99,7 @@ public ClassicHttpRequest buildConditionalRequest(final ClassicHttpRequest reque
|
||||
*/
|
||||
public ClassicHttpRequest buildConditionalRequestFromVariants(final ClassicHttpRequest request,
|
||||
final Map<String, Variant> variants) {
|
||||
final ClassicHttpRequest newRequest = ExecSupport.copy(request);
|
||||
final ClassicHttpRequest newRequest = ClassicRequestCopier.INSTANCE.copy(request);
|
||||
newRequest.setHeaders(request.getAllHeaders());
|
||||
|
||||
// we do not support partial content so all etags are used
|
||||
@ -128,7 +128,7 @@ public ClassicHttpRequest buildConditionalRequestFromVariants(final ClassicHttpR
|
||||
* @return an unconditional validation request
|
||||
*/
|
||||
public ClassicHttpRequest buildUnconditionalRequest(final ClassicHttpRequest request) {
|
||||
final ClassicHttpRequest newRequest = ExecSupport.copy(request);
|
||||
final ClassicHttpRequest newRequest = ClassicRequestCopier.INSTANCE.copy(request);
|
||||
newRequest.addHeader(HeaderConstants.CACHE_CONTROL,HeaderConstants.CACHE_CONTROL_NO_CACHE);
|
||||
newRequest.addHeader(HeaderConstants.PRAGMA,HeaderConstants.CACHE_CONTROL_NO_CACHE);
|
||||
newRequest.removeHeaders(HeaderConstants.IF_RANGE);
|
||||
|
@ -257,6 +257,9 @@ private void add100ContinueHeaderIfMissing(final HttpRequest request) {
|
||||
|
||||
protected boolean requestMinorVersionIsTooHighMajorVersionsMatch(final HttpRequest request) {
|
||||
final ProtocolVersion requestProtocol = request.getVersion();
|
||||
if (requestProtocol == null) {
|
||||
return false;
|
||||
}
|
||||
if (requestProtocol.getMajor() != HttpVersion.HTTP_1_1.getMajor()) {
|
||||
return false;
|
||||
}
|
||||
@ -269,7 +272,8 @@ protected boolean requestMinorVersionIsTooHighMajorVersionsMatch(final HttpReque
|
||||
}
|
||||
|
||||
protected boolean requestVersionIsTooLow(final HttpRequest request) {
|
||||
return request.getVersion().compareToVersion(HttpVersion.HTTP_1_1) < 0;
|
||||
final ProtocolVersion requestProtocol = request.getVersion();
|
||||
return requestProtocol != null && requestProtocol.compareToVersion(HttpVersion.HTTP_1_1) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@
|
||||
import org.apache.hc.client5.http.classic.ExecChain;
|
||||
import org.apache.hc.client5.http.classic.ExecChainHandler;
|
||||
import org.apache.hc.client5.http.classic.ExecRuntime;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
@ -107,7 +107,8 @@ public void setUp() {
|
||||
}
|
||||
|
||||
public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOException, HttpException {
|
||||
return impl.execute(ExecSupport.copy(request), new ExecChain.Scope(route, request, mockEndpoint, context), mockExecChain);
|
||||
return impl.execute(ClassicRequestCopier.INSTANCE.copy(request), new ExecChain.Scope(
|
||||
"test", route, request, mockEndpoint, context), mockExecChain);
|
||||
}
|
||||
|
||||
protected ExecChainHandler createCachingExecChain(final HttpCache cache, final CacheConfig config) {
|
||||
|
@ -75,7 +75,7 @@ public void setUp() {
|
||||
execChain = mock(ExecChain.class);
|
||||
mockCacheEntry = mock(HttpCacheEntry.class);
|
||||
mockResponse = mock(ClassicHttpResponse.class);
|
||||
scope = new ExecChain.Scope(route, request, mockEndpoint, context);
|
||||
scope = new ExecChain.Scope("test", route, request, mockEndpoint, context);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -82,7 +82,7 @@ public void setUp() {
|
||||
mockEndpoint = mock(ExecRuntime.class);
|
||||
mockCacheEntry = mock(HttpCacheEntry.class);
|
||||
mockSchedulingStrategy = mock(SchedulingStrategy.class);
|
||||
scope = new ExecChain.Scope(route, request, mockEndpoint, context);
|
||||
scope = new ExecChain.Scope("test", route, request, mockEndpoint, context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -167,9 +167,9 @@ public void testVariantsBothRevalidated() {
|
||||
new BasicHeaderIterator(variantHeaders, HeaderConstants.VARY));
|
||||
mockSchedulingStrategy.schedule(isA(AsynchronousValidationRequest.class));
|
||||
|
||||
impl.revalidateCacheEntry(mockClient, host, req1, new ExecChain.Scope(route, req1, mockEndpoint, context),
|
||||
impl.revalidateCacheEntry(mockClient, host, req1, new ExecChain.Scope("test", route, req1, mockEndpoint, context),
|
||||
mockExecChain, mockCacheEntry);
|
||||
impl.revalidateCacheEntry(mockClient, host, req2, new ExecChain.Scope(route, req2, mockEndpoint, context),
|
||||
impl.revalidateCacheEntry(mockClient, host, req2, new ExecChain.Scope("test", route, req2, mockEndpoint, context),
|
||||
mockExecChain, mockCacheEntry);
|
||||
|
||||
verify(mockCacheEntry, times(2)).hasVariants();
|
||||
|
@ -91,7 +91,7 @@ public class TestCachingExec extends TestCachingExecChain {
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
|
||||
scope = new ExecChain.Scope(route, request, mockEndpoint, context);
|
||||
scope = new ExecChain.Scope("test", route, request, mockEndpoint, context);
|
||||
mockBackendResponse = createNiceMock(ClassicHttpResponse.class);
|
||||
|
||||
requestDate = new Date(System.currentTimeMillis() - 1000);
|
||||
|
@ -58,7 +58,7 @@
|
||||
import org.apache.hc.client5.http.classic.ExecRuntime;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpOptions;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.client5.http.utils.DateUtils;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
@ -162,7 +162,8 @@ public abstract ExecChainHandler createCachingExecChain(HttpCache responseCache,
|
||||
public abstract ExecChainHandler createCachingExecChain(HttpCache cache, CacheConfig config);
|
||||
|
||||
protected ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOException, HttpException {
|
||||
return impl.execute(ExecSupport.copy(request), new ExecChain.Scope(route, request, mockEndpoint, context), mockExecChain);
|
||||
return impl.execute(ClassicRequestCopier.INSTANCE.copy(request), new ExecChain.Scope(
|
||||
"test", route, request, mockEndpoint, context), mockExecChain);
|
||||
}
|
||||
|
||||
public static ClassicHttpRequest eqRequest(final ClassicHttpRequest in) {
|
||||
@ -1349,8 +1350,8 @@ public void testDoesNotSetConnectionInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), backend);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1361,8 +1362,8 @@ public void testSetsTargetHostInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), backend);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1373,8 +1374,8 @@ public void testSetsRouteInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), backend);
|
||||
assertEquals(route, ctx.getHttpRoute());
|
||||
}
|
||||
|
||||
@ -1386,8 +1387,8 @@ public void testSetsRequestInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), backend);
|
||||
if (!HttpTestUtils.equivalent(request, ctx.getRequest())) {
|
||||
assertSame(request, ctx.getRequest());
|
||||
}
|
||||
@ -1401,8 +1402,8 @@ public void testSetsResponseInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
final ClassicHttpResponse result = impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), null);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
final ClassicHttpResponse result = impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), null);
|
||||
if (!HttpTestUtils.equivalent(result, ctx.getResponse())) {
|
||||
assertSame(result, ctx.getResponse());
|
||||
}
|
||||
@ -1416,8 +1417,8 @@ public void testSetsRequestSentInContextOnCacheHit() throws Exception {
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
final HttpClientContext ctx = HttpClientContext.create();
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, ctx), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, ctx), backend);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1428,8 +1429,8 @@ public void testCanCacheAResponseWithoutABody() throws Exception {
|
||||
final DummyBackend backend = new DummyBackend();
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
assertEquals(1, backend.getExecutions());
|
||||
}
|
||||
|
||||
@ -1581,12 +1582,12 @@ public void testUsesVirtualHostForCacheKey() throws Exception {
|
||||
response.setHeader("Cache-Control", "max-age=3600");
|
||||
backend.setResponse(response);
|
||||
impl = createCachingExecChain(new BasicHttpCache(), CacheConfig.DEFAULT);
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
assertEquals(1, backend.getExecutions());
|
||||
request.setAuthority(new URIAuthority("bar.example.com"));
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
assertEquals(2, backend.getExecutions());
|
||||
impl.execute(request, new ExecChain.Scope(route, request, mockEndpoint, context), backend);
|
||||
impl.execute(request, new ExecChain.Scope("test", route, request, mockEndpoint, context), backend);
|
||||
assertEquals(2, backend.getExecutions());
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,12 @@
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.cache.HeaderConstants;
|
||||
import org.apache.hc.client5.http.cache.HttpCacheEntry;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.client5.http.utils.DateUtils;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HeaderElement;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.ProtocolException;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.message.BasicHeader;
|
||||
@ -72,7 +71,7 @@ public void testBuildConditionalRequestWithLastModified() throws ProtocolExcepti
|
||||
|
||||
final ClassicHttpRequest basicRequest = new BasicClassicHttpRequest(theMethod, theUri);
|
||||
basicRequest.addHeader("Accept-Encoding", "gzip");
|
||||
final ClassicHttpRequest requestWrapper = ExecSupport.copy(basicRequest);
|
||||
final ClassicHttpRequest requestWrapper = ClassicRequestCopier.INSTANCE.copy(basicRequest);
|
||||
|
||||
final Header[] headers = new Header[] {
|
||||
new BasicHeader("Date", DateUtils.formatDate(new Date())),
|
||||
@ -108,7 +107,7 @@ public void testConditionalRequestForEntryWithLastModifiedAndEtagIncludesBothAsV
|
||||
new BasicHeader("ETag", etag)
|
||||
};
|
||||
final ClassicHttpRequest basicRequest = new BasicClassicHttpRequest("GET", "/");
|
||||
final ClassicHttpRequest requestWrapper = ExecSupport.copy(basicRequest);
|
||||
final ClassicHttpRequest requestWrapper = ClassicRequestCopier.INSTANCE.copy(basicRequest);
|
||||
final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
|
||||
final ClassicHttpRequest result = impl.buildConditionalRequest(requestWrapper, cacheEntry);
|
||||
Assert.assertEquals(lmDate,
|
||||
@ -125,7 +124,7 @@ public void testBuildConditionalRequestWithETag() throws ProtocolException {
|
||||
|
||||
final ClassicHttpRequest basicRequest = new BasicClassicHttpRequest(theMethod, theUri);
|
||||
basicRequest.addHeader("Accept-Encoding", "gzip");
|
||||
final ClassicHttpRequest requestWrapper = ExecSupport.copy(basicRequest);
|
||||
final ClassicHttpRequest requestWrapper = ClassicRequestCopier.INSTANCE.copy(basicRequest);
|
||||
|
||||
final Header[] headers = new Header[] {
|
||||
new BasicHeader("Date", DateUtils.formatDate(new Date())),
|
||||
@ -153,7 +152,7 @@ public void testBuildConditionalRequestWithETag() throws ProtocolException {
|
||||
@Test
|
||||
public void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() throws Exception {
|
||||
final ClassicHttpRequest basicRequest = new BasicClassicHttpRequest("GET","/");
|
||||
final ClassicHttpRequest requestWrapper = ExecSupport.copy(basicRequest);
|
||||
final ClassicHttpRequest requestWrapper = ClassicRequestCopier.INSTANCE.copy(basicRequest);
|
||||
final Date now = new Date();
|
||||
final Date elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
|
||||
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
@ -182,7 +181,7 @@ public void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() throws Ex
|
||||
@Test
|
||||
public void testCacheEntryWithProxyRevalidateDoesEndToEndRevalidation() throws Exception {
|
||||
final ClassicHttpRequest basicRequest = new BasicClassicHttpRequest("GET", "/");
|
||||
final ClassicHttpRequest requestWrapper = ExecSupport.copy(basicRequest);
|
||||
final ClassicHttpRequest requestWrapper = ClassicRequestCopier.INSTANCE.copy(basicRequest);
|
||||
final Date now = new Date();
|
||||
final Date elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
|
||||
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
@ -223,13 +222,6 @@ public void testBuildUnconditionalRequestUsesRequestUri()
|
||||
Assert.assertEquals(uri, result.getRequestUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildUnconditionalRequestUsesHTTP_1_1()
|
||||
throws Exception {
|
||||
final ClassicHttpRequest result = impl.buildUnconditionalRequest(request);
|
||||
Assert.assertEquals(HttpVersion.HTTP_1_1, result.getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildUnconditionalRequestAddsCacheControlNoCache()
|
||||
throws Exception {
|
||||
|
@ -164,7 +164,7 @@ private AsynchronousValidationRequest createAsynchronousValidationRequest(final
|
||||
final HttpRoute route = new HttpRoute(host);
|
||||
final ClassicHttpRequest request = new BasicClassicHttpRequest("GET", "/");
|
||||
final HttpClientContext context = new HttpClientContext();
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, mock(ExecRuntime.class), context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, mock(ExecRuntime.class), context);
|
||||
return new AsynchronousValidationRequest(mockValidator, cachingHttpClient, host, request,
|
||||
scope, mock(ExecChain.class), null, "identifier", errorCount);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public void testIssue1147() throws Exception {
|
||||
final BasicHttpCache cache = new BasicHttpCache(resourceFactory, httpCacheStorage, cacheConfig);
|
||||
final ExecChainHandler t = createCachingExecChain(cache, cacheConfig);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, get, mockEndpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("teset", route, get, mockEndpoint, context);
|
||||
final ClassicHttpResponse response1 = t.execute(get, scope, mockExecChain);
|
||||
Assert.assertEquals(200, response1.getCode());
|
||||
IOUtils.consume(response1.getEntity());
|
||||
|
@ -36,7 +36,7 @@
|
||||
import org.apache.hc.client5.http.classic.ExecChain;
|
||||
import org.apache.hc.client5.http.classic.ExecChainHandler;
|
||||
import org.apache.hc.client5.http.classic.ExecRuntime;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.client5.http.utils.DateUtils;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
@ -122,7 +122,8 @@ public void setUp() {
|
||||
}
|
||||
|
||||
private ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOException, HttpException {
|
||||
return impl.execute(ExecSupport.copy(request), new ExecChain.Scope(route, request, mockEndpoint, context), mockExecChain);
|
||||
return impl.execute(ClassicRequestCopier.INSTANCE.copy(request), new ExecChain.Scope(
|
||||
"test", route, request, mockEndpoint, context), mockExecChain);
|
||||
}
|
||||
|
||||
protected ExecChainHandler createCachingExecChain(final HttpCache cache, final CacheConfig config) {
|
||||
|
@ -33,7 +33,7 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.hc.client5.http.classic.methods.HttpPut;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.ProtocolVersion;
|
||||
@ -82,7 +82,7 @@ public void testRequestContainsNoCacheDirectiveWithFieldName() throws Exception
|
||||
|
||||
@Test
|
||||
public void doesNotModifyACompliantRequest() throws Exception {
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertTrue(HttpTestUtils.equivalent(req, wrapper));
|
||||
}
|
||||
@ -92,7 +92,7 @@ public void removesEntityFromTRACERequest() throws Exception {
|
||||
final ClassicHttpRequest request = new BasicClassicHttpRequest("TRACE", "/");
|
||||
request.setVersion(HttpVersion.HTTP_1_1);
|
||||
request.setEntity(HttpTestUtils.makeBody(50));
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(request);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(request);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertNull(wrapper.getEntity());
|
||||
}
|
||||
@ -101,7 +101,7 @@ public void removesEntityFromTRACERequest() throws Exception {
|
||||
public void upgrades1_0RequestTo1_1() throws Exception {
|
||||
req = new BasicClassicHttpRequest("GET", "/");
|
||||
req.setVersion(HttpVersion.HTTP_1_0);
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion());
|
||||
}
|
||||
@ -110,7 +110,7 @@ public void upgrades1_0RequestTo1_1() throws Exception {
|
||||
public void downgrades1_2RequestTo1_1() throws Exception {
|
||||
req = new BasicClassicHttpRequest("GET", "/");
|
||||
req.setVersion(new ProtocolVersion("HTTP", 1, 2));
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion());
|
||||
}
|
||||
@ -119,7 +119,7 @@ public void downgrades1_2RequestTo1_1() throws Exception {
|
||||
public void stripsMinFreshFromRequestIfNoCachePresent()
|
||||
throws Exception {
|
||||
req.setHeader("Cache-Control", "no-cache, min-fresh=10");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals("no-cache",
|
||||
wrapper.getFirstHeader("Cache-Control").getValue());
|
||||
@ -129,7 +129,7 @@ public void stripsMinFreshFromRequestIfNoCachePresent()
|
||||
public void stripsMaxFreshFromRequestIfNoCachePresent()
|
||||
throws Exception {
|
||||
req.setHeader("Cache-Control", "no-cache, max-stale=10");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals("no-cache",
|
||||
wrapper.getFirstHeader("Cache-Control").getValue());
|
||||
@ -139,7 +139,7 @@ public void stripsMaxFreshFromRequestIfNoCachePresent()
|
||||
public void stripsMaxAgeFromRequestIfNoCachePresent()
|
||||
throws Exception {
|
||||
req.setHeader("Cache-Control", "no-cache, max-age=10");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals("no-cache",
|
||||
wrapper.getFirstHeader("Cache-Control").getValue());
|
||||
@ -149,7 +149,7 @@ public void stripsMaxAgeFromRequestIfNoCachePresent()
|
||||
public void doesNotStripMinFreshFromRequestWithoutNoCache()
|
||||
throws Exception {
|
||||
req.setHeader("Cache-Control", "min-fresh=10");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals("min-fresh=10",
|
||||
wrapper.getFirstHeader("Cache-Control").getValue());
|
||||
@ -159,7 +159,7 @@ public void doesNotStripMinFreshFromRequestWithoutNoCache()
|
||||
public void correctlyStripsMinFreshFromMiddleIfNoCache()
|
||||
throws Exception {
|
||||
req.setHeader("Cache-Control", "no-cache,min-fresh=10,no-store");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
impl.makeRequestCompliant(wrapper);
|
||||
assertEquals("no-cache,no-store",
|
||||
wrapper.getFirstHeader("Cache-Control").getValue());
|
||||
|
@ -36,7 +36,7 @@
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpHead;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.classic.ClassicRequestCopier;
|
||||
import org.apache.hc.client5.http.utils.DateUtils;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
@ -92,7 +92,7 @@ private ClassicHttpResponse makePartialResponse(final int nbytes) {
|
||||
@Test
|
||||
public void consumesBodyIfOriginSendsOneInResponseToHEAD() throws Exception {
|
||||
final HttpHead req = new HttpHead("http://foo.example.com/");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
final int nbytes = 128;
|
||||
final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
|
||||
setMinimalResponseHeaders(resp);
|
||||
@ -110,7 +110,7 @@ public void consumesBodyIfOriginSendsOneInResponseToHEAD() throws Exception {
|
||||
@Test(expected=ClientProtocolException.class)
|
||||
public void throwsExceptionIfOriginReturnsPartialResponseWhenNotRequested() throws Exception {
|
||||
final HttpGet req = new HttpGet("http://foo.example.com/");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
final int nbytes = 128;
|
||||
final ClassicHttpResponse resp = makePartialResponse(nbytes);
|
||||
resp.setEntity(HttpTestUtils.makeBody(nbytes));
|
||||
@ -121,7 +121,7 @@ public void throwsExceptionIfOriginReturnsPartialResponseWhenNotRequested() thro
|
||||
@Test
|
||||
public void consumesPartialContentFromOriginEvenIfNotRequested() throws Exception {
|
||||
final HttpGet req = new HttpGet("http://foo.example.com/");
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
final int nbytes = 128;
|
||||
final ClassicHttpResponse resp = makePartialResponse(nbytes);
|
||||
|
||||
@ -144,7 +144,7 @@ public void consumesBodyOf100ContinueResponseIfItArrives() throws Exception {
|
||||
req.setHeader("Content-Type", "application/octet-stream");
|
||||
final HttpEntity postBody = new ByteArrayEntity(HttpTestUtils.getRandomBytes(nbytes));
|
||||
req.setEntity(postBody);
|
||||
final ClassicHttpRequest wrapper = ExecSupport.copy(req);
|
||||
final ClassicHttpRequest wrapper = ClassicRequestCopier.INSTANCE.copy(req);
|
||||
|
||||
final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE, "Continue");
|
||||
final Flag closed = new Flag();
|
||||
|
@ -40,12 +40,14 @@ public interface ExecChain {
|
||||
|
||||
final class Scope {
|
||||
|
||||
public final String exchangeId;
|
||||
public final HttpRoute route;
|
||||
public final ClassicHttpRequest originalRequest;
|
||||
public final ExecRuntime execRuntime;
|
||||
public final HttpClientContext clientContext;
|
||||
|
||||
public Scope(final HttpRoute route, final ClassicHttpRequest originalRequest, final ExecRuntime execRuntime, final HttpClientContext clientContext) {
|
||||
public Scope(final String exchangeId, final HttpRoute route, final ClassicHttpRequest originalRequest, final ExecRuntime execRuntime, final HttpClientContext clientContext) {
|
||||
this.exchangeId = Args.notNull(exchangeId, "Exchange id");
|
||||
this.route = Args.notNull(route, "Route");
|
||||
this.originalRequest = Args.notNull(originalRequest, "Original request");
|
||||
this.execRuntime = Args.notNull(execRuntime, "Exec runtime");
|
||||
|
@ -26,21 +26,8 @@
|
||||
*/
|
||||
package org.apache.hc.client5.http.impl;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpMessage;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.message.BasicHttpRequest;
|
||||
import org.apache.hc.core5.http.message.BasicHttpResponse;
|
||||
|
||||
public final class ExecSupport {
|
||||
|
||||
private static final AtomicLong COUNT = new AtomicLong(0);
|
||||
@ -49,64 +36,4 @@ public static long getNextExecNumber() {
|
||||
return COUNT.incrementAndGet();
|
||||
}
|
||||
|
||||
private static void copyMessageProperties(final HttpMessage original, final HttpMessage copy) {
|
||||
copy.setVersion(original.getVersion());
|
||||
for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
|
||||
copy.addHeader(it.next());
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyRequestProperties(final HttpRequest original, final HttpRequest copy) {
|
||||
copyMessageProperties(original, copy);
|
||||
if (copy.getVersion() == null) {
|
||||
copy.setVersion(HttpVersion.DEFAULT);
|
||||
}
|
||||
copy.setScheme(original.getScheme());
|
||||
copy.setAuthority(original.getAuthority());
|
||||
}
|
||||
|
||||
private static void copyResponseProperties(final HttpResponse original, final HttpResponse copy) {
|
||||
copyMessageProperties(original, copy);
|
||||
copy.setLocale(copy.getLocale());
|
||||
copy.setReasonPhrase(copy.getReasonPhrase());
|
||||
}
|
||||
|
||||
public static HttpRequest copy(final HttpRequest original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicHttpRequest copy = new BasicHttpRequest(original.getMethod(), original.getPath());
|
||||
copyRequestProperties(original, copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static HttpResponse copy(final HttpResponse original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicHttpResponse copy = new BasicHttpResponse(original.getCode());
|
||||
copyResponseProperties(original, copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static ClassicHttpRequest copy(final ClassicHttpRequest original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicClassicHttpRequest copy = new BasicClassicHttpRequest(original.getMethod(), original.getPath());
|
||||
copyRequestProperties(original, copy);
|
||||
copy.setEntity(original.getEntity());
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static ClassicHttpResponse copy(final ClassicHttpResponse original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicClassicHttpResponse copy = new BasicClassicHttpResponse(original.getCode());
|
||||
copyResponseProperties(original, copy);
|
||||
copy.setEntity(original.getEntity());
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.hc.client5.http.impl;
|
||||
|
||||
import org.apache.hc.core5.http.HttpMessage;
|
||||
|
||||
/**
|
||||
* Abstract HTTP message cloner.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface MessageCopier<T extends HttpMessage> {
|
||||
|
||||
T copy(T object);
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.hc.client5.http.impl;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.message.BasicHttpRequest;
|
||||
|
||||
public final class RequestCopier implements MessageCopier<HttpRequest> {
|
||||
|
||||
public static final RequestCopier INSTANCE = new RequestCopier();
|
||||
|
||||
public HttpRequest copy(final HttpRequest original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicHttpRequest copy = new BasicHttpRequest(original.getMethod(), original.getPath());
|
||||
copy.setVersion(original.getVersion());
|
||||
for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
|
||||
copy.addHeader(it.next());
|
||||
}
|
||||
copy.setScheme(original.getScheme());
|
||||
copy.setAuthority(original.getAuthority());
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
@ -33,7 +33,7 @@
|
||||
import org.apache.hc.client5.http.async.AsyncExecCallback;
|
||||
import org.apache.hc.client5.http.async.AsyncExecChain;
|
||||
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.RequestCopier;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.EntityDetails;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
@ -64,7 +64,7 @@ private void internalExecute(
|
||||
final AsyncExecChain chain,
|
||||
final AsyncExecCallback asyncExecCallback) throws HttpException, IOException {
|
||||
|
||||
chain.proceed(ExecSupport.copy(request), entityProducer, scope, new AsyncExecCallback() {
|
||||
chain.proceed(RequestCopier.INSTANCE.copy(request), entityProducer, scope, new AsyncExecCallback() {
|
||||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
|
@ -43,6 +43,7 @@
|
||||
import org.apache.hc.client5.http.cookie.CookieSpecProvider;
|
||||
import org.apache.hc.client5.http.cookie.CookieStore;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.impl.RequestCopier;
|
||||
import org.apache.hc.client5.http.nio.AsyncClientConnectionManager;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
|
||||
@ -161,7 +162,7 @@ private void executeChain(
|
||||
|
||||
final AsyncExecChain.Scope scope = new AsyncExecChain.Scope(exchangeId, route, request, clientContext, execRuntime);
|
||||
execChain.execute(
|
||||
ExecSupport.copy(request),
|
||||
RequestCopier.INSTANCE.copy(request),
|
||||
entityDetails != null ? new InternalAsyncEntityProducer(exchangeHandler, entityDetails) : null,
|
||||
scope,
|
||||
new AsyncExecCallback() {
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.hc.client5.http.impl.classic;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.hc.client5.http.impl.MessageCopier;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
|
||||
|
||||
public final class ClassicRequestCopier implements MessageCopier<ClassicHttpRequest> {
|
||||
|
||||
public static final ClassicRequestCopier INSTANCE = new ClassicRequestCopier();
|
||||
|
||||
public ClassicHttpRequest copy(final ClassicHttpRequest original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
final BasicClassicHttpRequest copy = new BasicClassicHttpRequest(original.getMethod(), original.getPath());
|
||||
copy.setVersion(original.getVersion());
|
||||
for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
|
||||
copy.addHeader(it.next());
|
||||
}
|
||||
copy.setScheme(original.getScheme());
|
||||
copy.setAuthority(original.getAuthority());
|
||||
copy.setEntity(original.getEntity());
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
@ -157,10 +157,11 @@ protected CloseableHttpResponse doExecute(
|
||||
}
|
||||
setupContext(localcontext);
|
||||
final HttpRoute route = determineRoute(target, request, localcontext);
|
||||
final String exchangeId = String.format("ex-%08X", ExecSupport.getNextExecNumber());
|
||||
final ExecRuntime execRuntime = new ExecRuntimeImpl(log, connManager, requestExecutor,
|
||||
request instanceof CancellableAware ? (CancellableAware) request : null);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, localcontext);
|
||||
final ClassicHttpResponse response = this.execChain.execute(ExecSupport.copy(request), scope);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(exchangeId, route, request, execRuntime, localcontext);
|
||||
final ClassicHttpResponse response = this.execChain.execute(ClassicRequestCopier.INSTANCE.copy(request), scope);
|
||||
return CloseableHttpResponse.adapt(response);
|
||||
} catch (final HttpException httpException) {
|
||||
throw new ClientProtocolException(httpException.getMessage(), httpException);
|
||||
|
@ -159,6 +159,7 @@ public ClassicHttpResponse execute(
|
||||
}
|
||||
currentRoute = this.routePlanner.determineRoute(newTarget, context);
|
||||
currentScope = new ExecChain.Scope(
|
||||
currentScope.exchangeId,
|
||||
currentRoute,
|
||||
currentScope.originalRequest,
|
||||
currentScope.execRuntime,
|
||||
|
@ -34,7 +34,6 @@
|
||||
import org.apache.hc.client5.http.NonRepeatableRequestException;
|
||||
import org.apache.hc.client5.http.classic.ExecChain;
|
||||
import org.apache.hc.client5.http.classic.ExecChainHandler;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.annotation.Contract;
|
||||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
@ -106,7 +105,7 @@ public ClassicHttpResponse execute(
|
||||
throw new NonRepeatableRequestException("Cannot retry request " +
|
||||
"with a non-repeatable request entity", ex);
|
||||
}
|
||||
currentRequest = ExecSupport.copy(scope.originalRequest);
|
||||
currentRequest = ClassicRequestCopier.INSTANCE.copy(scope.originalRequest);
|
||||
if (this.log.isInfoEnabled()) {
|
||||
this.log.info("Retrying request to " + route);
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
import org.apache.hc.client5.http.ServiceUnavailableRetryStrategy;
|
||||
import org.apache.hc.client5.http.classic.ExecChain;
|
||||
import org.apache.hc.client5.http.classic.ExecChainHandler;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.annotation.Contract;
|
||||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
@ -101,7 +100,7 @@ public ClassicHttpResponse execute(
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
}
|
||||
currentRequest = ExecSupport.copy(scope.originalRequest);
|
||||
currentRequest = ClassicRequestCopier.INSTANCE.copy(scope.originalRequest);
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public void testExecAcquireConnection() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(false);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
Mockito.verify(execRuntime).acquireConnection(route, "Blah", context);
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -130,7 +130,7 @@ public void testEstablishDirectRoute() throws Exception {
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connect(Mockito.<HttpClientContext>any());
|
||||
Mockito.when(execRuntime.isConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -147,7 +147,7 @@ public void testEstablishRouteDirectProxy() throws Exception {
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connect(Mockito.<HttpClientContext>any());
|
||||
Mockito.when(execRuntime.isConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -168,7 +168,7 @@ public void testEstablishRouteViaProxyTunnel() throws Exception {
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -197,7 +197,7 @@ public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exceptio
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ public void testEstablishRouteViaProxyTunnelFailure() throws Exception {
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
exec.execute(request, scope, execChain);
|
||||
} catch (final TunnelRefusedException ex) {
|
||||
@ -260,7 +260,7 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnec
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -300,7 +300,7 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentCon
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
|
||||
Mockito.verify(execRuntime).connect(context);
|
||||
@ -321,7 +321,7 @@ public void testEstablishRouteViaProxyTunnelMultipleHops() throws Exception {
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connect(Mockito.<HttpClientContext>any());
|
||||
Mockito.when(execRuntime.isConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class TestContentCompressionExec {
|
||||
public void setup() {
|
||||
host = new HttpHost("somehost", 80);
|
||||
context = HttpClientContext.create();
|
||||
scope = new ExecChain.Scope(new HttpRoute(host), originaRequest, execRuntime, context);
|
||||
scope = new ExecChain.Scope("test", new HttpRoute(host), originaRequest, execRuntime, context);
|
||||
impl = new ContentCompressionExec();
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public void testExecRequestNonPersistentConnection() throws Exception {
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(false);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null);
|
||||
Mockito.verify(endpoint).execute(request, context);
|
||||
Mockito.verify(endpoint, Mockito.times(1)).markConnectionNonReusable();
|
||||
@ -124,7 +124,7 @@ public void testExecRequestNonPersistentConnectionNoResponseEntity() throws Exce
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(false);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null);
|
||||
|
||||
Mockito.verify(endpoint).execute(request, context);
|
||||
@ -160,7 +160,7 @@ public void testExecRequestPersistentConnection() throws Exception {
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(TimeValue.ofMillis(678L));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null);
|
||||
|
||||
Mockito.verify(endpoint).execute(request, context);
|
||||
@ -192,7 +192,7 @@ public void testExecRequestPersistentConnectionNoResponseEntity() throws Excepti
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(TimeValue.ofMillis(678L));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null);
|
||||
|
||||
Mockito.verify(endpoint).execute(request, context);
|
||||
@ -224,7 +224,7 @@ public void testExecRequestConnectionRelease() throws Exception {
|
||||
Mockito.same(response),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.FALSE);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null);
|
||||
Mockito.verify(endpoint, Mockito.times(1)).execute(request, context);
|
||||
Mockito.verify(endpoint, Mockito.never()).disconnect();
|
||||
@ -248,7 +248,7 @@ public void testExecConnectionShutDown() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new ConnectionShutdownException());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
mainClientExec.execute(request, scope, null);
|
||||
} catch (Exception ex) {
|
||||
@ -267,7 +267,7 @@ public void testExecRuntimeException() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new RuntimeException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
mainClientExec.execute(request, scope, null);
|
||||
} catch (final Exception ex) {
|
||||
@ -286,7 +286,7 @@ public void testExecHttpException() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new HttpException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
mainClientExec.execute(request, scope, null);
|
||||
} catch (final Exception ex) {
|
||||
@ -305,7 +305,7 @@ public void testExecIOException() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new IOException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
mainClientExec.execute(request, scope, null);
|
||||
} catch (final Exception ex) {
|
||||
|
@ -111,7 +111,7 @@ public void testFundamentals() throws Exception {
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
protocolExec.execute(request, scope, chain);
|
||||
|
||||
Mockito.verify(httpProcessor).process(request, null, context);
|
||||
@ -135,7 +135,7 @@ public void testUserInfoInRequestURI() throws Exception {
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
protocolExec.execute(request, scope, chain);
|
||||
Assert.assertEquals(new URI("http://bar/test"), request.getUri());
|
||||
final CredentialsProvider credentialsProvider = context.getCredentialsProvider();
|
||||
@ -157,7 +157,7 @@ public void testPostProcessHttpException() throws Exception {
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.doThrow(new HttpException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
@ -178,7 +178,7 @@ public void testPostProcessIOException() throws Exception {
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.doThrow(new IOException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
@ -199,7 +199,7 @@ public void testPostProcessRuntimeException() throws Exception {
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.doThrow(new RuntimeException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
@ -238,7 +238,7 @@ public void testExecRequestRetryOnAuthChallenge() throws Exception {
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
final ClassicHttpResponse finalResponse = protocolExec.execute(request, scope, chain);
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(request, scope);
|
||||
Mockito.verify(instream1).close();
|
||||
@ -284,7 +284,7 @@ public void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exceptio
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
final ClassicHttpResponse finalResponse = protocolExec.execute(request, scope, chain);
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(request, scope);
|
||||
Mockito.verify(execRuntime).disconnect();
|
||||
@ -334,7 +334,7 @@ public HttpResponse answer(final InvocationOnMock invocationOnMock) throws Throw
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
protocolExec.execute(request, scope, chain);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public void testFundamentals() throws Exception {
|
||||
Mockito.eq(target),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(route);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
|
||||
final ArgumentCaptor<ClassicHttpRequest> reqCaptor = ArgumentCaptor.forClass(
|
||||
@ -171,7 +171,7 @@ public void testMaxRedirect() throws Exception {
|
||||
Mockito.eq(target),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(route);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ public void testRelativeRedirect() throws Exception {
|
||||
Mockito.eq(target),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(route);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ public void testCrossSiteRedirect() throws Exception {
|
||||
Mockito.eq(otherHost),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(new HttpRoute(otherHost));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
|
||||
final AuthExchange authExchange1 = context.getAuthExchange(target);
|
||||
@ -280,7 +280,7 @@ public void testRedirectRuntimeException() throws Exception {
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
redirectExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
@ -313,7 +313,7 @@ public void testRedirectProtocolException() throws Exception {
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
redirectExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
|
@ -38,7 +38,6 @@
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
||||
import org.apache.hc.client5.http.entity.EntityBuilder;
|
||||
import org.apache.hc.client5.http.impl.ExecSupport;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
@ -104,8 +103,8 @@ public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||
Mockito.<IOException>any(),
|
||||
Mockito.eq(1),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ExecSupport.copy(originalRequest);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ClassicRequestCopier.INSTANCE.copy(originalRequest);
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
} catch (final IOException ex) {
|
||||
@ -127,8 +126,8 @@ public void testAbortedRequest() throws Exception {
|
||||
Mockito.<ExecChain.Scope>any())).thenThrow(new IOException("Ka-boom"));
|
||||
Mockito.when(endpoint.isExecutionAborted()).thenReturn(true);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ExecSupport.copy(originalRequest);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ClassicRequestCopier.INSTANCE.copy(originalRequest);
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
} catch (final IOException ex) {
|
||||
@ -172,8 +171,8 @@ public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||
Mockito.<IOException>any(),
|
||||
Mockito.eq(1),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ExecSupport.copy(originalRequest);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ClassicRequestCopier.INSTANCE.copy(originalRequest);
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
} catch (final IOException ex) {
|
||||
|
@ -87,7 +87,7 @@ public void testFundamentals() throws Exception {
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(0L);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
retryExec.execute(request, scope, chain);
|
||||
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(
|
||||
@ -110,7 +110,7 @@ public void testStrategyRuntimeException() throws Exception {
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
} catch (final Exception ex) {
|
||||
@ -138,7 +138,7 @@ public void testNonRepeatableEntityResponseReturnedImmediately() throws Exceptio
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope(route, request, endpoint, context);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = retryExec.execute(request, scope, chain);
|
||||
|
||||
Assert.assertSame(response, finalResponse);
|
||||
|
Loading…
x
Reference in New Issue
Block a user