Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Fix follower streaming edge case.

Kishore Nallan9db05986d7b4
diff --git a/src/http_client.cpp b/src/http_client.cpp
index 66479b0a..04153b60 100644
--- a/src/http_client.cpp
+++ b/src/http_client.cpp
@@ -225,7 +225,8 @@ size_t HttpClient::curl_write_async(char *buffer, size_t size, size_t nmemb, voi
//LOG(INFO) << "curl_write_async response, res body size: " << req_res->res->body.size();
- req_res->server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, req_res);
+ async_req_res_t* async_req_res = new async_req_res_t(req_res->req, req_res->res, true);
+ req_res->server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, async_req_res);
// wait until response is sent
//LOG(INFO) << "Waiting on req_res " << req_res->res;
@@ -247,7 +248,8 @@ size_t HttpClient::curl_write_async_done(void *context, curl_socket_t item) {
req_res->res->body = "";
req_res->res->final = true;
- req_res->server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, req_res);
+ async_req_res_t* async_req_res = new async_req_res_t(req_res->req, req_res->res, true);
+ req_res->server->get_message_dispatcher()->send_message(HttpServer::STREAM_RESPONSE_MESSAGE, async_req_res);
// wait until final response is flushed or response object will be destroyed by caller
req_res->res->wait();
diff --git a/src/http_server.cpp b/src/http_server.cpp
index b865c839..e3d0fd9c 100644
--- a/src/http_server.cpp
+++ b/src/http_server.cpp
@@ -740,8 +740,8 @@ void HttpServer::stream_response(stream_response_state_t& state) {
h2o_start_response(req, state.generator);
}
- if(state.res_body.len == 0) {
- // without this, http streaming will break
+ if(state.res_body.len == 0 && state.send_state != H2O_SEND_STATE_FINAL) {
+ // without this guard, http streaming will break
return;
}