minor refactoring and Content-Type header

This commit is contained in:
Christophe Fajardo
2022-01-20 18:10:30 +01:00
parent a9bbadf8ad
commit abf2a5ea4e
3 changed files with 16 additions and 12 deletions

View File

@@ -766,10 +766,12 @@ void appasset(resp_https_t response, req_https_t request) {
print_req<SimpleWeb::HTTPS>(request);
auto args = request->parse_query_string();
auto app_image = proc::proc.get_app_image(util::from_view(args.at("appid")));
auto [ app_image, image_content_type ] = proc::proc.get_app_image(util::from_view(args.at("appid")));
std::ifstream in(app_image, std::ios::binary);
response->write(SimpleWeb::StatusCode::success_ok, in);
SimpleWeb::CaseInsensitiveMultimap headers;
headers.emplace("Content-Type", image_content_type);
response->write(SimpleWeb::StatusCode::success_ok, in, headers);
response->close_connection_after_response = true;
}