mirror of https://github.com/kiwix/libkiwix.git
Refactoring: got rid of duplicate get_mime_type()
This commit is contained in:
parent
81e781133d
commit
bfa51c2d87
|
@ -844,15 +844,6 @@ std::string get_book_name(const RequestContext& request)
|
|||
}
|
||||
}
|
||||
|
||||
std::string get_mime_type(const kiwix::Entry& entry)
|
||||
{
|
||||
try {
|
||||
return entry.getMimetype();
|
||||
} catch (exception& e) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
std::shared_ptr<Reader>
|
||||
|
@ -912,18 +903,16 @@ Response InternalServer::handle_content(const RequestContext& request)
|
|||
return build_404(request, bookName);
|
||||
}
|
||||
|
||||
const std::string mimeType = get_mime_type(entry);
|
||||
|
||||
if (m_verbose.load()) {
|
||||
printf("Found %s\n", urlStr.c_str());
|
||||
printf("mimeType: %s\n", mimeType.c_str());
|
||||
}
|
||||
|
||||
auto response = get_default_response();
|
||||
|
||||
response.set_entry(entry, request);
|
||||
|
||||
if (mimeType.find("text/html") != string::npos)
|
||||
if (m_verbose.load()) {
|
||||
printf("Found %s\n", entry.getPath().c_str());
|
||||
printf("mimeType: %s\n", response.get_mimeType().c_str());
|
||||
}
|
||||
|
||||
if (response.get_mimeType().find("text/html") != string::npos)
|
||||
response.set_taskbar(bookName, reader->getTitle());
|
||||
|
||||
return response;
|
||||
|
|
|
@ -62,6 +62,7 @@ class Response {
|
|||
void set_range_len(uint64_t len) { m_lenRange = len; }
|
||||
|
||||
int getReturnCode() { return m_returnCode; }
|
||||
std::string get_mimeType() const { return m_mimeType; }
|
||||
|
||||
void introduce_taskbar();
|
||||
void inject_externallinks_blocker();
|
||||
|
|
Loading…
Reference in New Issue