diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index d996c9ab..604d8503 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -727,8 +727,7 @@ std::unique_ptr InternalServer::handle_skin(const RequestContext& requ auto response = ContentResponse::build( *this, getResource(resourceName), - getMimeTypeForFile(resourceName), - /*raw=*/true); + getMimeTypeForFile(resourceName)); response->set_cacheable(); return std::move(response); } catch (const ResourceNotFound& e) { @@ -818,11 +817,9 @@ std::unique_ptr InternalServer::handle_search(const RequestContext& re renderer.setSearchProtocolPrefix(m_root + "/search"); renderer.setPageLength(pageLength); if (request.get_requested_format() == "xml") { - return ContentResponse::build(*this, renderer.getXml(), "application/rss+xml; charset=utf-8", - /*raw =*/true); + return ContentResponse::build(*this, renderer.getXml(), "application/rss+xml; charset=utf-8"); } - auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8", - /*raw =*/false); + auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8"); // XXX: Now this has to be handled by the iframe-based viewer which // XXX: has to resolve if the book selection resulted in a single book. /* @@ -952,8 +949,7 @@ std::unique_ptr InternalServer::handle_catalog(const RequestContext& r auto response = ContentResponse::build( *this, opdsDumper.dumpOPDSFeed(bookIdsToDump, request.get_query()), - "application/atom+xml; profile=opds-catalog; kind=acquisition; charset=utf-8", - /*raw*/ true); + "application/atom+xml; profile=opds-catalog; kind=acquisition; charset=utf-8"); return std::move(response); } @@ -1098,13 +1094,13 @@ std::unique_ptr InternalServer::handle_raw(const RequestContext& reque try { if (kind == "meta") { auto item = archive->getMetadataItem(itemPath); - return ItemResponse::build(*this, request, item, /*raw=*/true); + return ItemResponse::build(*this, request, item); } else { auto entry = archive->getEntryByPath(itemPath); if (entry.isRedirect()) { return build_redirect(bookName, entry.getItem(true)); } - return ItemResponse::build(*this, request, entry.getItem(), /*raw=*/true); + return ItemResponse::build(*this, request, entry.getItem()); } } catch (zim::EntryNotFound& e ) { if (m_verbose.load()) { @@ -1141,8 +1137,7 @@ std::unique_ptr InternalServer::handle_locally_customized_resource(con return ContentResponse::build(*this, resourceData, - crd.mimeType, - /*raw=*/true); + crd.mimeType); } } diff --git a/src/server/internalServer.h b/src/server/internalServer.h index ee2c2072..3e4943ad 100644 --- a/src/server/internalServer.h +++ b/src/server/internalServer.h @@ -183,8 +183,8 @@ class InternalServer { std::unique_ptr m_customizedResources; friend std::unique_ptr Response::build(const InternalServer& server); - friend std::unique_ptr ContentResponse::build(const InternalServer& server, const std::string& content, const std::string& mimetype, bool raw); - friend std::unique_ptr ItemResponse::build(const InternalServer& server, const RequestContext& request, const zim::Item& item, bool raw); + friend std::unique_ptr ContentResponse::build(const InternalServer& server, const std::string& content, const std::string& mimetype); + friend std::unique_ptr ItemResponse::build(const InternalServer& server, const RequestContext& request, const zim::Item& item); }; } diff --git a/src/server/internalServer_catalog_v2.cpp b/src/server/internalServer_catalog_v2.cpp index 842c2544..b082dd1c 100644 --- a/src/server/internalServer_catalog_v2.cpp +++ b/src/server/internalServer_catalog_v2.cpp @@ -103,8 +103,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_entries(const Reques return ContentResponse::build( *this, opdsFeed, - "application/atom+xml;profile=opds-catalog;kind=acquisition", - /*raw*/ true + "application/atom+xml;profile=opds-catalog;kind=acquisition" ); } @@ -124,8 +123,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_complete_entry(const return ContentResponse::build( *this, opdsFeed, - "application/atom+xml;type=entry;profile=opds-catalog", - /*raw*/ true + "application/atom+xml;type=entry;profile=opds-catalog" ); } @@ -137,8 +135,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_categories(const Req return ContentResponse::build( *this, opdsDumper.categoriesOPDSFeed(), - "application/atom+xml;profile=opds-catalog;kind=navigation", - /*raw*/ true + "application/atom+xml;profile=opds-catalog;kind=navigation" ); } @@ -150,8 +147,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_languages(const Requ return ContentResponse::build( *this, opdsDumper.languagesOPDSFeed(), - "application/atom+xml;profile=opds-catalog;kind=navigation", - /*raw*/ true + "application/atom+xml;profile=opds-catalog;kind=navigation" ); } @@ -165,8 +161,7 @@ std::unique_ptr InternalServer::handle_catalog_v2_illustration(const R return ContentResponse::build( *this, illustration->getData(), - illustration->mimeType, - /*raw*/ true + illustration->mimeType ); } catch(...) { return HTTP404Response(*this, request) diff --git a/src/server/response.cpp b/src/server/response.cpp index fab72b2c..7067ff20 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -233,11 +233,7 @@ HTTP500Response::HTTP500Response(const InternalServer& server, std::unique_ptr HTTP500Response::generateResponseObject() const { - // We want a 500 response to be a minimalistic one (so that the server doesn't - // have to provide additional resources required for its proper rendering) - // ";raw=true" in the MIME-type below disables response decoration - // (see ContentResponse::contentDecorationAllowed()) - const std::string mimeType = "text/html;charset=utf-8;raw=true"; + const std::string mimeType = "text/html;charset=utf-8"; auto r = ContentResponse::build(m_server, m_template, m_data, mimeType); r->set_code(m_httpStatusCode); return r; @@ -390,8 +386,7 @@ ContentResponse::ContentResponse(const std::string& root, bool verbose, const st std::unique_ptr ContentResponse::build( const InternalServer& server, const std::string& content, - const std::string& mimetype, - bool raw) + const std::string& mimetype) { return std::unique_ptr(new ContentResponse( server.m_root, @@ -407,7 +402,7 @@ std::unique_ptr ContentResponse::build( const std::string& mimetype) { auto content = render_template(template_str, data); - return ContentResponse::build(server, content, mimetype, /*raw*/false); + return ContentResponse::build(server, content, mimetype); } ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange) : @@ -420,14 +415,14 @@ ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::strin add_header(MHD_HTTP_HEADER_CONTENT_TYPE, m_mimeType); } -std::unique_ptr ItemResponse::build(const InternalServer& server, const RequestContext& request, const zim::Item& item, bool raw) +std::unique_ptr ItemResponse::build(const InternalServer& server, const RequestContext& request, const zim::Item& item) { const std::string mimetype = get_mime_type(item); auto byteRange = request.get_range().resolve(item.getSize()); const bool noRange = byteRange.kind() == ByteRange::RESOLVED_FULL_CONTENT; if (noRange && is_compressible_mime_type(mimetype)) { // Return a contentResponse - auto response = ContentResponse::build(server, item.getData(), mimetype, raw); + auto response = ContentResponse::build(server, item.getData(), mimetype); response->set_cacheable(); response->m_byteRange = byteRange; return std::move(response); diff --git a/src/server/response.h b/src/server/response.h index 6a114ba5..55c8fde4 100644 --- a/src/server/response.h +++ b/src/server/response.h @@ -89,8 +89,7 @@ class ContentResponse : public Response { static std::unique_ptr build( const InternalServer& server, const std::string& content, - const std::string& mimetype, - bool raw); + const std::string& mimetype); static std::unique_ptr build( const InternalServer& server, @@ -205,7 +204,7 @@ private: // overrides class ItemResponse : public Response { public: ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange); - static std::unique_ptr build(const InternalServer& server, const RequestContext& request, const zim::Item& item, bool raw = false); + static std::unique_ptr build(const InternalServer& server, const RequestContext& request, const zim::Item& item); private: MHD_Response* create_mhd_response(const RequestContext& request);