mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
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:
1 parent
35342285a0
commit
ad6c851d19
3 files changed
+47
-6
No files matched your search
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user