mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
Treat a zero WebSocket payload limit as none
CPPHTTPLIB_WEBSOCKET_MAX_PAYLOAD_LENGTH = 0 rejected every frame with a payload, while 0 means no limit for payload_max_length. Make it mean the same here, and refuse a length that size_t cannot hold.
This commit is contained in:
1 parent
194f392417
commit
0116be0a2b
3 files changed
+28
-3
No files matched your search
@@ -25811,6 +25811,26 @@ TEST(WebSocketFrameTest, MultiByteFieldsSplitAcrossReads) {
|
||||
EXPECT_EQ(payload, body);
|
||||
}
|
||||
|
||||
TEST(WebSocketFrameTest, ZeroMaxLenMeansNoLimit) {
|
||||
std::string body(2000, 'x');
|
||||
std::string frame;
|
||||
frame += static_cast<char>(0x82); // FIN + Binary
|
||||
frame += static_cast<char>(126); // 16-bit length follows
|
||||
frame += static_cast<char>(body.size() >> 8);
|
||||
frame += static_cast<char>(body.size() & 0xff);
|
||||
frame += body;
|
||||
|
||||
detail::BufferStream strm;
|
||||
strm.write(frame.data(), frame.size());
|
||||
ws::Opcode opcode;
|
||||
std::string payload;
|
||||
bool fin;
|
||||
EXPECT_EQ(
|
||||
ws::impl::read_websocket_frame(strm, opcode, payload, fin, false, 0),
|
||||
ws::impl::FrameRead::Ok);
|
||||
EXPECT_EQ(body, payload);
|
||||
}
|
||||
|
||||
TEST(WebSocketFrameTest, PayloadGrowsOnlyAsItArrives) {
|
||||
// The header announces the largest payload allowed, and only 3 bytes of it
|
||||
// ever arrive.
|
||||
|
||||
Reference in new issue
Block a user