mirror of https://github.com/kiwix/libkiwix.git
More uses of HTTP404HtmlResponse
This commit is contained in:
parent
1a5e2eda0f
commit
d5ae92e4e2
|
@ -278,8 +278,10 @@ MHD_Result InternalServer::handlerCallback(struct MHD_Connection* connection,
|
||||||
std::unique_ptr<Response> InternalServer::handle_request(const RequestContext& request)
|
std::unique_ptr<Response> InternalServer::handle_request(const RequestContext& request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (! request.is_valid_url())
|
if (! request.is_valid_url()) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
|
}
|
||||||
|
|
||||||
const ETag etag = get_matching_if_none_match_etag(request);
|
const ETag etag = get_matching_if_none_match_etag(request);
|
||||||
if ( etag )
|
if ( etag )
|
||||||
|
@ -476,7 +478,8 @@ std::unique_ptr<Response> InternalServer::handle_skin(const RequestContext& requ
|
||||||
response->set_cacheable();
|
response->set_cacheable();
|
||||||
return std::move(response);
|
return std::move(response);
|
||||||
} catch (const ResourceNotFound& e) {
|
} catch (const ResourceNotFound& e) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,8 +639,10 @@ std::unique_ptr<Response> InternalServer::handle_captured_external(const Request
|
||||||
source = kiwix::urlDecode(request.get_argument("source"));
|
source = kiwix::urlDecode(request.get_argument("source"));
|
||||||
} catch (const std::out_of_range& e) {}
|
} catch (const std::out_of_range& e) {}
|
||||||
|
|
||||||
if (source.empty())
|
if (source.empty()) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
|
}
|
||||||
|
|
||||||
auto data = get_default_data();
|
auto data = get_default_data();
|
||||||
data.set("source", source);
|
data.set("source", source);
|
||||||
|
@ -855,7 +860,8 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
|
||||||
bookName = request.get_url_part(1);
|
bookName = request.get_url_part(1);
|
||||||
kind = request.get_url_part(2);
|
kind = request.get_url_part(2);
|
||||||
} catch (const std::out_of_range& e) {
|
} catch (const std::out_of_range& e) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind != "meta" && kind!= "content") {
|
if (kind != "meta" && kind!= "content") {
|
||||||
|
|
|
@ -43,7 +43,8 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2(const RequestContext
|
||||||
try {
|
try {
|
||||||
url = request.get_url_part(2);
|
url = request.get_url_part(2);
|
||||||
} catch (const std::out_of_range&) {
|
} catch (const std::out_of_range&) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url == "root.xml") {
|
if (url == "root.xml") {
|
||||||
|
@ -69,7 +70,8 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2(const RequestContext
|
||||||
} else if (url == "illustration") {
|
} else if (url == "illustration") {
|
||||||
return handle_catalog_v2_illustration(request);
|
return handle_catalog_v2_illustration(request);
|
||||||
} else {
|
} else {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +112,8 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_complete_entry(const
|
||||||
try {
|
try {
|
||||||
mp_library->getBookById(entryId);
|
mp_library->getBookById(entryId);
|
||||||
} catch (const std::out_of_range&) {
|
} catch (const std::out_of_range&) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
OPDSDumper opdsDumper(mp_library);
|
OPDSDumper opdsDumper(mp_library);
|
||||||
|
@ -158,7 +161,8 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_illustration(const R
|
||||||
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);
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
return Response::build_404(*this, request.get_full_url());
|
return HTTP404HtmlResponse(*this, request)
|
||||||
|
+ urlNotFoundMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue