|
@@ -1371,7 +1371,7 @@ TEST_F(ChunkedEncodingTest, WithResponseHandlerAndContentReceiver) {
|
|
|
|
|
|
|
|
TEST(RangeTest, FromHTTPBin_Online) {
|
|
TEST(RangeTest, FromHTTPBin_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/range/32"};
|
|
auto path = std::string{"/range/32"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -1473,7 +1473,7 @@ TEST(ConnectionErrorTest, InvalidHost) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
TEST(ConnectionErrorTest, InvalidHost2) {
|
|
TEST(ConnectionErrorTest, InvalidHost2) {
|
|
|
- auto host = "httpbin.org/";
|
|
|
|
|
|
|
+ auto host = "httpcan.org/";
|
|
|
|
|
|
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
SSLClient cli(host);
|
|
SSLClient cli(host);
|
|
@@ -1488,7 +1488,7 @@ TEST(ConnectionErrorTest, InvalidHost2) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
|
|
TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
|
|
|
- auto host = "httpbin.org/";
|
|
|
|
|
|
|
+ auto host = "httpcan.org/";
|
|
|
|
|
|
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
SSLClient cli(host);
|
|
SSLClient cli(host);
|
|
@@ -1545,7 +1545,7 @@ TEST(ConnectionErrorTest, Timeout_Online) {
|
|
|
|
|
|
|
|
TEST(CancelTest, NoCancel_Online) {
|
|
TEST(CancelTest, NoCancel_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/range/32"};
|
|
auto path = std::string{"/range/32"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -1569,7 +1569,7 @@ TEST(CancelTest, NoCancel_Online) {
|
|
|
|
|
|
|
|
TEST(CancelTest, WithCancelSmallPayload_Online) {
|
|
TEST(CancelTest, WithCancelSmallPayload_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/range/32"};
|
|
auto path = std::string{"/range/32"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -1592,7 +1592,7 @@ TEST(CancelTest, WithCancelSmallPayload_Online) {
|
|
|
|
|
|
|
|
TEST(CancelTest, WithCancelLargePayload_Online) {
|
|
TEST(CancelTest, WithCancelLargePayload_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/range/65536"};
|
|
auto path = std::string{"/range/65536"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -1941,7 +1941,7 @@ static std::string remove_whitespace(const std::string &input) {
|
|
|
|
|
|
|
|
TEST(BaseAuthTest, FromHTTPWatch_Online) {
|
|
TEST(BaseAuthTest, FromHTTPWatch_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/basic-auth/hello/world"};
|
|
auto path = std::string{"/basic-auth/hello/world"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -1998,13 +1998,12 @@ TEST(BaseAuthTest, FromHTTPWatch_Online) {
|
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
|
|
TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
|
TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto unauth_path = std::string{"/digest-auth/auth/hello/world"};
|
|
auto unauth_path = std::string{"/digest-auth/auth/hello/world"};
|
|
|
auto paths = std::vector<std::string>{
|
|
auto paths = std::vector<std::string>{
|
|
|
"/digest-auth/auth/hello/world/MD5",
|
|
"/digest-auth/auth/hello/world/MD5",
|
|
|
"/digest-auth/auth/hello/world/SHA-256",
|
|
"/digest-auth/auth/hello/world/SHA-256",
|
|
|
"/digest-auth/auth/hello/world/SHA-512",
|
|
"/digest-auth/auth/hello/world/SHA-512",
|
|
|
- "/digest-auth/auth-int/hello/world/MD5",
|
|
|
|
|
};
|
|
};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -2032,8 +2031,60 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
|
|
for (const auto &path : paths) {
|
|
for (const auto &path : paths) {
|
|
|
auto res = cli.Get(path.c_str());
|
|
auto res = cli.Get(path.c_str());
|
|
|
ASSERT_TRUE(res);
|
|
ASSERT_TRUE(res);
|
|
|
|
|
+#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
|
|
+ std::string algo(path.substr(path.rfind('/') + 1));
|
|
|
|
|
+ EXPECT_EQ(
|
|
|
|
|
+ remove_whitespace("{\"algorithm\":\"" + algo +
|
|
|
|
|
+ "\",\"authenticated\":true,\"user\":\"hello\"}\n"),
|
|
|
|
|
+ remove_whitespace(res->body));
|
|
|
|
|
+#else
|
|
|
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
|
|
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
|
|
|
remove_whitespace(res->body));
|
|
remove_whitespace(res->body));
|
|
|
|
|
+#endif
|
|
|
|
|
+ EXPECT_EQ(StatusCode::OK_200, res->status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
|
|
+ cli.set_digest_auth("hello", "bad");
|
|
|
|
|
+ for (const auto &path : paths) {
|
|
|
|
|
+ auto res = cli.Get(path.c_str());
|
|
|
|
|
+ ASSERT_TRUE(res);
|
|
|
|
|
+ EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#ifndef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
|
|
+TEST(DigestAuthTest, FromHTTPWatch_Online_HTTPCan) {
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
|
|
+ auto unauth_path = std::string{"/digest-auth/auth/hello/world"};
|
|
|
|
|
+ auto paths = std::vector<std::string>{
|
|
|
|
|
+ "/digest-auth/auth/hello/world/MD5",
|
|
|
|
|
+ "/digest-auth/auth/hello/world/SHA-256",
|
|
|
|
|
+ "/digest-auth/auth/hello/world/SHA-512",
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ auto port = 443;
|
|
|
|
|
+ SSLClient cli(host, port);
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ auto res = cli.Get(unauth_path);
|
|
|
|
|
+ ASSERT_TRUE(res);
|
|
|
|
|
+ EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ cli.set_digest_auth("hello", "world");
|
|
|
|
|
+ for (const auto &path : paths) {
|
|
|
|
|
+ auto res = cli.Get(path.c_str());
|
|
|
|
|
+ ASSERT_TRUE(res);
|
|
|
|
|
+ std::string algo(path.substr(path.rfind('/') + 1));
|
|
|
|
|
+ EXPECT_EQ(
|
|
|
|
|
+ remove_whitespace("{\"algorithm\":\"" + algo +
|
|
|
|
|
+ "\",\"authenticated\":true,\"user\":\"hello\"}\n"),
|
|
|
|
|
+ remove_whitespace(res->body));
|
|
|
EXPECT_EQ(StatusCode::OK_200, res->status);
|
|
EXPECT_EQ(StatusCode::OK_200, res->status);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2044,18 +2095,18 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
|
|
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
|
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // NOTE: Until httpbin.org fixes issue #46, the following test is commented
|
|
|
|
|
- // out. Please see https://httpbin.org/digest-auth/auth/hello/world
|
|
|
|
|
- // cli.set_digest_auth("bad", "world");
|
|
|
|
|
- // for (const auto& path : paths) {
|
|
|
|
|
- // auto res = cli.Get(path.c_str());
|
|
|
|
|
- // ASSERT_TRUE(res);
|
|
|
|
|
- // EXPECT_EQ(StatusCode::BadRequest_400, res->status);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ cli.set_digest_auth("bad", "world");
|
|
|
|
|
+ for (const auto &path : paths) {
|
|
|
|
|
+ auto res = cli.Get(path.c_str());
|
|
|
|
|
+ ASSERT_TRUE(res);
|
|
|
|
|
+ EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) {
|
|
TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) {
|
|
|
auto host = "google.com";
|
|
auto host = "google.com";
|
|
|
auto another_host = "example.com";
|
|
auto another_host = "example.com";
|
|
@@ -7924,7 +7975,7 @@ TEST(GetWithParametersTest, GetWithParameters2) {
|
|
|
|
|
|
|
|
TEST(ClientDefaultHeadersTest, DefaultHeaders_Online) {
|
|
TEST(ClientDefaultHeadersTest, DefaultHeaders_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/range/32"};
|
|
auto path = std::string{"/range/32"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -8440,7 +8491,7 @@ TEST(SSLClientTest, UpdateCAStore) {
|
|
|
|
|
|
|
|
TEST(SSLClientTest, ServerNameIndication_Online) {
|
|
TEST(SSLClientTest, ServerNameIndication_Online) {
|
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
|
|
- auto host = "httpbin.org";
|
|
|
|
|
|
|
+ auto host = "httpcan.org";
|
|
|
auto path = std::string{"/get"};
|
|
auto path = std::string{"/get"};
|
|
|
#else
|
|
#else
|
|
|
auto host = "nghttp2.org";
|
|
auto host = "nghttp2.org";
|
|
@@ -8684,7 +8735,7 @@ TEST(SSLClientTest, Issue2251_ClientCertFileNotMatchingKey) {
|
|
|
|
|
|
|
|
#if 0
|
|
#if 0
|
|
|
TEST(SSLClientTest, SetInterfaceWithINET6) {
|
|
TEST(SSLClientTest, SetInterfaceWithINET6) {
|
|
|
- auto cli = std::make_shared<httplib::Client>("https://httpbin.org");
|
|
|
|
|
|
|
+ auto cli = std::make_shared<httplib::Client>("https://httpcan.org");
|
|
|
ASSERT_TRUE(cli != nullptr);
|
|
ASSERT_TRUE(cli != nullptr);
|
|
|
|
|
|
|
|
cli->set_address_family(AF_INET6);
|
|
cli->set_address_family(AF_INET6);
|