Fixed incorrect server protocol version initialization in the cross-site redirect integration test
This commit is contained in:
parent
678cc1bcb8
commit
7468244080
|
@ -54,11 +54,14 @@ import org.apache.hc.core5.http.HttpHost;
|
||||||
import org.apache.hc.core5.http.HttpRequest;
|
import org.apache.hc.core5.http.HttpRequest;
|
||||||
import org.apache.hc.core5.http.HttpResponse;
|
import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
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.ProtocolException;
|
||||||
import org.apache.hc.core5.http.URIScheme;
|
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.message.BasicHeader;
|
||||||
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
||||||
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
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.net.URIBuilder;
|
||||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||||
import org.apache.hc.core5.reactor.ListenerEndpoint;
|
import org.apache.hc.core5.reactor.ListenerEndpoint;
|
||||||
|
@ -69,8 +72,20 @@ import org.junit.Test;
|
||||||
|
|
||||||
public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsyncClient> extends AbstractIntegrationTestBase<T> {
|
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);
|
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 {
|
static class BasicRedirectService extends AbstractSimpleServerExchangeHandler {
|
||||||
|
@ -683,7 +698,11 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
secondServer.start();
|
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 Future<ListenerEndpoint> endpointFuture = secondServer.listen(new InetSocketAddress(0));
|
||||||
final ListenerEndpoint endpoint2 = endpointFuture.get();
|
final ListenerEndpoint endpoint2 = endpointFuture.get();
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ import org.apache.hc.core5.http.HttpHost;
|
||||||
import org.apache.hc.core5.http.HttpRequest;
|
import org.apache.hc.core5.http.HttpRequest;
|
||||||
import org.apache.hc.core5.http.HttpResponse;
|
import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
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.ProtocolException;
|
||||||
import org.apache.hc.core5.http.URIScheme;
|
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.message.BasicHeader;
|
||||||
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
||||||
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
||||||
|
@ -85,6 +85,10 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
|
||||||
protected HttpAsyncClientBuilder clientBuilder;
|
protected HttpAsyncClientBuilder clientBuilder;
|
||||||
protected PoolingAsyncClientConnectionManager connManager;
|
protected PoolingAsyncClientConnectionManager connManager;
|
||||||
|
|
||||||
|
public TestHttp1AsyncRedirects(final URIScheme scheme) {
|
||||||
|
super(HttpVersion.HTTP_1_1, scheme);
|
||||||
|
}
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExternalResource connManagerResource = new ExternalResource() {
|
public ExternalResource connManagerResource = new ExternalResource() {
|
||||||
|
|
||||||
|
@ -120,20 +124,11 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestHttp1AsyncRedirects(final URIScheme scheme) {
|
|
||||||
super(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CloseableHttpAsyncClient createClient() throws Exception {
|
protected CloseableHttpAsyncClient createClient() throws Exception {
|
||||||
return clientBuilder.build();
|
return clientBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final HttpHost start() throws Exception {
|
|
||||||
return super.start(null, H1Config.DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class NoKeepAliveRedirectService extends AbstractSimpleServerExchangeHandler {
|
static class NoKeepAliveRedirectService extends AbstractSimpleServerExchangeHandler {
|
||||||
|
|
||||||
private final int statuscode;
|
private final int statuscode;
|
||||||
|
|
|
@ -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.impl.async.Http2AsyncClientBuilder;
|
||||||
import org.apache.hc.client5.http.ssl.H2TlsStrategy;
|
import org.apache.hc.client5.http.ssl.H2TlsStrategy;
|
||||||
import org.apache.hc.client5.testing.SSLTestContexts;
|
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.http.URIScheme;
|
||||||
import org.apache.hc.core5.http2.config.H2Config;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.rules.ExternalResource;
|
import org.junit.rules.ExternalResource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -55,6 +54,10 @@ public class TestHttp2AsyncRedirect extends AbstractHttpAsyncRedirectsTest<Close
|
||||||
|
|
||||||
protected Http2AsyncClientBuilder clientBuilder;
|
protected Http2AsyncClientBuilder clientBuilder;
|
||||||
|
|
||||||
|
public TestHttp2AsyncRedirect(final URIScheme scheme) {
|
||||||
|
super(HttpVersion.HTTP_2, scheme);
|
||||||
|
}
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExternalResource clientResource = new ExternalResource() {
|
public ExternalResource clientResource = new ExternalResource() {
|
||||||
|
|
||||||
|
@ -70,18 +73,9 @@ public class TestHttp2AsyncRedirect extends AbstractHttpAsyncRedirectsTest<Close
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestHttp2AsyncRedirect(final URIScheme scheme) {
|
|
||||||
super(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CloseableHttpAsyncClient createClient() {
|
protected CloseableHttpAsyncClient createClient() {
|
||||||
return clientBuilder.build();
|
return clientBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpHost start() throws Exception {
|
|
||||||
return super.start(null, H2Config.DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue