You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/09/30 21:01:17 UTC
httpcomponents-client git commit: Added MessageCopier and
implementations for HttpRequest and ClassicHttpRequest messages;
removed message copy methods from ExecSupport
Repository: httpcomponents-client
Updated Branches:
refs/heads/master e8972624a -> 9ac5808bd
Added MessageCopier and implementations for HttpRequest and ClassicHttpRequest messages; removed message copy methods from ExecSupport
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/9ac5808b
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/9ac5808b
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/9ac5808b
Branch: refs/heads/master
Commit: 9ac5808bdbb045fedbbe99b3ca7366e50ab26b31
Parents: e897262
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Sep 30 23:00:45 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Sep 30 23:00:45 2017 +0200
----------------------------------------------------------------------
.../impl/cache/ConditionalRequestBuilder.java | 8 +--
.../impl/cache/RequestProtocolCompliance.java | 6 +-
.../http/impl/cache/AbstractProtocolTest.java | 5 +-
.../TestAsynchronousValidationRequest.java | 2 +-
.../impl/cache/TestAsynchronousValidator.java | 6 +-
.../http/impl/cache/TestCachingExec.java | 2 +-
.../http/impl/cache/TestCachingExecChain.java | 39 ++++++-----
.../cache/TestConditionalRequestBuilder.java | 20 ++----
...ExponentialBackingOffSchedulingStrategy.java | 2 +-
.../impl/cache/TestHttpCacheJiraNumber1147.java | 2 +-
.../http/impl/cache/TestProtocolDeviations.java | 5 +-
.../cache/TestRequestProtocolCompliance.java | 20 +++---
.../cache/TestResponseProtocolCompliance.java | 10 +--
.../hc/client5/http/classic/ExecChain.java | 4 +-
.../hc/client5/http/impl/ExecSupport.java | 73 --------------------
.../hc/client5/http/impl/MessageCopier.java | 41 +++++++++++
.../hc/client5/http/impl/RequestCopier.java | 53 ++++++++++++++
.../client5/http/impl/async/AsyncRetryExec.java | 4 +-
.../impl/async/InternalHttpAsyncClient.java | 3 +-
.../http/impl/classic/ClassicRequestCopier.java | 55 +++++++++++++++
.../http/impl/classic/InternalHttpClient.java | 5 +-
.../client5/http/impl/classic/RedirectExec.java | 1 +
.../hc/client5/http/impl/classic/RetryExec.java | 3 +-
.../classic/ServiceUnavailableRetryExec.java | 3 +-
.../http/impl/classic/TestConnectExec.java | 18 ++---
.../classic/TestContentCompressionExec.java | 2 +-
.../http/impl/classic/TestMainClientExec.java | 18 ++---
.../http/impl/classic/TestProtocolExec.java | 16 ++---
.../http/impl/classic/TestRedirectExec.java | 12 ++--
.../http/impl/classic/TestRetryExec.java | 13 ++--
.../TestServiceUnavailableRetryExec.java | 6 +-
31 files changed, 267 insertions(+), 190 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java
index 73324ba..d298c93 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java
@@ -31,7 +31,7 @@ import java.util.Map;
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 @@ class ConditionalRequestBuilder {
*/
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 @@ class ConditionalRequestBuilder {
* @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);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
index 92757e0..c21b80d 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
@@ -257,6 +257,9 @@ class RequestProtocolCompliance {
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 @@ class RequestProtocolCompliance {
}
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;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/AbstractProtocolTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/AbstractProtocolTest.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/AbstractProtocolTest.java
index 7a5be9d..395c9a3 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/AbstractProtocolTest.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/AbstractProtocolTest.java
@@ -33,7 +33,7 @@ import org.apache.hc.client5.http.HttpRoute;
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 abstract class AbstractProtocolTest {
}
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) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java
index 8f585d7..227f240 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java
@@ -75,7 +75,7 @@ public class TestAsynchronousValidationRequest {
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
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java
index 9e53c4b..06c42ac 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java
@@ -82,7 +82,7 @@ public class TestAsynchronousValidator {
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 class TestAsynchronousValidator {
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();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
index 21facaa..366dea0 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
index cc8d86a..bd9f0a8 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
@@ -58,7 +58,7 @@ import org.apache.hc.client5.http.classic.ExecChainHandler;
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 class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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 abstract class TestCachingExecChain {
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());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
index bdf7fc4..d5c596e 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
@@ -34,13 +34,12 @@ import java.util.Map;
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 class TestConditionalRequestBuilder {
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 class TestConditionalRequestBuilder {
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 class TestConditionalRequestBuilder {
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 class TestConditionalRequestBuilder {
@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 class TestConditionalRequestBuilder {
@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);
@@ -224,13 +223,6 @@ public class TestConditionalRequestBuilder {
}
@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 {
final ClassicHttpRequest result = impl.buildUnconditionalRequest(request);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestExponentialBackingOffSchedulingStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestExponentialBackingOffSchedulingStrategy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestExponentialBackingOffSchedulingStrategy.java
index 5954c43..277e82f 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestExponentialBackingOffSchedulingStrategy.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestExponentialBackingOffSchedulingStrategy.java
@@ -164,7 +164,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
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);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java
index da362a7..72aa987 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java
@@ -116,7 +116,7 @@ public class TestHttpCacheJiraNumber1147 {
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());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
index 0c59c04..48c5f6a 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
@@ -36,7 +36,7 @@ import org.apache.hc.client5.http.cache.HttpCacheContext;
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 class TestProtocolDeviations {
}
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) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRequestProtocolCompliance.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRequestProtocolCompliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRequestProtocolCompliance.java
index ad9b25a..a538229 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRequestProtocolCompliance.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRequestProtocolCompliance.java
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
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 class TestRequestProtocolCompliance {
@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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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 class TestRequestProtocolCompliance {
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());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseProtocolCompliance.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseProtocolCompliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseProtocolCompliance.java
index e548e18..7410c1b 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseProtocolCompliance.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseProtocolCompliance.java
@@ -36,7 +36,7 @@ import org.apache.hc.client5.http.ClientProtocolException;
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 @@ public class TestResponseProtocolCompliance {
@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 class TestResponseProtocolCompliance {
@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 class TestResponseProtocolCompliance {
@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 class TestResponseProtocolCompliance {
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();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java
index 30ecc47..fd1e92e 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java
@@ -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");
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java
index dc99528..9be8153 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java
@@ -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 final class ExecSupport {
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;
- }
-
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java
new file mode 100644
index 0000000..cd152ea
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java
@@ -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);
+
+}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/RequestCopier.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/RequestCopier.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/RequestCopier.java
new file mode 100644
index 0000000..b119018
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/RequestCopier.java
@@ -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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java
index 162915e..82fc6f9 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java
@@ -33,7 +33,7 @@ import org.apache.hc.client5.http.HttpRoute;
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 @@ class AsyncRetryExec implements AsyncExecChainHandler {
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(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
index c6f0d93..e1370e8 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
@@ -43,6 +43,7 @@ import org.apache.hc.client5.http.config.RequestConfig;
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 @@ class InternalHttpAsyncClient extends AbstractHttpAsyncClientBase {
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() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ClassicRequestCopier.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ClassicRequestCopier.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ClassicRequestCopier.java
new file mode 100644
index 0000000..12f044d
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ClassicRequestCopier.java
@@ -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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java
index b759809..795938a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java
@@ -157,10 +157,11 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
}
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);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
index 556c9df..a4fae90 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
@@ -159,6 +159,7 @@ final class RedirectExec implements ExecChainHandler {
}
currentRoute = this.routePlanner.determineRoute(newTarget, context);
currentScope = new ExecChain.Scope(
+ currentScope.exchangeId,
currentRoute,
currentScope.originalRequest,
currentScope.execRuntime,
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
index cd80c54..42167b1 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
@@ -34,7 +34,6 @@ import org.apache.hc.client5.http.HttpRoute;
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 @@ final class RetryExec implements ExecChainHandler {
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);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
index 970f968..e36a02f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
@@ -33,7 +33,6 @@ import java.io.InterruptedIOException;
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 @@ final class ServiceUnavailableRetryExec implements ExecChainHandler {
throw new InterruptedIOException();
}
}
- currentRequest = ExecSupport.copy(scope.originalRequest);
+ currentRequest = ClassicRequestCopier.INSTANCE.copy(scope.originalRequest);
} else {
return response;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
index 4f5d8be..20b1aa8 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
@@ -114,7 +114,7 @@ public class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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 class TestConnectExec {
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);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
index 950b6fb..ff96201 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
@@ -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();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
index 10313d1..bef2fa0 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
@@ -96,7 +96,7 @@ public class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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 class TestMainClientExec {
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) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
index 881af34..ca498be 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
@@ -111,7 +111,7 @@ public class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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 class TestProtocolExec {
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);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
index 0346ead..2339a89 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
@@ -122,7 +122,7 @@ public class TestRedirectExec {
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 class TestRedirectExec {
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 class TestRedirectExec {
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 class TestRedirectExec {
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 class TestRedirectExec {
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 class TestRedirectExec {
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) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRetryExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRetryExec.java
index d21a022..030d175 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRetryExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRetryExec.java
@@ -38,7 +38,6 @@ 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.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 class TestRetryExec {
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 class TestRetryExec {
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 class TestRetryExec {
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) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/9ac5808b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestServiceUnavailableRetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestServiceUnavailableRetryExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestServiceUnavailableRetryExec.java
index f6ab7b3..10371c8 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestServiceUnavailableRetryExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestServiceUnavailableRetryExec.java
@@ -87,7 +87,7 @@ public class TestServiceUnavailableRetryExec {
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 class TestServiceUnavailableRetryExec {
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 class TestServiceUnavailableRetryExec {
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);