mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
Fix code inconsistently formatted and re-format (#2063)
* Fix code inconsistently formatted by clang-format * Run clang-format
This commit is contained in:
parent
32bf5c9c09
commit
2996cecee0
4 changed files with 31 additions and 33 deletions
11
test/test.cc
11
test/test.cc
|
@ -3553,9 +3553,11 @@ TEST_F(ServerTest, TooLongRequest) {
|
|||
}
|
||||
|
||||
TEST_F(ServerTest, AlmostTooLongRequest) {
|
||||
// test for #2046 - URI length check shouldn't include other content on req line
|
||||
// URI is max URI length, minus 14 other chars in req line (GET, space, leading /, space, HTTP/1.1)
|
||||
std::string request = "/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
|
||||
// test for #2046 - URI length check shouldn't include other content on req
|
||||
// line URI is max URI length, minus 14 other chars in req line (GET, space,
|
||||
// leading /, space, HTTP/1.1)
|
||||
std::string request =
|
||||
"/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
|
||||
|
||||
auto res = cli_.Get(request.c_str());
|
||||
|
||||
|
@ -8283,7 +8285,6 @@ TEST(MaxTimeoutTest, ContentStream) {
|
|||
Client cli("localhost", PORT);
|
||||
cli.set_max_timeout(std::chrono::milliseconds(timeout));
|
||||
|
||||
|
||||
{
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
|
@ -8345,7 +8346,7 @@ TEST(MaxTimeoutTest, ContentStreamSSL) {
|
|||
[&, data](size_t offset, size_t length, DataSink &sink) {
|
||||
const size_t DATA_CHUNK_SIZE = 4;
|
||||
const auto &d = *data;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE));
|
||||
return true;
|
||||
},
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
using namespace std;
|
||||
using namespace httplib;
|
||||
|
||||
template <typename T>
|
||||
void ProxyTest(T& cli, bool basic) {
|
||||
template <typename T> void ProxyTest(T &cli, bool basic) {
|
||||
cli.set_proxy("localhost", basic ? 3128 : 3129);
|
||||
auto res = cli.Get("/httpbin/get");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
|
@ -38,7 +37,7 @@ TEST(ProxyTest, SSLDigest) {
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
void RedirectProxyText(T& cli, const char *path, bool basic) {
|
||||
void RedirectProxyText(T &cli, const char *path, bool basic) {
|
||||
cli.set_proxy("localhost", basic ? 3128 : 3129);
|
||||
if (basic) {
|
||||
cli.set_proxy_basic_auth("hello", "world");
|
||||
|
@ -100,8 +99,7 @@ TEST(RedirectTest, YouTubeSSLDigest) {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
void BaseAuthTestFromHTTPWatch(T& cli) {
|
||||
template <typename T> void BaseAuthTestFromHTTPWatch(T &cli) {
|
||||
cli.set_proxy("localhost", 3128);
|
||||
cli.set_proxy_basic_auth("hello", "world");
|
||||
|
||||
|
@ -112,11 +110,11 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
|
|||
}
|
||||
|
||||
{
|
||||
auto res =
|
||||
cli.Get("/basic-auth/hello/world",
|
||||
{make_basic_authentication_header("hello", "world")});
|
||||
auto res = cli.Get("/basic-auth/hello/world",
|
||||
{make_basic_authentication_header("hello", "world")});
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
|
||||
res->body);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
|
@ -124,7 +122,8 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
|
|||
cli.set_basic_auth("hello", "world");
|
||||
auto res = cli.Get("/basic-auth/hello/world");
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
|
||||
res->body);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
|
@ -158,8 +157,7 @@ TEST(BaseAuthTest, SSL) {
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
template <typename T>
|
||||
void DigestAuthTestFromHTTPWatch(T& cli) {
|
||||
template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
|
||||
cli.set_proxy("localhost", 3129);
|
||||
cli.set_proxy_digest_auth("hello", "world");
|
||||
|
||||
|
@ -181,7 +179,8 @@ void DigestAuthTestFromHTTPWatch(T& cli) {
|
|||
for (auto path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
|
||||
res->body);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
|
@ -216,8 +215,7 @@ TEST(DigestAuthTest, NoSSL) {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
void KeepAliveTest(T& cli, bool basic) {
|
||||
template <typename T> void KeepAliveTest(T &cli, bool basic) {
|
||||
cli.set_proxy("localhost", basic ? 3128 : 3129);
|
||||
if (basic) {
|
||||
cli.set_proxy_basic_auth("hello", "world");
|
||||
|
@ -249,9 +247,10 @@ void KeepAliveTest(T& cli, bool basic) {
|
|||
"/httpbin/digest-auth/auth-int/hello/world/MD5",
|
||||
};
|
||||
|
||||
for (auto path: paths) {
|
||||
for (auto path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
|
||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
|
||||
res->body);
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue