Refactoring: extracted is_compressible_mime_type()

This commit is contained in:
Veloman Yunkan 2020-04-16 13:58:15 +04:00
parent a058520628
commit 87cbbed9e3
1 changed files with 8 additions and 3 deletions

View File

@ -855,6 +855,13 @@ std::string get_mime_type(const kiwix::Entry& entry)
}
}
bool is_compressible_mime_type(const std::string& mimeType)
{
return mimeType.find("text/") != string::npos
|| mimeType.find("application/javascript") != string::npos
|| mimeType.find("application/json") != string::npos;
}
} // unnamed namespace
std::shared_ptr<Reader>
@ -918,9 +925,7 @@ Response InternalServer::handle_content(const RequestContext& request)
printf("mimeType: %s\n", mimeType.c_str());
}
if (mimeType.find("text/") != string::npos
|| mimeType.find("application/javascript") != string::npos
|| mimeType.find("application/json") != string::npos) {
if ( is_compressible_mime_type(mimeType) ) {
zim::Blob raw_content = entry.getBlob();
content = string(raw_content.data(), raw_content.size());
auto response = get_default_response();