diff --git a/firecgi b/firecgi index 8bd0813..b5b0cbd 160000 --- a/firecgi +++ b/firecgi @@ -1 +1 @@ -Subproject commit 8bd0813161fcb60871f415bd5b2512f2ec54b553 +Subproject commit b5b0cbd599aefa4f8243de1368858023c0a5de5c diff --git a/stream.cc b/stream.cc index ef89cd4..ededd93 100644 --- a/stream.cc +++ b/stream.cc @@ -6,15 +6,16 @@ Stream::Stream(firecgi::Request* request) : request_(request) {} bool Stream::WriteEvent(const std::string& data, uint64_t id, const std::string& type) { - if (id) { - request_->WriteBody("id: ", std::to_string(id), "\n"); - } - if (!type.empty()) { - request_->WriteBody("event: ", type, "\n"); - } - request_->WriteBody("data: ", data, "\n"); - - return request_->Flush(); + return request_->InTransaction([=]() { + if (id) { + request_->WriteBody("id: ", std::to_string(id), "\n"); + } + if (!type.empty()) { + request_->WriteBody("event: ", type, "\n"); + } + request_->WriteBody("data: ", data, "\n\n"); + return request_->Flush(); + }); } bool Stream::End() {