Bound the size of an SSE event

The SSE client buffered a line, or the data of an event, with no limit
of its own, and with payload_max_length(0) with none at all. Add
CPPHTTPLIB_SSE_MAX_EVENT_LENGTH (16MB) and end the connection with
ExceedMaxPayloadSize past it.
This commit is contained in:
yhirose committed 2026-10-16 16:39:00 -04:00
1 parent f5e11024da
commit cadcc425b8
3 files changed
+44

No files matched your search

+2
View File
@@ -79,6 +79,8 @@ sse.set_max_reconnect_attempts(10);
sse.set_headers({{"Authorization", "Bearer new_token"}});
```
An event, or a line still waiting for its end, longer than `CPPHTTPLIB_SSE_MAX_EVENT_LENGTH` (16MB by default, `0` for no limit) ends the connection with `Error::ExceedMaxPayloadSize`, and the client reconnects as usual.
#### Control
```cpp