Skip to content

Commit

Permalink
fixup! Add raw endpoint.
Browse files Browse the repository at this point in the history
Fix rebase conflict.
  • Loading branch information
mgautierfr committed Dec 23, 2021
1 parent a3882dc commit 55880d0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server/internalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,11 +894,12 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
bookName = request.get_url_part(1);
kind = request.get_url_part(2);
} catch (const std::out_of_range& e) {
return Response::build_404(*this, request, bookName, "", "");
return Response::build_404(*this, request.get_full_url(), bookName, "", "");
}

if (kind != "meta" && kind!= "content") {
return Response::build_404(*this, request, bookName, "", "");
const std::string error_details = kind + " is not a valid request for raw content.";
return Response::build_404(*this, request.get_full_url(), bookName, "", "");
}

std::shared_ptr<zim::Archive> archive;
Expand All @@ -908,7 +909,8 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
} catch (const std::out_of_range& e) {}

if (archive == nullptr) {
return Response::build_404(*this, request, bookName, "", "");
const std::string error_details = "No such book: " + bookName;
return Response::build_404(*this, request.get_full_url(), bookName, "", error_details);
}

auto itemPath = request.get_url().substr(bookName.size()+kind.size()+6);
Expand All @@ -931,7 +933,8 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
if (m_verbose.load()) {
printf("Failed to find %s\n", itemPath.c_str());
}
return Response::build_404(*this, request, bookName, getArchiveTitle(*archive), "");
const std::string error_details = "Cannot find " + kind + " entry " + itemPath;
return Response::build_404(*this, request.get_full_url(), bookName, getArchiveTitle(*archive), error_details);
}
}

Expand Down

0 comments on commit 55880d0

Please sign in to comment.