Skip to content

Commit b42c256

Browse files
committed
Add test to demonstrate that AsyncHttpClient#1134 is fixed in AHC2
1 parent 1e9dd38 commit b42c256

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

client/src/test/java/org/asynchttpclient/BasicHttpTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import static io.netty.handler.codec.http.HttpHeaders.Names.*;
1717
import static io.netty.handler.codec.http.HttpHeaders.Values.*;
18-
import static java.nio.charset.StandardCharsets.*;
18+
import static java.nio.charset.StandardCharsets.ISO_8859_1;
1919
import static java.util.concurrent.TimeUnit.SECONDS;
2020
import static org.asynchttpclient.Dsl.*;
2121
import static org.asynchttpclient.test.TestUtils.*;
@@ -41,6 +41,8 @@
4141
import java.util.concurrent.atomic.AtomicInteger;
4242
import java.util.concurrent.atomic.AtomicReference;
4343

44+
import javax.net.ssl.SSLException;
45+
4446
import org.asynchttpclient.cookie.Cookie;
4547
import org.asynchttpclient.handler.MaxRedirectException;
4648
import org.asynchttpclient.request.body.multipart.StringPart;
@@ -893,4 +895,20 @@ public void newConnectionEventsAreFired() throws Throwable {
893895
});
894896
});
895897
}
898+
899+
@Test
900+
public void requestingPlainHttpEndpointOverHttpsThrowsSslException() throws Throwable {
901+
withClient().run(client -> {
902+
withServer(server).run(server -> {
903+
server.enqueueEcho();
904+
try {
905+
client.prepareGet(getTargetUrl().replace("http", "https")).execute().get();
906+
fail("Request shouldn't succeed");
907+
} catch (ExecutionException e) {
908+
assertTrue(e.getCause() instanceof ConnectException, "Cause should be a ConnectException");
909+
assertTrue(e.getCause().getCause() instanceof SSLException, "Root cause should be a SslException");
910+
}
911+
});
912+
});
913+
}
896914
}

0 commit comments

Comments
 (0)