diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 08cc36265..811f2760a 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -683,20 +683,17 @@ std::unique_ptr InternalServer::handle_search(const RequestContext& re } catch(std::runtime_error& e) { // Searcher->search will throw a runtime error if there is no valid xapian database to do the search. // (in case of zim file not containing a index) - auto response = std::move( - HTTPErrorHtmlResponse(*this, request, MHD_HTTP_NOT_FOUND, - "fulltext-search-unavailable", - "404-page-heading", - m_root + "/skin/search_results.css") - + nonParameterizedMessage("no-search-results") - ); + HTTPErrorHtmlResponse response(*this, request, MHD_HTTP_NOT_FOUND, + "fulltext-search-unavailable", + "404-page-heading", + m_root + "/skin/search_results.css"); + response += nonParameterizedMessage("no-search-results"); if(bookIds.size() == 1) { auto bookId = *bookIds.begin(); auto bookName = mp_nameMapper->getNameForId(bookId); - return response + TaskbarInfo(bookName, mp_library->getArchiveById(bookId).get()); - } else { - return response; + response += TaskbarInfo(bookName, mp_library->getArchiveById(bookId).get()); } + return response; } auto start = 0; diff --git a/src/server/internalServer.h b/src/server/internalServer.h index c5d29e8b4..e528e2236 100644 --- a/src/server/internalServer.h +++ b/src/server/internalServer.h @@ -148,7 +148,9 @@ class InternalServer { bool etag_not_needed(const RequestContext& r) const; ETag get_matching_if_none_match_etag(const RequestContext& request) const; - Library::BookIdSet selectBooks(const RequestContext& r, const std::string& prefix) const; + Library:: + + BookIdSet selectBooks(const RequestContext& r, const std::string& prefix) const; SearchInfo getSearchInfo(const RequestContext& r, const std::string& prefix) const; private: // data diff --git a/src/server/response.cpp b/src/server/response.cpp index 20a236020..7c893527a 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -150,6 +150,12 @@ HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+(const ParameterizedMessa return *this + details.getText(m_request.get_user_language()); } +HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+=(const ParameterizedMessage& details) +{ + // operator+() is already a state-modifying operator (akin to operator+=) + return *this + details; +} + HTTP400HtmlResponse::HTTP400HtmlResponse(const InternalServer& server, const RequestContext& request) @@ -202,6 +208,13 @@ ContentResponseBlueprint& ContentResponseBlueprint::operator+(const TaskbarInfo& return *this; } +ContentResponseBlueprint& ContentResponseBlueprint::operator+=(const TaskbarInfo& taskbarInfo) +{ + // operator+() is already a state-modifying operator (akin to operator+=) + return *this + taskbarInfo; +} + + std::unique_ptr Response::build_416(const InternalServer& server, size_t resourceLength) { auto response = Response::build(server); diff --git a/src/server/response.h b/src/server/response.h index 79f93b3eb..c8c4c73ea 100644 --- a/src/server/response.h +++ b/src/server/response.h @@ -168,6 +168,7 @@ class ContentResponseBlueprint ContentResponseBlueprint& operator+(const TaskbarInfo& taskbarInfo); + ContentResponseBlueprint& operator+=(const TaskbarInfo& taskbarInfo); protected: // functions std::string getMessage(const std::string& msgId) const; @@ -193,8 +194,10 @@ struct HTTPErrorHtmlResponse : ContentResponseBlueprint const std::string& cssUrl = ""); using ContentResponseBlueprint::operator+; + using ContentResponseBlueprint::operator+=; HTTPErrorHtmlResponse& operator+(const std::string& msg); HTTPErrorHtmlResponse& operator+(const ParameterizedMessage& errorDetails); + HTTPErrorHtmlResponse& operator+=(const ParameterizedMessage& errorDetails); }; class UrlNotFoundMsg {};