Run clang-format on httplib.h and test.cc

Fixes formatting introduced in 199d7ee and d5f8858 that clang-format
18.1.3 (the version used by CI) disagrees with.
This commit is contained in:
yhirose committed 2026-09-07 16:29:08 -04:00
1 parent d5f8858731
commit 6303a99ce1
2 files changed
+33 -34

No files matched your search

+3 -4
View File
@@ -4603,8 +4603,8 @@ private:
}; };
template <class Rep, class Period> template <class Rep, class Period>
inline void inline void WebSocket::set_read_timeout(
WebSocket::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) { const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec( detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); }); duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
} }
@@ -6402,8 +6402,7 @@ inline ssize_t select_impl(socket_t sock, short events, time_t sec,
// A negative timeout waits forever, poll's own convention. 0 keeps meaning // A negative timeout waits forever, poll's own convention. 0 keeps meaning
// "return immediately", which callers here rely on to probe a socket. // "return immediately", which callers here rely on to probe a socket.
auto timeout = auto timeout = sec < 0 ? -1 : static_cast<int>(sec * 1000 + usec / 1000);
sec < 0 ? -1 : static_cast<int>(sec * 1000 + usec / 1000);
return handle_EINTR([&]() { return poll_wrapper(&pfd, 1, timeout); }); return handle_EINTR([&]() { return poll_wrapper(&pfd, 1, timeout); });
} }
+30 -30
View File
@@ -22341,9 +22341,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// RSV2 set (0x20) // RSV2 set (0x20)
@@ -22353,9 +22353,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// RSV3 set (0x10) // RSV3 set (0x10)
@@ -22365,9 +22365,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// No RSV bits set - should succeed // No RSV bits set - should succeed
@@ -22377,9 +22377,9 @@ TEST(WebSocketTest, RSVBitsMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok); ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Text, opcode); EXPECT_EQ(ws::Opcode::Text, opcode);
EXPECT_EQ("Hello", payload); EXPECT_EQ("Hello", payload);
EXPECT_TRUE(fin); EXPECT_TRUE(fin);
@@ -22400,9 +22400,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// Close with FIN=0 - must be rejected // Close with FIN=0 - must be rejected
@@ -22415,9 +22415,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// Ping with payload_len=126 (extended length) - must be rejected // Ping with payload_len=126 (extended length) - must be rejected
@@ -22433,9 +22433,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// Ping with FIN=1 and payload_len=125 - should succeed // Ping with FIN=1 and payload_len=125 - should succeed
@@ -22449,9 +22449,9 @@ TEST(WebSocketTest, ControlFrameValidation) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok); ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Ping, opcode); EXPECT_EQ(ws::Opcode::Ping, opcode);
EXPECT_EQ(125u, payload.size()); EXPECT_EQ(125u, payload.size());
EXPECT_TRUE(fin); EXPECT_TRUE(fin);
@@ -22474,9 +22474,9 @@ TEST(WebSocketTest, PayloadLength64BitMSBMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Fail); ws::impl::FrameRead::Fail);
} }
// MSB clear - should pass length parsing (will be rejected by max_len, // MSB clear - should pass length parsing (will be rejected by max_len,
@@ -22493,9 +22493,9 @@ TEST(WebSocketTest, PayloadLength64BitMSBMustBeZero) {
ws::Opcode opcode; ws::Opcode opcode;
std::string payload; std::string payload;
bool fin; bool fin;
EXPECT_EQ(ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, EXPECT_EQ(
1024), ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 1024),
ws::impl::FrameRead::Ok); ws::impl::FrameRead::Ok);
EXPECT_EQ(ws::Opcode::Text, opcode); EXPECT_EQ(ws::Opcode::Text, opcode);
EXPECT_EQ("abc", payload); EXPECT_EQ("abc", payload);
} }