mirror of https://github.com/kiwix/libkiwix.git
Refactoring: extracted get_mime_type()
This commit is contained in:
parent
1ef5ebfb52
commit
a058520628
|
@ -846,6 +846,15 @@ 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
|
} // unnamed namespace
|
||||||
|
|
||||||
std::shared_ptr<Reader>
|
std::shared_ptr<Reader>
|
||||||
|
@ -866,9 +875,7 @@ Response InternalServer::handle_content(const RequestContext& request)
|
||||||
printf("** running handle_content\n");
|
printf("** running handle_content\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string baseUrl;
|
|
||||||
std::string content;
|
std::string content;
|
||||||
std::string mimeType;
|
|
||||||
|
|
||||||
kiwix::Entry entry;
|
kiwix::Entry entry;
|
||||||
|
|
||||||
|
@ -904,11 +911,7 @@ Response InternalServer::handle_content(const RequestContext& request)
|
||||||
return build_404(request, bookName);
|
return build_404(request, bookName);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const std::string mimeType = get_mime_type(entry);
|
||||||
mimeType = entry.getMimetype();
|
|
||||||
} catch (exception& e) {
|
|
||||||
mimeType = "application/octet-stream";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_verbose.load()) {
|
if (m_verbose.load()) {
|
||||||
printf("Found %s\n", urlStr.c_str());
|
printf("Found %s\n", urlStr.c_str());
|
||||||
|
|
Loading…
Reference in New Issue