@@ -651,19 +651,6 @@ TEST(YahooRedirectTest, Redirect) {
651651 EXPECT_EQ (200 , res->status );
652652}
653653
654- TEST (YahooRedirectTest2, Redirect) {
655- httplib::Client2 cli (" http://yahoo.com" );
656-
657- auto res = cli.Get (" /" );
658- ASSERT_TRUE (res != nullptr );
659- EXPECT_EQ (301 , res->status );
660-
661- cli.set_follow_location (true );
662- res = cli.Get (" /" );
663- ASSERT_TRUE (res != nullptr );
664- EXPECT_EQ (200 , res->status );
665- }
666-
667654TEST (HttpsToHttpRedirectTest, Redirect) {
668655 httplib::SSLClient cli (" httpbin.org" );
669656 cli.set_follow_location (true );
@@ -673,16 +660,6 @@ TEST(HttpsToHttpRedirectTest, Redirect) {
673660 EXPECT_EQ (200 , res->status );
674661}
675662
676- TEST (HttpsToHttpRedirectTest2, Redirect) {
677- auto res =
678- httplib::Client2 (" https://httpbin.org" )
679- .set_follow_location (true )
680- .Get (" /redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302" );
681-
682- ASSERT_TRUE (res != nullptr );
683- EXPECT_EQ (200 , res->status );
684- }
685-
686663TEST (RedirectToDifferentPort, Redirect) {
687664 Server svr8080;
688665 Server svr8081;
@@ -2887,13 +2864,6 @@ TEST(SSLClientServerTest, TrustDirOptional) {
28872864
28882865 t.join ();
28892866}
2890-
2891- /* Cannot test this case as there is no external access to SSL object to check
2892- SSL_get_peer_certificate() == NULL TEST(SSLClientServerTest,
2893- ClientCAPathRequired) { SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE,
2894- nullptr, CLIENT_CA_CERT_DIR);
2895- }
2896- */
28972867#endif
28982868
28992869#ifdef _WIN32
@@ -2902,3 +2872,51 @@ TEST(CleanupTest, WSACleanup) {
29022872 ASSERT_EQ (0 , ret);
29032873}
29042874#endif
2875+
2876+ #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
2877+ TEST (InvalidScheme, SimpleInterface) {
2878+ httplib::Client2 cli (" scheme://yahoo.com" );
2879+ ASSERT_FALSE (cli.is_valid ());
2880+ }
2881+
2882+ TEST (NoScheme, SimpleInterface) {
2883+ httplib::Client2 cli (" yahoo.com" );
2884+ ASSERT_FALSE (cli.is_valid ());
2885+ }
2886+
2887+ TEST (YahooRedirectTest2, SimpleInterface) {
2888+ httplib::Client2 cli (" http://yahoo.com" );
2889+
2890+ auto res = cli.Get (" /" );
2891+ ASSERT_TRUE (res != nullptr );
2892+ EXPECT_EQ (301 , res->status );
2893+
2894+ cli.set_follow_location (true );
2895+ res = cli.Get (" /" );
2896+ ASSERT_TRUE (res != nullptr );
2897+ EXPECT_EQ (200 , res->status );
2898+ }
2899+
2900+ TEST (YahooRedirectTest3, SimpleInterface) {
2901+ httplib::Client2 cli (" https://yahoo.com" );
2902+
2903+ auto res = cli.Get (" /" );
2904+ ASSERT_TRUE (res != nullptr );
2905+ EXPECT_EQ (301 , res->status );
2906+
2907+ cli.set_follow_location (true );
2908+ res = cli.Get (" /" );
2909+ ASSERT_TRUE (res != nullptr );
2910+ EXPECT_EQ (200 , res->status );
2911+ }
2912+
2913+ TEST (HttpsToHttpRedirectTest2, SimpleInterface) {
2914+ auto res =
2915+ httplib::Client2 (" https://httpbin.org" )
2916+ .set_follow_location (true )
2917+ .Get (" /redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302" );
2918+
2919+ ASSERT_TRUE (res != nullptr );
2920+ EXPECT_EQ (200 , res->status );
2921+ }
2922+ #endif
0 commit comments