Rewrite FileServerRequestHandler::sendError to rely on generic sendError
Signed-off-by: Jan Dageförde <jan.dagefoerde@googlemail.com> Change-Id: Ib19f95868b61fa43375bf4b19372d9f3f68691dd
This commit is contained in:
parent
c543e44150
commit
7206231ede
1 changed files with 9 additions and 13 deletions
|
@ -45,6 +45,7 @@
|
|||
#include <Log.hpp>
|
||||
#include <Protocol.hpp>
|
||||
#include <Util.hpp>
|
||||
#include <net/HttpHelper.hpp>
|
||||
|
||||
using Poco::Net::HTMLForm;
|
||||
using Poco::Net::HTTPBasicCredentials;
|
||||
|
@ -494,24 +495,19 @@ void FileServerRequestHandler::sendError(int errorCode, const Poco::Net::HTTPReq
|
|||
const std::string& shortMessage, const std::string& longMessage,
|
||||
const std::string& extraHeader)
|
||||
{
|
||||
Poco::URI requestUri(request.getURI());
|
||||
const std::string& path = requestUri.getPath();
|
||||
std::ostringstream oss;
|
||||
oss << "HTTP/1.1 " << errorCode << "\r\n"
|
||||
"Content-Type: text/html charset=UTF-8\r\n"
|
||||
"Date: " << Util::getHttpTimeNow() << "\r\n"
|
||||
"User-Agent: " << WOPI_AGENT_STRING << "\r\n"
|
||||
<< extraHeader
|
||||
<< "\r\n";
|
||||
std::string body;
|
||||
std::string headers = extraHeader;
|
||||
if (!shortMessage.empty())
|
||||
{
|
||||
Poco::URI requestUri(request.getURI());
|
||||
std::string pathSanitized;
|
||||
Poco::URI::encode(path, "", pathSanitized);
|
||||
oss << "<h1>Error: " << shortMessage << "</h1>"
|
||||
"<p>" << longMessage << ' ' << pathSanitized << "</p>"
|
||||
Poco::URI::encode(requestUri.getPath(), "", pathSanitized);
|
||||
headers += "Content-Type: text/html charset=UTF-8\r\n";
|
||||
body = "<h1>Error: " + shortMessage + "</h1>" +
|
||||
"<p>" + longMessage + ' ' + pathSanitized + "</p>" +
|
||||
"<p>Please contact your system administrator.</p>";
|
||||
}
|
||||
socket->send(oss.str());
|
||||
HttpHelper::sendError(errorCode, socket, body, headers);
|
||||
}
|
||||
|
||||
void FileServerRequestHandler::readDirToHash(const std::string &basePath, const std::string &path, const std::string &prefix)
|
||||
|
|
Loading…
Reference in a new issue