mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Code format
This commit is contained in:
parent
242706ea34
commit
3f88a46c4a
@ -3555,7 +3555,8 @@ inline bool load_system_certs_on_windows(X509_STORE *store) {
|
|||||||
if (!hStore) { return false; }
|
if (!hStore) { return false; }
|
||||||
|
|
||||||
PCCERT_CONTEXT pContext = NULL;
|
PCCERT_CONTEXT pContext = NULL;
|
||||||
while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != nullptr) {
|
while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) !=
|
||||||
|
nullptr) {
|
||||||
auto encoded_cert =
|
auto encoded_cert =
|
||||||
static_cast<const unsigned char *>(pContext->pbCertEncoded);
|
static_cast<const unsigned char *>(pContext->pbCertEncoded);
|
||||||
|
|
||||||
|
40
test/test.cc
40
test/test.cc
@ -70,8 +70,7 @@ TEST(EncodeQueryParamTest, TestUTF8Characters){
|
|||||||
EXPECT_EQ(detail::encode_query_param(russianCharacters),
|
EXPECT_EQ(detail::encode_query_param(russianCharacters),
|
||||||
"%D0%B4%D0%BE%D0%BC");
|
"%D0%B4%D0%BE%D0%BC");
|
||||||
|
|
||||||
EXPECT_EQ(detail::encode_query_param(brazilianCharacters),
|
EXPECT_EQ(detail::encode_query_param(brazilianCharacters), "%C3%B3culos");
|
||||||
"%C3%B3culos");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TrimTests, TrimStringTests) {
|
TEST(TrimTests, TrimStringTests) {
|
||||||
@ -3211,6 +3210,39 @@ TEST(KeepAliveTest, ReadTimeout) {
|
|||||||
ASSERT_FALSE(svr.is_running());
|
ASSERT_FALSE(svr.is_running());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ErrorHandlerWithContentProviderTest, ErrorHandler) {
|
||||||
|
Server svr;
|
||||||
|
|
||||||
|
svr.set_error_handler([](Request const &, Response &res) -> void {
|
||||||
|
res.set_chunked_content_provider(
|
||||||
|
"text/plain", [](std::size_t const, DataSink &sink) -> bool {
|
||||||
|
sink.os << "hello";
|
||||||
|
sink.os << "world";
|
||||||
|
sink.done();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); });
|
||||||
|
while (!svr.is_running()) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give GET time to get a few messages.
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
|
Client cli("localhost", PORT);
|
||||||
|
|
||||||
|
auto res = cli.Get("/");
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
EXPECT_EQ(404, res->status);
|
||||||
|
EXPECT_EQ("helloworld", res->body);
|
||||||
|
|
||||||
|
svr.stop();
|
||||||
|
listen_thread.join();
|
||||||
|
ASSERT_FALSE(svr.is_running());
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
TEST(KeepAliveTest, ReadTimeoutSSL) {
|
TEST(KeepAliveTest, ReadTimeoutSSL) {
|
||||||
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
|
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
|
||||||
@ -3770,8 +3802,8 @@ TEST(DecodeWithChunkedEncoding, BrotliEncoding) {
|
|||||||
TEST(HttpsToHttpRedirectTest2, SimpleInterface) {
|
TEST(HttpsToHttpRedirectTest2, SimpleInterface) {
|
||||||
Client cli("https://nghttp2.org");
|
Client cli("https://nghttp2.org");
|
||||||
cli.set_follow_location(true);
|
cli.set_follow_location(true);
|
||||||
auto res = cli.Get(
|
auto res =
|
||||||
"/httpbin/"
|
cli.Get("/httpbin/"
|
||||||
"redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
|
"redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user