mirror of https://github.com/kiwix/libkiwix.git
Refactoring: extracted is_compressible_mime_type()
This commit is contained in:
parent
a058520628
commit
87cbbed9e3
|
@ -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
|
} // unnamed namespace
|
||||||
|
|
||||||
std::shared_ptr<Reader>
|
std::shared_ptr<Reader>
|
||||||
|
@ -918,9 +925,7 @@ Response InternalServer::handle_content(const RequestContext& request)
|
||||||
printf("mimeType: %s\n", mimeType.c_str());
|
printf("mimeType: %s\n", mimeType.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mimeType.find("text/") != string::npos
|
if ( is_compressible_mime_type(mimeType) ) {
|
||||||
|| mimeType.find("application/javascript") != string::npos
|
|
||||||
|| mimeType.find("application/json") != string::npos) {
|
|
||||||
zim::Blob raw_content = entry.getBlob();
|
zim::Blob raw_content = entry.getBlob();
|
||||||
content = string(raw_content.data(), raw_content.size());
|
content = string(raw_content.data(), raw_content.size());
|
||||||
auto response = get_default_response();
|
auto response = get_default_response();
|
||||||
|
|
Loading…
Reference in New Issue