Upgraded HttpCore to version 5.2-alpha1
This commit is contained in:
parent
c56c00c549
commit
bdc7f3b93e
|
@ -43,7 +43,7 @@ import org.apache.hc.core5.http.HttpRequest;
|
|||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
|
||||
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
||||
import org.apache.hc.core5.http.nio.entity.NoopEntityConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.DiscardingEntityConsumer;
|
||||
import org.apache.hc.core5.http.support.BasicRequestBuilder;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
@ -113,7 +113,7 @@ public final class AsyncHttpRequestRetryExec implements AsyncExecChainHandler {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("{} retrying request in {}", exchangeId, state.delay);
|
||||
}
|
||||
return new NoopEntityConsumer();
|
||||
return new DiscardingEntityConsumer<>();
|
||||
} else {
|
||||
return asyncExecCallback.handleResponse(response, entityDetails);
|
||||
}
|
||||
|
|
|
@ -94,10 +94,8 @@ final class DefaultAsyncClientConnectionOperator implements AsyncClientConnectio
|
|||
tlsStrategy.upgrade(
|
||||
connection,
|
||||
host,
|
||||
session.getLocalAddress(),
|
||||
session.getRemoteAddress(),
|
||||
attachment,
|
||||
connectTimeout);
|
||||
connectTimeout, null);
|
||||
} catch (final Exception ex) {
|
||||
future.failed(ex);
|
||||
return;
|
||||
|
@ -128,9 +126,8 @@ final class DefaultAsyncClientConnectionOperator implements AsyncClientConnectio
|
|||
tlsStrategy.upgrade(
|
||||
connection,
|
||||
host,
|
||||
connection.getLocalAddress(),
|
||||
connection.getRemoteAddress(),
|
||||
attachment,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import javax.net.ssl.SSLSession;
|
|||
|
||||
import org.apache.hc.core5.annotation.Contract;
|
||||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http.ssl.TLS;
|
||||
|
@ -47,6 +48,7 @@ import org.apache.hc.core5.http.ssl.TlsCiphers;
|
|||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
|
||||
import org.apache.hc.core5.http2.ssl.H2TlsSupport;
|
||||
import org.apache.hc.core5.net.NamedEndpoint;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
|
||||
|
@ -82,6 +84,10 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
|
|||
this.tlsSessionValidator = new TlsSessionValidator(LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #upgrade(TransportSecurityLayer, NamedEndpoint, Object, Timeout, FutureCallback)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean upgrade(
|
||||
final TransportSecurityLayer tlsSession,
|
||||
|
@ -90,7 +96,18 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
|
|||
final SocketAddress remoteAddress,
|
||||
final Object attachment,
|
||||
final Timeout handshakeTimeout) {
|
||||
tlsSession.startTls(sslContext, host, sslBufferManagement, (endpoint, sslEngine) -> {
|
||||
upgrade(tlsSession, host, attachment, handshakeTimeout, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgrade(
|
||||
final TransportSecurityLayer tlsSession,
|
||||
final NamedEndpoint endpoint,
|
||||
final Object attachment,
|
||||
final Timeout handshakeTimeout,
|
||||
final FutureCallback<TransportSecurityLayer> callback) {
|
||||
tlsSession.startTls(sslContext, endpoint, sslBufferManagement, (e, sslEngine) -> {
|
||||
|
||||
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
|
||||
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
|
||||
|
@ -119,8 +136,8 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
|
|||
LOG.debug("Enabled protocols: {}", Arrays.asList(sslEngine.getEnabledProtocols()));
|
||||
LOG.debug("Enabled cipher suites:{}", Arrays.asList(sslEngine.getEnabledCipherSuites()));
|
||||
}
|
||||
}, (endpoint, sslEngine) -> {
|
||||
verifySession(host.getHostName(), sslEngine.getSession());
|
||||
}, (e, sslEngine) -> {
|
||||
verifySession(endpoint.getHostName(), sslEngine.getSession());
|
||||
final TlsDetails tlsDetails = createTlsDetails(sslEngine);
|
||||
final String negotiatedCipherSuite = sslEngine.getSession().getCipherSuite();
|
||||
if (tlsDetails != null && ApplicationProtocol.HTTP_2.id.equals(tlsDetails.getApplicationProtocol())) {
|
||||
|
@ -130,8 +147,7 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
|
|||
}
|
||||
}
|
||||
return tlsDetails;
|
||||
}, handshakeTimeout);
|
||||
return true;
|
||||
}, handshakeTimeout, callback);
|
||||
}
|
||||
|
||||
abstract void applyParameters(SSLEngine sslEngine, SSLParameters sslParameters, String[] appProtocols);
|
||||
|
|
|
@ -38,7 +38,6 @@ import javax.net.ssl.SSLParameters;
|
|||
import org.apache.hc.core5.annotation.Contract;
|
||||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http2.ssl.H2TlsSupport;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
|
@ -92,7 +91,7 @@ public class ConscryptClientTlsStrategy extends AbstractClientTlsStrategy {
|
|||
sslEngine.setSSLParameters(sslParameters);
|
||||
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
|
||||
} else {
|
||||
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
|
||||
sslParameters.setApplicationProtocols(appProtocols);
|
||||
sslEngine.setSSLParameters(sslParameters);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.apache.hc.core5.annotation.Contract;
|
|||
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||
import org.apache.hc.core5.function.Factory;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http2.ssl.H2TlsSupport;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
|
@ -98,7 +97,7 @@ public class DefaultClientTlsStrategy extends AbstractClientTlsStrategy {
|
|||
|
||||
@Override
|
||||
void applyParameters(final SSLEngine sslEngine, final SSLParameters sslParameters, final String[] appProtocols) {
|
||||
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
|
||||
sslParameters.setApplicationProtocols(appProtocols);
|
||||
sslEngine.setSSLParameters(sslParameters);
|
||||
}
|
||||
|
||||
|
|
3
pom.xml
3
pom.xml
|
@ -62,7 +62,7 @@
|
|||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<httpcore.version>5.1.1</httpcore.version>
|
||||
<httpcore.version>5.2-alpha1</httpcore.version>
|
||||
<log4j.version>2.9.1</log4j.version>
|
||||
<commons-codec.version>1.15</commons-codec.version>
|
||||
<conscrypt.version>2.2.1</conscrypt.version>
|
||||
|
@ -75,6 +75,7 @@
|
|||
<hc.stylecheck.version>1</hc.stylecheck.version>
|
||||
<rxjava.version>2.2.7</rxjava.version>
|
||||
<api.comparison.version>5.1</api.comparison.version>
|
||||
<hc.animal-sniffer.signature.ignores>javax.net.ssl.SSLEngine,javax.net.ssl.SSLParameters</hc.animal-sniffer.signature.ignores>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
Loading…
Reference in New Issue