Skip to content

Commit 2996cec

Browse files
Fix code inconsistently formatted and re-format (#2063)
* Fix code inconsistently formatted by clang-format * Run clang-format
1 parent 32bf5c9 commit 2996cec

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

example/ssesvr.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ using namespace std;
1212

1313
class EventDispatcher {
1414
public:
15-
EventDispatcher() {
16-
}
15+
EventDispatcher() {}
1716

1817
void wait_event(DataSink *sink) {
1918
unique_lock<mutex> lk(m_);

httplib.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5987,9 +5987,9 @@ inline ssize_t Stream::write(const std::string &s) {
59875987

59885988
namespace detail {
59895989

5990-
inline void calc_actual_timeout(time_t max_timeout_msec,
5991-
time_t duration_msec, time_t timeout_sec,
5992-
time_t timeout_usec, time_t &actual_timeout_sec,
5990+
inline void calc_actual_timeout(time_t max_timeout_msec, time_t duration_msec,
5991+
time_t timeout_sec, time_t timeout_usec,
5992+
time_t &actual_timeout_sec,
59935993
time_t &actual_timeout_usec) {
59945994
auto timeout_msec = (timeout_sec * 1000) + (timeout_usec / 1000);
59955995

@@ -8213,8 +8213,7 @@ inline bool ClientImpl::process_socket(
82138213
std::function<bool(Stream &strm)> callback) {
82148214
return detail::process_client_socket(
82158215
socket.sock, read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
8216-
write_timeout_usec_, max_timeout_msec_, start_time,
8217-
std::move(callback));
8216+
write_timeout_usec_, max_timeout_msec_, start_time, std::move(callback));
82188217
}
82198218

82208219
inline bool ClientImpl::is_ssl() const { return false; }
@@ -9119,8 +9118,8 @@ inline bool process_client_socket_ssl(
91199118
time_t max_timeout_msec,
91209119
std::chrono::time_point<std::chrono::steady_clock> start_time, T callback) {
91219120
SSLSocketStream strm(sock, ssl, read_timeout_sec, read_timeout_usec,
9122-
write_timeout_sec, write_timeout_usec,
9123-
max_timeout_msec, start_time);
9121+
write_timeout_sec, write_timeout_usec, max_timeout_msec,
9122+
start_time);
91249123
return callback(strm);
91259124
}
91269125

@@ -9735,8 +9734,8 @@ SSLClient::verify_host_with_subject_alt_name(X509 *server_cert) const {
97359734

97369735
auto type = GEN_DNS;
97379736

9738-
struct in6_addr addr6{};
9739-
struct in_addr addr{};
9737+
struct in6_addr addr6 = {};
9738+
struct in_addr addr = {};
97409739
size_t addr_len = 0;
97419740

97429741
#ifndef __MINGW32__

test/test.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,9 +3553,11 @@ TEST_F(ServerTest, TooLongRequest) {
35533553
}
35543554

35553555
TEST_F(ServerTest, AlmostTooLongRequest) {
3556-
// test for #2046 - URI length check shouldn't include other content on req line
3557-
// URI is max URI length, minus 14 other chars in req line (GET, space, leading /, space, HTTP/1.1)
3558-
std::string request = "/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
3556+
// test for #2046 - URI length check shouldn't include other content on req
3557+
// line URI is max URI length, minus 14 other chars in req line (GET, space,
3558+
// leading /, space, HTTP/1.1)
3559+
std::string request =
3560+
"/" + string(CPPHTTPLIB_REQUEST_URI_MAX_LENGTH - 14, 'A');
35593561

35603562
auto res = cli_.Get(request.c_str());
35613563

@@ -8283,7 +8285,6 @@ TEST(MaxTimeoutTest, ContentStream) {
82838285
Client cli("localhost", PORT);
82848286
cli.set_max_timeout(std::chrono::milliseconds(timeout));
82858287

8286-
82878288
{
82888289
auto start = std::chrono::steady_clock::now();
82898290

@@ -8345,7 +8346,7 @@ TEST(MaxTimeoutTest, ContentStreamSSL) {
83458346
[&, data](size_t offset, size_t length, DataSink &sink) {
83468347
const size_t DATA_CHUNK_SIZE = 4;
83478348
const auto &d = *data;
8348-
std::this_thread::sleep_for(std::chrono::seconds(1));
8349+
std::this_thread::sleep_for(std::chrono::seconds(1));
83498350
sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE));
83508351
return true;
83518352
},

test/test_proxy.cc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
using namespace std;
66
using namespace httplib;
77

8-
template <typename T>
9-
void ProxyTest(T& cli, bool basic) {
8+
template <typename T> void ProxyTest(T &cli, bool basic) {
109
cli.set_proxy("localhost", basic ? 3128 : 3129);
1110
auto res = cli.Get("/httpbin/get");
1211
ASSERT_TRUE(res != nullptr);
@@ -38,7 +37,7 @@ TEST(ProxyTest, SSLDigest) {
3837
// ----------------------------------------------------------------------------
3938

4039
template <typename T>
41-
void RedirectProxyText(T& cli, const char *path, bool basic) {
40+
void RedirectProxyText(T &cli, const char *path, bool basic) {
4241
cli.set_proxy("localhost", basic ? 3128 : 3129);
4342
if (basic) {
4443
cli.set_proxy_basic_auth("hello", "world");
@@ -100,8 +99,7 @@ TEST(RedirectTest, YouTubeSSLDigest) {
10099

101100
// ----------------------------------------------------------------------------
102101

103-
template <typename T>
104-
void BaseAuthTestFromHTTPWatch(T& cli) {
102+
template <typename T> void BaseAuthTestFromHTTPWatch(T &cli) {
105103
cli.set_proxy("localhost", 3128);
106104
cli.set_proxy_basic_auth("hello", "world");
107105

@@ -112,19 +110,20 @@ void BaseAuthTestFromHTTPWatch(T& cli) {
112110
}
113111

114112
{
115-
auto res =
116-
cli.Get("/basic-auth/hello/world",
117-
{make_basic_authentication_header("hello", "world")});
113+
auto res = cli.Get("/basic-auth/hello/world",
114+
{make_basic_authentication_header("hello", "world")});
118115
ASSERT_TRUE(res != nullptr);
119-
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
116+
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
117+
res->body);
120118
EXPECT_EQ(StatusCode::OK_200, res->status);
121119
}
122120

123121
{
124122
cli.set_basic_auth("hello", "world");
125123
auto res = cli.Get("/basic-auth/hello/world");
126124
ASSERT_TRUE(res != nullptr);
127-
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
125+
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
126+
res->body);
128127
EXPECT_EQ(StatusCode::OK_200, res->status);
129128
}
130129

@@ -158,8 +157,7 @@ TEST(BaseAuthTest, SSL) {
158157
// ----------------------------------------------------------------------------
159158

160159
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
161-
template <typename T>
162-
void DigestAuthTestFromHTTPWatch(T& cli) {
160+
template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
163161
cli.set_proxy("localhost", 3129);
164162
cli.set_proxy_digest_auth("hello", "world");
165163

@@ -181,7 +179,8 @@ void DigestAuthTestFromHTTPWatch(T& cli) {
181179
for (auto path : paths) {
182180
auto res = cli.Get(path.c_str());
183181
ASSERT_TRUE(res != nullptr);
184-
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
182+
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
183+
res->body);
185184
EXPECT_EQ(StatusCode::OK_200, res->status);
186185
}
187186

@@ -216,8 +215,7 @@ TEST(DigestAuthTest, NoSSL) {
216215

217216
// ----------------------------------------------------------------------------
218217

219-
template <typename T>
220-
void KeepAliveTest(T& cli, bool basic) {
218+
template <typename T> void KeepAliveTest(T &cli, bool basic) {
221219
cli.set_proxy("localhost", basic ? 3128 : 3129);
222220
if (basic) {
223221
cli.set_proxy_basic_auth("hello", "world");
@@ -249,9 +247,10 @@ void KeepAliveTest(T& cli, bool basic) {
249247
"/httpbin/digest-auth/auth-int/hello/world/MD5",
250248
};
251249

252-
for (auto path: paths) {
250+
for (auto path : paths) {
253251
auto res = cli.Get(path.c_str());
254-
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res->body);
252+
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
253+
res->body);
255254
EXPECT_EQ(StatusCode::OK_200, res->status);
256255
}
257256
}

0 commit comments

Comments
 (0)