@@ -1371,7 +1371,7 @@ TEST_F(ChunkedEncodingTest, WithResponseHandlerAndContentReceiver) {
13711371
13721372TEST (RangeTest, FromHTTPBin_Online) {
13731373#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
1374- auto host = " httpbin .org" ;
1374+ auto host = " httpcan .org" ;
13751375 auto path = std::string{" /range/32" };
13761376#else
13771377 auto host = " nghttp2.org" ;
@@ -1473,7 +1473,7 @@ TEST(ConnectionErrorTest, InvalidHost) {
14731473}
14741474
14751475TEST (ConnectionErrorTest, InvalidHost2) {
1476- auto host = " httpbin .org/" ;
1476+ auto host = " httpcan .org/" ;
14771477
14781478#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
14791479 SSLClient cli (host);
@@ -1488,7 +1488,7 @@ TEST(ConnectionErrorTest, InvalidHost2) {
14881488}
14891489
14901490TEST (ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
1491- auto host = " httpbin .org/" ;
1491+ auto host = " httpcan .org/" ;
14921492
14931493#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
14941494 SSLClient cli (host);
@@ -1545,7 +1545,7 @@ TEST(ConnectionErrorTest, Timeout_Online) {
15451545
15461546TEST (CancelTest, NoCancel_Online) {
15471547#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
1548- auto host = " httpbin .org" ;
1548+ auto host = " httpcan .org" ;
15491549 auto path = std::string{" /range/32" };
15501550#else
15511551 auto host = " nghttp2.org" ;
@@ -1569,7 +1569,7 @@ TEST(CancelTest, NoCancel_Online) {
15691569
15701570TEST (CancelTest, WithCancelSmallPayload_Online) {
15711571#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
1572- auto host = " httpbin .org" ;
1572+ auto host = " httpcan .org" ;
15731573 auto path = std::string{" /range/32" };
15741574#else
15751575 auto host = " nghttp2.org" ;
@@ -1592,7 +1592,7 @@ TEST(CancelTest, WithCancelSmallPayload_Online) {
15921592
15931593TEST (CancelTest, WithCancelLargePayload_Online) {
15941594#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
1595- auto host = " httpbin .org" ;
1595+ auto host = " httpcan .org" ;
15961596 auto path = std::string{" /range/65536" };
15971597#else
15981598 auto host = " nghttp2.org" ;
@@ -1941,7 +1941,7 @@ static std::string remove_whitespace(const std::string &input) {
19411941
19421942TEST (BaseAuthTest, FromHTTPWatch_Online) {
19431943#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
1944- auto host = " httpbin .org" ;
1944+ auto host = " httpcan .org" ;
19451945 auto path = std::string{" /basic-auth/hello/world" };
19461946#else
19471947 auto host = " nghttp2.org" ;
@@ -1998,13 +1998,12 @@ TEST(BaseAuthTest, FromHTTPWatch_Online) {
19981998#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
19991999TEST (DigestAuthTest, FromHTTPWatch_Online) {
20002000#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
2001- auto host = " httpbin .org" ;
2001+ auto host = " httpcan .org" ;
20022002 auto unauth_path = std::string{" /digest-auth/auth/hello/world" };
20032003 auto paths = std::vector<std::string>{
20042004 " /digest-auth/auth/hello/world/MD5" ,
20052005 " /digest-auth/auth/hello/world/SHA-256" ,
20062006 " /digest-auth/auth/hello/world/SHA-512" ,
2007- " /digest-auth/auth-int/hello/world/MD5" ,
20082007 };
20092008#else
20102009 auto host = " nghttp2.org" ;
@@ -2032,8 +2031,60 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
20322031 for (const auto &path : paths) {
20332032 auto res = cli.Get (path.c_str ());
20342033 ASSERT_TRUE (res);
2034+ #ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
2035+ std::string algo (path.substr (path.rfind (' /' ) + 1 ));
2036+ EXPECT_EQ (
2037+ remove_whitespace (" {\" algorithm\" :\" " + algo +
2038+ " \" ,\" authenticated\" :true,\" user\" :\" hello\" }\n " ),
2039+ remove_whitespace (res->body ));
2040+ #else
20352041 EXPECT_EQ (" {\" authenticated\" :true,\" user\" :\" hello\" }" ,
20362042 remove_whitespace (res->body ));
2043+ #endif
2044+ EXPECT_EQ (StatusCode::OK_200, res->status );
2045+ }
2046+
2047+ #ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
2048+ cli.set_digest_auth (" hello" , " bad" );
2049+ for (const auto &path : paths) {
2050+ auto res = cli.Get (path.c_str ());
2051+ ASSERT_TRUE (res);
2052+ EXPECT_EQ (StatusCode::Unauthorized_401, res->status );
2053+ }
2054+ #endif
2055+ }
2056+ }
2057+
2058+ #ifndef CPPHTTPLIB_DEFAULT_HTTPBIN
2059+ TEST (DigestAuthTest, FromHTTPWatch_Online_HTTPCan) {
2060+ auto host = " httpcan.org" ;
2061+ auto unauth_path = std::string{" /digest-auth/auth/hello/world" };
2062+ auto paths = std::vector<std::string>{
2063+ " /digest-auth/auth/hello/world/MD5" ,
2064+ " /digest-auth/auth/hello/world/SHA-256" ,
2065+ " /digest-auth/auth/hello/world/SHA-512" ,
2066+ };
2067+
2068+ auto port = 443 ;
2069+ SSLClient cli (host, port);
2070+
2071+ {
2072+ auto res = cli.Get (unauth_path);
2073+ ASSERT_TRUE (res);
2074+ EXPECT_EQ (StatusCode::Unauthorized_401, res->status );
2075+ }
2076+
2077+ {
2078+
2079+ cli.set_digest_auth (" hello" , " world" );
2080+ for (const auto &path : paths) {
2081+ auto res = cli.Get (path.c_str ());
2082+ ASSERT_TRUE (res);
2083+ std::string algo (path.substr (path.rfind (' /' ) + 1 ));
2084+ EXPECT_EQ (
2085+ remove_whitespace (" {\" algorithm\" :\" " + algo +
2086+ " \" ,\" authenticated\" :true,\" user\" :\" hello\" }\n " ),
2087+ remove_whitespace (res->body ));
20372088 EXPECT_EQ (StatusCode::OK_200, res->status );
20382089 }
20392090
@@ -2044,18 +2095,18 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
20442095 EXPECT_EQ (StatusCode::Unauthorized_401, res->status );
20452096 }
20462097
2047- // NOTE: Until httpbin.org fixes issue #46, the following test is commented
2048- // out. Please see https://httpbin.org/digest-auth/auth/hello/world
2049- // cli.set_digest_auth("bad", "world");
2050- // for (const auto& path : paths) {
2051- // auto res = cli.Get(path.c_str());
2052- // ASSERT_TRUE(res);
2053- // EXPECT_EQ(StatusCode::BadRequest_400, res->status);
2054- // }
2098+ cli.set_digest_auth (" bad" , " world" );
2099+ for (const auto &path : paths) {
2100+ auto res = cli.Get (path.c_str ());
2101+ ASSERT_TRUE (res);
2102+ EXPECT_EQ (StatusCode::Unauthorized_401, res->status );
2103+ }
20552104 }
20562105}
20572106#endif
20582107
2108+ #endif
2109+
20592110TEST (SpecifyServerIPAddressTest, AnotherHostname_Online) {
20602111 auto host = " google.com" ;
20612112 auto another_host = " example.com" ;
@@ -7924,7 +7975,7 @@ TEST(GetWithParametersTest, GetWithParameters2) {
79247975
79257976TEST (ClientDefaultHeadersTest, DefaultHeaders_Online) {
79267977#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
7927- auto host = " httpbin .org" ;
7978+ auto host = " httpcan .org" ;
79287979 auto path = std::string{" /range/32" };
79297980#else
79307981 auto host = " nghttp2.org" ;
@@ -8440,7 +8491,7 @@ TEST(SSLClientTest, UpdateCAStore) {
84408491
84418492TEST (SSLClientTest, ServerNameIndication_Online) {
84428493#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
8443- auto host = " httpbin .org" ;
8494+ auto host = " httpcan .org" ;
84448495 auto path = std::string{" /get" };
84458496#else
84468497 auto host = " nghttp2.org" ;
@@ -8684,7 +8735,7 @@ TEST(SSLClientTest, Issue2251_ClientCertFileNotMatchingKey) {
86848735
86858736#if 0
86868737TEST(SSLClientTest, SetInterfaceWithINET6) {
8687- auto cli = std::make_shared<httplib::Client>("https://httpbin .org");
8738+ auto cli = std::make_shared<httplib::Client>("https://httpcan .org");
86888739 ASSERT_TRUE(cli != nullptr);
86898740
86908741 cli->set_address_family(AF_INET6);
0 commit comments