From b2d7316f8bd64a21e8ae3beaea3798fb10b68f95 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Thu, 28 Aug 2014 14:55:11 -0600 Subject: [PATCH] Small beautifications --- src/server/kiwix-serve.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index ee63267..f19bade 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -298,7 +298,7 @@ static int accessHandlerCallback(void *cls, /* If article found then redirect directly to it */ if (!patternCorrespondingUrl.empty()) { - httpRedirection="/" + humanReadableBookId + "/" + patternCorrespondingUrl; + httpRedirection = "/" + humanReadableBookId + "/" + patternCorrespondingUrl; } } @@ -335,17 +335,19 @@ static int accessHandlerCallback(void *cls, pthread_mutex_lock(&readerLock); randomUrl = reader->getRandomPageUrl(); pthread_mutex_unlock(&readerLock); - httpRedirection="/" + humanReadableBookId + "/" + randomUrl; + httpRedirection = "/" + humanReadableBookId + "/" + randomUrl; } } /* Display the content of a ZIM article */ else if (reader != NULL) { - pthread_mutex_lock(&readerLock); std::string baseUrl; try { + pthread_mutex_lock(&readerLock); found = reader->getContentByDecodedUrl(urlStr, content, contentLength, mimeType, baseUrl); + pthread_mutex_unlock(&readerLock); + if (found) { if (isVerbose()) { cout << "Found " << urlStr << endl; @@ -355,15 +357,14 @@ static int accessHandlerCallback(void *cls, } else { if (isVerbose()) cout << "Failed to find " << urlStr << endl; - - content = "\nContent not found

Not Found

The requested URL " + urlStr + " was not found on this server.

"; + + content = "\nContent not found

Not Found

The requested URL \"" + urlStr + "\" was not found on this server.

"; mimeType = "text/html"; httpResponseCode = MHD_HTTP_NOT_FOUND; } } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } - pthread_mutex_unlock(&readerLock); /* Special rewrite URL in case of ZIM file use intern *asbolute* url like /A/Kiwix */ if (mimeType.find("text/html") != string::npos) {