Bound an SSE stream by event only

An event stream has no end, but the client's payload_max_length, 100MB
by default, cut it and made the client reconnect. SSEClient lifts that
limit for its stream; each event stays bounded by
CPPHTTPLIB_SSE_MAX_EVENT_LENGTH.
This commit is contained in:
yhirose committed 2026-10-16 21:38:40 -04:00
1 parent 35342285a0
commit ad6c851d19
3 files changed
+47 -6

No files matched your search

+10 -2
View File
@@ -593,6 +593,10 @@ namespace ws {
class WebSocket;
} // namespace ws
namespace sse {
class SSEClient;
} // namespace sse
namespace detail {
/*
@@ -2752,6 +2756,7 @@ public:
private:
friend class ClientImpl;
friend class sse::SSEClient;
ssize_t read_with_decompression(char *buf, size_t len);
@@ -5020,8 +5025,11 @@ inline void SSEClient::run_event_loop() {
request_headers.emplace("Last-Event-ID", last_event_id_);
}
// Open streaming connection
auto result = stream::Get(client_, path_, request_headers);
// Open streaming connection. An event stream has no end, so each event is
// bounded instead of the whole body.
auto handle = client_.open_stream("GET", path_, {}, request_headers);
handle.body_reader_.payload_max_length = 0;
stream::Result result{std::move(handle)};
// Connection error handling
if (!result) {