diff --git a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpClientConfig.java b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpClientConfig.java index 47e2284a25..d0d467662b 100644 --- a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpClientConfig.java +++ b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpClientConfig.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors + * Copyright © 2018-2020 Apple Inc. and the ServiceTalk project authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,8 @@ final class HttpClientConfig { } HttpClientConfig(final HttpClientConfig from) { - tcpConfig = from.tcpConfig(); - protocolConfigs = from.protocolConfigs(); + tcpConfig = new TcpClientConfig(from.tcpConfig()); + protocolConfigs = new HttpConfig(from.protocolConfigs()); connectAddress = from.connectAddress; } diff --git a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpConfig.java b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpConfig.java index 398dc33a3f..eb0291547e 100644 --- a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpConfig.java +++ b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpConfig.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Apple Inc. and the ServiceTalk project authors + * Copyright © 2019-2020 Apple Inc. and the ServiceTalk project authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,22 @@ final class HttpConfig { @Nullable - private H1ProtocolConfig h1Config = h1Default(); + private H1ProtocolConfig h1Config; @Nullable private H2ProtocolConfig h2Config; - private List supportedAlpnProtocols = emptyList(); + private List supportedAlpnProtocols; + + HttpConfig() { + h1Config = h1Default(); + h2Config = null; + supportedAlpnProtocols = emptyList(); + } + + HttpConfig(final HttpConfig from) { + this.h1Config = from.h1Config; + this.h2Config = from.h2Config; + this.supportedAlpnProtocols = from.supportedAlpnProtocols; + } @Nullable H1ProtocolConfig h1Config() { diff --git a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java index 8d1237234a..75a5b8b9f8 100644 --- a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java +++ b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors + * Copyright © 2018-2020 Apple Inc. and the ServiceTalk project authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -202,6 +202,30 @@ public void multiAddressClientWithSslToSecureServer() throws Exception { } } + @Test + public void multiAddressClientToSecureServerThenToNonSecureServer() throws Exception { + try (BlockingHttpClient client = HttpClients.forMultiAddressUrl() + .secure((hap, config) -> config.disableHostnameVerification() + .trustManager(DefaultTestCerts::loadMutualAuthCaPem)) + .buildBlocking()) { + testRequestResponse(client, secureRequestTarget, true); + resetMocks(); + testRequestResponse(client, requestTarget, false); + } + } + + @Test + public void multiAddressClientToNonSecureServerThenToSecureServer() throws Exception { + try (BlockingHttpClient client = HttpClients.forMultiAddressUrl() + .secure((hap, config) -> config.disableHostnameVerification() + .trustManager(DefaultTestCerts::loadMutualAuthCaPem)) + .buildBlocking()) { + testRequestResponse(client, requestTarget, false); + resetMocks(); + testRequestResponse(client, secureRequestTarget, true); + } + } + private static void testRequestResponse(final BlockingHttpClient client, final String requestTarget, final boolean secure) throws Exception { final HttpResponse response = client.request(client.get(requestTarget));