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 2018/10/07 13:20:43 UTC
[2/2] httpcomponents-client git commit: Fixed incorrect server
protocol version initialization in the cross-site redirect integration test
Fixed incorrect server protocol version initialization in the cross-site redirect integration test
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/c51aab45
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/c51aab45
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/c51aab45
Branch: refs/heads/master
Commit: c51aab45b49a68af23ced4d744f1770af505e3ab
Parents: 1b9ff18
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Oct 7 15:18:52 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Oct 7 15:18:52 2018 +0200
----------------------------------------------------------------------
.../async/AbstractHttpAsyncRedirectsTest.java | 22 ++++++++++++++++++--
.../testing/async/TestHttp1AsyncRedirects.java | 15 +++++--------
.../testing/async/TestHttp2AsyncRedirect.java | 16 +++++---------
3 files changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/c51aab45/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
index 2af85ef..e98a140 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java
@@ -54,12 +54,14 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.net.URIBuilder;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.ListenerEndpoint;
@@ -70,8 +72,20 @@ import org.junit.Test;
public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsyncClient> extends AbstractIntegrationTestBase<T> {
- public AbstractHttpAsyncRedirectsTest(final URIScheme scheme) {
+ protected final HttpVersion version;
+
+ public AbstractHttpAsyncRedirectsTest(final HttpVersion version, final URIScheme scheme) {
super(scheme);
+ this.version = version;
+ }
+
+ @Override
+ public final HttpHost start() throws Exception {
+ if (version.greaterEquals(HttpVersion.HTTP_2)) {
+ return super.start(null, H2Config.DEFAULT);
+ } else {
+ return super.start(null, H1Config.DEFAULT);
+ }
}
static class BasicRedirectService extends AbstractSimpleServerExchangeHandler {
@@ -684,7 +698,11 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
});
- secondServer.start(H1Config.DEFAULT);
+ if (version.greaterEquals(HttpVersion.HTTP_2)) {
+ secondServer.start(H2Config.DEFAULT);
+ } else {
+ secondServer.start(H1Config.DEFAULT);
+ }
final Future<ListenerEndpoint> endpointFuture = secondServer.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint2 = endpointFuture.get();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/c51aab45/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
index 8212b20..2abf5d0 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java
@@ -54,9 +54,9 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.URIScheme;
-import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
@@ -85,6 +85,10 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
protected HttpAsyncClientBuilder clientBuilder;
protected PoolingAsyncClientConnectionManager connManager;
+ public TestHttp1AsyncRedirects(final URIScheme scheme) {
+ super(HttpVersion.HTTP_1_1, scheme);
+ }
+
@Rule
public ExternalResource connManagerResource = new ExternalResource() {
@@ -120,20 +124,11 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
};
- public TestHttp1AsyncRedirects(final URIScheme scheme) {
- super(scheme);
- }
-
@Override
protected CloseableHttpAsyncClient createClient() throws Exception {
return clientBuilder.build();
}
- @Override
- public final HttpHost start() throws Exception {
- return super.start(null, H1Config.DEFAULT);
- }
-
static class NoKeepAliveRedirectService extends AbstractSimpleServerExchangeHandler {
private final int statuscode;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/c51aab45/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp2AsyncRedirect.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp2AsyncRedirect.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp2AsyncRedirect.java
index 417c3da..c76c0ce 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp2AsyncRedirect.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp2AsyncRedirect.java
@@ -34,9 +34,8 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.Http2AsyncClientBuilder;
import org.apache.hc.client5.http.ssl.H2TlsStrategy;
import org.apache.hc.client5.testing.SSLTestContexts;
-import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.URIScheme;
-import org.apache.hc.core5.http2.config.H2Config;
import org.junit.Rule;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
@@ -55,6 +54,10 @@ public class TestHttp2AsyncRedirect extends AbstractHttpAsyncRedirectsTest<Close
protected Http2AsyncClientBuilder clientBuilder;
+ public TestHttp2AsyncRedirect(final URIScheme scheme) {
+ super(HttpVersion.HTTP_2, scheme);
+ }
+
@Rule
public ExternalResource clientResource = new ExternalResource() {
@@ -70,18 +73,9 @@ public class TestHttp2AsyncRedirect extends AbstractHttpAsyncRedirectsTest<Close
};
- public TestHttp2AsyncRedirect(final URIScheme scheme) {
- super(scheme);
- }
-
@Override
protected CloseableHttpAsyncClient createClient() {
return clientBuilder.build();
}
- @Override
- public HttpHost start() throws Exception {
- return super.start(null, H2Config.DEFAULT);
- }
-
}
\ No newline at end of file