Spaces:
Sleeping
Sleeping
Dmitry Beresnev commited on
Commit ·
d211568
1
Parent(s): 057edf0
fix encoding
Browse files- cpp/llm_manager.cpp +8 -1
cpp/llm_manager.cpp
CHANGED
|
@@ -306,6 +306,7 @@ struct ProxiedGetResult {
|
|
| 306 |
int status = 500;
|
| 307 |
std::string body;
|
| 308 |
std::string content_type = "text/plain; charset=utf-8";
|
|
|
|
| 309 |
};
|
| 310 |
|
| 311 |
static ProxiedGetResult forward_get_to_worker(const WorkerInfo &worker,
|
|
@@ -319,7 +320,7 @@ static ProxiedGetResult forward_get_to_worker(const WorkerInfo &worker,
|
|
| 319 |
http::request<http::string_body> req{http::verb::get, target, 11};
|
| 320 |
req.set(http::field::host, "127.0.0.1");
|
| 321 |
req.set(http::field::user_agent, "llm-manager");
|
| 322 |
-
req.set(http::field::accept_encoding, "identity");
|
| 323 |
http::write(stream, req);
|
| 324 |
|
| 325 |
beast::flat_buffer buffer;
|
|
@@ -333,6 +334,9 @@ static ProxiedGetResult forward_get_to_worker(const WorkerInfo &worker,
|
|
| 333 |
if (res.base().find(http::field::content_type) != res.base().end()) {
|
| 334 |
out.content_type = res.base()[http::field::content_type].to_string();
|
| 335 |
}
|
|
|
|
|
|
|
|
|
|
| 336 |
return out;
|
| 337 |
}
|
| 338 |
|
|
@@ -433,6 +437,9 @@ http::response<http::string_body> handle_request(
|
|
| 433 |
http::response<http::string_body> res{
|
| 434 |
static_cast<http::status>(upstream.status), req.version()};
|
| 435 |
res.set(http::field::content_type, upstream.content_type);
|
|
|
|
|
|
|
|
|
|
| 436 |
res.set(http::field::server, "llm-manager");
|
| 437 |
res.keep_alive(req.keep_alive());
|
| 438 |
res.body() = upstream.body;
|
|
|
|
| 306 |
int status = 500;
|
| 307 |
std::string body;
|
| 308 |
std::string content_type = "text/plain; charset=utf-8";
|
| 309 |
+
std::string content_encoding;
|
| 310 |
};
|
| 311 |
|
| 312 |
static ProxiedGetResult forward_get_to_worker(const WorkerInfo &worker,
|
|
|
|
| 320 |
http::request<http::string_body> req{http::verb::get, target, 11};
|
| 321 |
req.set(http::field::host, "127.0.0.1");
|
| 322 |
req.set(http::field::user_agent, "llm-manager");
|
| 323 |
+
req.set(http::field::accept_encoding, "gzip, identity");
|
| 324 |
http::write(stream, req);
|
| 325 |
|
| 326 |
beast::flat_buffer buffer;
|
|
|
|
| 334 |
if (res.base().find(http::field::content_type) != res.base().end()) {
|
| 335 |
out.content_type = res.base()[http::field::content_type].to_string();
|
| 336 |
}
|
| 337 |
+
if (res.base().find(http::field::content_encoding) != res.base().end()) {
|
| 338 |
+
out.content_encoding = res.base()[http::field::content_encoding].to_string();
|
| 339 |
+
}
|
| 340 |
return out;
|
| 341 |
}
|
| 342 |
|
|
|
|
| 437 |
http::response<http::string_body> res{
|
| 438 |
static_cast<http::status>(upstream.status), req.version()};
|
| 439 |
res.set(http::field::content_type, upstream.content_type);
|
| 440 |
+
if (!upstream.content_encoding.empty()) {
|
| 441 |
+
res.set(http::field::content_encoding, upstream.content_encoding);
|
| 442 |
+
}
|
| 443 |
res.set(http::field::server, "llm-manager");
|
| 444 |
res.keep_alive(req.keep_alive());
|
| 445 |
res.body() = upstream.body;
|