1
0
mirror of synced 2025-04-19 00:24:02 +03:00

Fix code inconsistently formatted and re-format (#2063)

* Fix code inconsistently formatted by clang-format

* Run clang-format
This commit is contained in:
Florian Albrechtskirchinger 2025-02-17 18:14:02 +01:00 committed by GitHub
parent 32bf5c9c09
commit 2996cecee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 33 deletions

View File

@ -12,8 +12,7 @@ using namespace std;
class EventDispatcher { class EventDispatcher {
public: public:
EventDispatcher() { EventDispatcher() {}
}
void wait_event(DataSink *sink) { void wait_event(DataSink *sink) {
unique_lock<mutex> lk(m_); unique_lock<mutex> lk(m_);

View File

@ -5987,9 +5987,9 @@ inline ssize_t Stream::write(const std::string &s) {
namespace detail { namespace detail {
inline void calc_actual_timeout(time_t max_timeout_msec, inline void calc_actual_timeout(time_t max_timeout_msec, time_t duration_msec,
time_t duration_msec, time_t timeout_sec, time_t timeout_sec, time_t timeout_usec,
time_t timeout_usec, time_t &actual_timeout_sec, time_t &actual_timeout_sec,
time_t &actual_timeout_usec) { time_t &actual_timeout_usec) {
auto timeout_msec = (timeout_sec * 1000) + (timeout_usec / 1000); auto timeout_msec = (timeout_sec * 1000) + (timeout_usec / 1000);
@ -8213,8 +8213,7 @@ inline bool ClientImpl::process_socket(
std::function<bool(Stream &strm)> callback) { std::function<bool(Stream &strm)> callback) {
return detail::process_client_socket( return detail::process_client_socket(
socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_, socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
write_timeout_usec_, max_timeout_msec_, start_time, write_timeout_usec_, max_timeout_msec_, start_time, std::move(callback));
std::move(callback));
} }
inline bool ClientImpl::is_ssl() const { return false; } inline bool ClientImpl::is_ssl() const { return false; }
@ -9119,8 +9118,8 @@ inline bool process_client_socket_ssl(
time_t max_timeout_msec, time_t max_timeout_msec,
std::chrono::time_point<std::chrono::steady_clock> start_time, T callback) { std::chrono::time_point<std::chrono::steady_clock> start_time, T callback) {
SSLSocketStream strm(sock, ssl, read_timeout_sec, read_timeout_usec, SSLSocketStream strm(sock, ssl, read_timeout_sec, read_timeout_usec,
write_timeout_sec, write_timeout_usec, write_timeout_sec, write_timeout_usec, max_timeout_msec,
max_timeout_msec, start_time); start_time);
return callback(strm); return callback(strm);
} }
@ -9735,8 +9734,8 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {
auto type = GEN_DNS; auto type = GEN_DNS;
struct in6_addr addr6{}; struct in6_addr addr6 = {};
struct in_addr addr{}; struct in_addr addr = {};
size_t addr_len = 0; size_t addr_len = 0;
#ifndef __MINGW32__ #ifndef __MINGW32__

View File

@ -3553,9 +3553,11 @@ TEST_F(ServerTest, TooLongRequest) {
} }
TEST_F(ServerTest, AlmostTooLongRequest) { TEST_F(ServerTest, AlmostTooLongRequest) {
// test for #2046 - URI length check shouldn't include other content on req line // test for #2046 - URI length check shouldn't include other content on req
// URI is max URI length, minus 14 other chars in req line (GET, space, leading /, space, HTTP/1.1) // line URI is max URI length, minus 14 other chars in req line (GET, space,
std::string request = "/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A'); // leading /, space, HTTP/1.1)
std::string request =
"/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
auto res = cli_.Get(request.c_str()); auto res = cli_.Get(request.c_str());
@ -8283,7 +8285,6 @@ TEST(MaxTimeoutTest, ContentStream) {
Client cli("localhost", PORT); Client cli("localhost", PORT);
cli.set_max_timeout(std::chrono::milliseconds(timeout)); cli.set_max_timeout(std::chrono::milliseconds(timeout));
{ {
auto start = std::chrono::steady_clock::now(); auto start = std::chrono::steady_clock::now();

View File

@ -5,8 +5,7 @@
using namespace std; using namespace std;
using namespace httplib; using namespace httplib;
template <typename T> template <typename T> void ProxyTest(T &cli, bool basic) {
void ProxyTest(T& cli, bool basic) {
cli.set_proxy("localhost", basic ? 3128 : 3129); cli.set_proxy("localhost", basic ? 3128 : 3129);
auto res = cli.Get("/httpbin/get"); auto res = cli.Get("/httpbin/get");
ASSERT_TRUE(res != nullptr); ASSERT_TRUE(res != nullptr);
@ -100,8 +99,7 @@ TEST(RedirectTest, YouTubeSSLDigest) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
template <typename T> template <typename T> void BaseAuthTestFromHTTPWatch(T &cli) {
void BaseAuthTestFromHTTPWatch(T& cli) {
cli.set_proxy("localhost", 3128); cli.set_proxy("localhost", 3128);
cli.set_proxy_basic_auth("hello", "world"); cli.set_proxy_basic_auth("hello", "world");
@ -112,11 +110,11 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
} }
{ {
auto res = auto res = cli.Get("/basic-auth/hello/world",
cli.Get("/basic-auth/hello/world",
{make_basic_authentication_header("hello", "world")}); {make_basic_authentication_header("hello", "world")});
ASSERT_TRUE(res != nullptr); 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); EXPECT_EQ(StatusCode::OK_200, res->status);
} }
@ -124,7 +122,8 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
cli.set_basic_auth("hello", "world"); cli.set_basic_auth("hello", "world");
auto res = cli.Get("/basic-auth/hello/world"); auto res = cli.Get("/basic-auth/hello/world");
ASSERT_TRUE(res != nullptr); 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); EXPECT_EQ(StatusCode::OK_200, res->status);
} }
@ -158,8 +157,7 @@ TEST(BaseAuthTest, SSL) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
template <typename T> template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
void DigestAuthTestFromHTTPWatch(T& cli) {
cli.set_proxy("localhost", 3129); cli.set_proxy("localhost", 3129);
cli.set_proxy_digest_auth("hello", "world"); cli.set_proxy_digest_auth("hello", "world");
@ -181,7 +179,8 @@ void DigestAuthTestFromHTTPWatch(T& cli) {
for (auto path : paths) { for (auto path : paths) {
auto res = cli.Get(path.c_str()); auto res = cli.Get(path.c_str());
ASSERT_TRUE(res != nullptr); 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); EXPECT_EQ(StatusCode::OK_200, res->status);
} }
@ -216,8 +215,7 @@ TEST(DigestAuthTest, NoSSL) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
template <typename T> template <typename T> void KeepAliveTest(T &cli, bool basic) {
void KeepAliveTest(T& cli, bool basic) {
cli.set_proxy("localhost", basic ? 3128 : 3129); cli.set_proxy("localhost", basic ? 3128 : 3129);
if (basic) { if (basic) {
cli.set_proxy_basic_auth("hello", "world"); cli.set_proxy_basic_auth("hello", "world");
@ -251,7 +249,8 @@ void KeepAliveTest(T& cli, bool basic) {
for (auto path : paths) { for (auto path : paths) {
auto res = cli.Get(path.c_str()); 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); EXPECT_EQ(StatusCode::OK_200, res->status);
} }
} }