From d8a924121bb1740cd484042fa69e09a9dc2db12c Mon Sep 17 00:00:00 2001 From: Kelson42 Date: Sun, 14 Sep 2014 18:40:39 +0200 Subject: [PATCH] + more robus mimetype retrieving --- src/common/kiwix/reader.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index a7759ba97..d1b5c0eab 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -421,14 +421,21 @@ namespace kiwix { article = article.getRedirectArticle(); } - /* Compute base url (might be different from the url if redirects */ - baseUrl = "/" + std::string(1, article.getNamespace()) + "/" + article.getUrl(); - - /* Get the content mime-type */ - contentType = string(article.getMimeType().data(), article.getMimeType().size()); + if (loopCounter < 42) { + /* Compute base url (might be different from the url if redirects */ + baseUrl = "/" + std::string(1, article.getNamespace()) + "/" + article.getUrl(); + + /* Get the content mime-type */ + try { + contentType = string(article.getMimeType().data(), article.getMimeType().size()); + } catch (exception &e) { + cerr << "Unable to get the mimetype for "<< baseUrl<< ":" << e.what() << endl; + contentType = "application/octet-stream"; + } - /* Get the data */ - content = string(article.getData().data(), article.getArticleSize()); + /* Get the data */ + content = string(article.getData().data(), article.getArticleSize()); + } /* Try to set a stub HTML header/footer if necesssary */ if (contentType.find("text/html") != string::npos &&