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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Fix premature close of async req on http/2
Kishore Nallan2d34bb66e6cc
diff --git a/src/http_server.cpp b/src/http_server.cppindex 8c635711..6e7f2252 100644--- a/src/http_server.cpp+++ b/src/http_server.cpp@@ -670,6 +670,27 @@ void HttpServer::stream_response(const std::shared_ptr<http_req>& request, consth2o_req_t* req = request->_req;h2o_custom_generator_t* custom_generator = reinterpret_cast<h2o_custom_generator_t *>(response->generator);+ if(custom_generator->rpath->async_req && custom_generator->res()->final &&+ !custom_generator->req()->last_chunk_aggregate) {+ // premature termination of async request: handle this explicitly as otherwise, request is not being closed+ LOG(INFO) << "Premature termination of async request.";++ req->res.status = response->status_code;+ req->res.reason = http_res::get_status_reason(response->status_code);+ h2o_iovec_t body = h2o_strdup(&req->pool, response->body.c_str(), SIZE_MAX);++ if(request->is_http_v1()) {+ h2o_start_response(req, &custom_generator->super);+ h2o_send(req, &body, 1, H2O_SEND_STATE_FINAL);+ h2o_dispose_request(req);+ } else {+ h2o_start_response(req, &custom_generator->super);+ h2o_send(req, &body, 1, H2O_SEND_STATE_ERROR);+ }++ return ;+ }+if (req->res.status == 0) {//LOG(INFO) << "h2o_start_response, content_type=" << response.content_type_header// << ",response.status_code=" << response.status_code;@@ -691,13 +712,6 @@ void HttpServer::stream_response(const std::shared_ptr<http_req>& request, constconst h2o_send_state_t state = custom_generator->res()->final ? H2O_SEND_STATE_FINAL : H2O_SEND_STATE_IN_PROGRESS;h2o_send(req, &body, 1, state);- if(custom_generator->rpath->async_req && custom_generator->res()->final &&- !custom_generator->req()->last_chunk_aggregate) {- // premature termination of async request: handle this explicitly as otherwise, request is not being closed- LOG(INFO) << "Premature termination of async request, disposing req object.";- h2o_dispose_request(req);- }-// LOG(INFO) << "stream_response after send";}