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

Set import response content type as text/plain.

kishorencfd81cbb9767b
diff --git a/src/core_api.cpp b/src/core_api.cpp
index e7c75131..22956bcf 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -605,6 +605,7 @@ bool post_import_documents(http_req & req, http_res & res) {
}
}
+ res.content_type_header = "text/plain; charset=utf8";
res.set_200(ss.str());
return true;
}
diff --git a/src/http_server.cpp b/src/http_server.cpp
index 2b8b6dc1..74a732a5 100644
--- a/src/http_server.cpp
+++ b/src/http_server.cpp
@@ -410,7 +410,8 @@ void HttpServer::send_response(http_req* request, const http_res* response) {
h2o_iovec_t body = h2o_strdup(&req->pool, response->body.c_str(), SIZE_MAX);
req->res.status = response->status_code;
req->res.reason = http_res::get_status_reason(response->status_code);
- h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE, nullptr, H2O_STRLIT("application/json; charset=utf-8"));
+ h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE,
+ nullptr, response->content_type_header.c_str(), response->content_type_header.size());
h2o_start_response(req, &generator);
h2o_send(req, &body, 1, H2O_SEND_STATE_FINAL);