Skip to content

Commit 4f7dc9e

Browse files
committed
client should backoff when receiving final chunk
1 parent 1e780ce commit 4f7dc9e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

contract-tests/sse-contract-tests/src/event_outbox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ EventOutbox::RequestType EventOutbox::build_request(
6767
RequestType req;
6868

6969
req.set(http::field::host, callback_host_);
70-
req.method(http::verb::get);
70+
req.method(http::verb::post);
7171
req.target(callback_url_ + "/" + std::to_string(counter));
7272

7373
nlohmann::json json;

libs/server-sent-events/src/client.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ class FoxyClient : public Client,
303303
logger_("read HTTP response body aborted (shutting down)");
304304
return;
305305
}
306+
if (body_parser_->is_done()) {
307+
// The server can indicate that the chunk encoded response is done
308+
// by sending a final chunk + CRLF. The body parser will have
309+
// detected this. The correct response is to attempt to reconnect.
310+
return do_backoff("receiving final chunk");
311+
}
306312
if (!ec) {
307313
log_and_update_last_read(amount);
308314
return session_->async_read_some(

0 commit comments

Comments
 (0)