mirror of https://github.com/kiwix/libkiwix.git
Do not make unnecessary copy when serving binary content.
Binary content do not need to be modified, so we don't need to copy it. We can directly serve it from the internal zim (cluster) buffer. The handle_content function now getArticleObjectByDecodedUrl instead of getContentByDecodedUrl. This is to get the mimetype of the article and copy the content only when needed (getContentByDecodedUrl always copy the content). Thus, handle_content is a bit more complex as it need to do some manipulation previously made in getContentByDecodedUrl. The main change is that if the content is binary, we serve the content with a callback response who will get the content chunks directly from the blob buffer.
This commit is contained in:
parent
e950ad3a0c
commit
82cba79179
|
@ -81,6 +81,7 @@ namespace kiwix {
|
|||
bool parseUrl(const string &url, char *ns, string &title);
|
||||
unsigned int getFileSize();
|
||||
zim::File* getZimFileHandler();
|
||||
bool getArticleObjectByDecodedUrl(const string &url, zim::Article &article);
|
||||
|
||||
protected:
|
||||
zim::File* zimFileHandler;
|
||||
|
@ -95,7 +96,6 @@ namespace kiwix {
|
|||
|
||||
private:
|
||||
std::map<std::string, unsigned int> parseCounterMetadata();
|
||||
bool getArticleObjectByDecodedUrl(const string &url, zim::Article &article);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue