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
@ -12,8 +12,7 @@ using namespace std;
|
||||
|
||||
class EventDispatcher {
|
||||
public:
|
||||
EventDispatcher() {
|
||||
}
|
||||
EventDispatcher() {}
|
||||
|
||||
void wait_event(DataSink *sink) {
|
||||
unique_lock<mutex> lk(m_);
|
||||
|
17
httplib.h
17
httplib.h
@ -5987,9 +5987,9 @@ inline ssize_t Stream::write(const std::string &s) {
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline void calc_actual_timeout(time_t max_timeout_msec,
|
||||
time_t duration_msec, time_t timeout_sec,
|
||||
time_t timeout_usec, time_t &actual_timeout_sec,
|
||||
inline void calc_actual_timeout(time_t max_timeout_msec, time_t duration_msec,
|
||||
time_t timeout_sec, time_t timeout_usec,
|
||||
time_t &actual_timeout_sec,
|
||||
time_t &actual_timeout_usec) {
|
||||
auto timeout_msec = (timeout_sec * 1000) + (timeout_usec / 1000);
|
||||
|
||||
@ -8213,8 +8213,7 @@ inline bool ClientImpl::process_socket(
|
||||
std::function<bool(Stream &strm)> callback) {
|
||||
return detail::process_client_socket(
|
||||
socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
|
||||
write_timeout_usec_, max_timeout_msec_, start_time,
|
||||
std::move(callback));
|
||||
write_timeout_usec_, max_timeout_msec_, start_time, std::move(callback));
|
||||
}
|
||||
|
||||
inline bool ClientImpl::is_ssl() const { return false; }
|
||||
@ -9119,8 +9118,8 @@ inline bool process_client_socket_ssl(
|
||||
time_t max_timeout_msec,
|
||||
std::chrono::time_point<std::chrono::steady_clock> start_time, T callback) {
|
||||
SSLSocketStream strm(sock, ssl, read_timeout_sec, read_timeout_usec,
|
||||
write_timeout_sec, write_timeout_usec,
|
||||
max_timeout_msec, start_time);
|
||||
write_timeout_sec, write_timeout_usec, max_timeout_msec,
|
||||
start_time);
|
||||
return callback(strm);
|
||||
}
|
||||
|
||||
@ -9735,8 +9734,8 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {
|
||||
|
||||
auto type = GEN_DNS;
|
||||
|
||||
struct in6_addr addr6{};
|
||||
struct in_addr addr{};
|
||||
struct in6_addr addr6 = {};
|
||||
struct in_addr addr = {};
|
||||
size_t addr_len = 0;
|
||||
|
||||
#ifndef __MINGW32__
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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",
|
||||
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…
x
Reference in New Issue
Block a user