mirror of https://github.com/kiwix/libkiwix.git
Undefaulted bool params of ContentResponse::build()
This resulted in compiler aided discovery of all call sites where the default values were used. For OPDS/catalog requests now passing true for the `raw` parameter, since XML content isn't supposed to undergo any transformations.
This commit is contained in:
parent
c988511561
commit
eb0a45b13e
|
@ -823,7 +823,9 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
/*isHomePage =*/false,
|
/*isHomePage =*/false,
|
||||||
/*raw =*/true);
|
/*raw =*/true);
|
||||||
}
|
}
|
||||||
auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8");
|
auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8",
|
||||||
|
/*isHomePage =*/false,
|
||||||
|
/*raw =*/false);
|
||||||
// XXX: Now this has to be handled by the iframe-based viewer which
|
// 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.
|
// XXX: has to resolve if the book selection resulted in a single book.
|
||||||
/*
|
/*
|
||||||
|
@ -953,7 +955,9 @@ std::unique_ptr<Response> InternalServer::handle_catalog(const RequestContext& r
|
||||||
auto response = ContentResponse::build(
|
auto response = ContentResponse::build(
|
||||||
*this,
|
*this,
|
||||||
opdsDumper.dumpOPDSFeed(bookIdsToDump, request.get_query()),
|
opdsDumper.dumpOPDSFeed(bookIdsToDump, request.get_query()),
|
||||||
"application/atom+xml; profile=opds-catalog; kind=acquisition; charset=utf-8");
|
"application/atom+xml; profile=opds-catalog; kind=acquisition; charset=utf-8",
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true);
|
||||||
return std::move(response);
|
return std::move(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,9 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_entries(const Reques
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
*this,
|
*this,
|
||||||
opdsFeed,
|
opdsFeed,
|
||||||
"application/atom+xml;profile=opds-catalog;kind=acquisition"
|
"application/atom+xml;profile=opds-catalog;kind=acquisition",
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +125,9 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_complete_entry(const
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
*this,
|
*this,
|
||||||
opdsFeed,
|
opdsFeed,
|
||||||
"application/atom+xml;type=entry;profile=opds-catalog"
|
"application/atom+xml;type=entry;profile=opds-catalog",
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +139,9 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_categories(const Req
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
*this,
|
*this,
|
||||||
opdsDumper.categoriesOPDSFeed(),
|
opdsDumper.categoriesOPDSFeed(),
|
||||||
"application/atom+xml;profile=opds-catalog;kind=navigation"
|
"application/atom+xml;profile=opds-catalog;kind=navigation",
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +153,9 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_languages(const Requ
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
*this,
|
*this,
|
||||||
opdsDumper.languagesOPDSFeed(),
|
opdsDumper.languagesOPDSFeed(),
|
||||||
"application/atom+xml;profile=opds-catalog;kind=navigation"
|
"application/atom+xml;profile=opds-catalog;kind=navigation",
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +166,13 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_illustration(const R
|
||||||
auto book = mp_library->getBookByIdThreadSafe(bookId);
|
auto book = mp_library->getBookByIdThreadSafe(bookId);
|
||||||
auto size = request.get_argument<unsigned int>("size");
|
auto size = request.get_argument<unsigned int>("size");
|
||||||
auto illustration = book.getIllustration(size);
|
auto illustration = book.getIllustration(size);
|
||||||
return ContentResponse::build(*this, illustration->getData(), illustration->mimeType);
|
return ContentResponse::build(
|
||||||
|
*this,
|
||||||
|
illustration->getData(),
|
||||||
|
illustration->mimeType,
|
||||||
|
/*isHomePage*/ false,
|
||||||
|
/*raw*/ true
|
||||||
|
);
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
return HTTP404Response(*this, request)
|
return HTTP404Response(*this, request)
|
||||||
+ urlNotFoundMsg;
|
+ urlNotFoundMsg;
|
||||||
|
|
|
@ -448,7 +448,7 @@ std::unique_ptr<ContentResponse> ContentResponse::build(
|
||||||
const std::string& mimetype)
|
const std::string& mimetype)
|
||||||
{
|
{
|
||||||
auto content = render_template(template_str, data);
|
auto content = render_template(template_str, data);
|
||||||
return ContentResponse::build(server, content, mimetype);
|
return ContentResponse::build(server, content, mimetype, /*isHomePage*/false, /*raw*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange) :
|
ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange) :
|
||||||
|
|
|
@ -92,8 +92,8 @@ class ContentResponse : public Response {
|
||||||
const InternalServer& server,
|
const InternalServer& server,
|
||||||
const std::string& content,
|
const std::string& content,
|
||||||
const std::string& mimetype,
|
const std::string& mimetype,
|
||||||
bool isHomePage = false,
|
bool isHomePage,
|
||||||
bool raw = false);
|
bool raw);
|
||||||
|
|
||||||
static std::unique_ptr<ContentResponse> build(
|
static std::unique_ptr<ContentResponse> build(
|
||||||
const InternalServer& server,
|
const InternalServer& server,
|
||||||
|
|
Loading…
Reference in New Issue