aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp')
-rw-r--r--contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp218
1 files changed, 109 insertions, 109 deletions
diff --git a/contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp b/contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp
index 33ebf8f9c9..ed39617e2b 100644
--- a/contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp
+++ b/contrib/libs/poco/Net/src/AbstractHTTPRequestHandler.cpp
@@ -1,109 +1,109 @@
-//
-// AbstractHTTPRequestHandler.cpp
-//
-// Library: Net
-// Package: HTTPServer
-// Module: AbstractHTTPRequestHandler
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Net/AbstractHTTPRequestHandler.h"
-#include "Poco/Net/HTTPServerRequest.h"
-#include "Poco/Net/HTTPServerResponse.h"
-#include "Poco/Net/HTMLForm.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/Exception.h"
-
-
-using Poco::NumberFormatter;
-
-
-namespace Poco {
-namespace Net {
-
-
-AbstractHTTPRequestHandler::AbstractHTTPRequestHandler():
- _pRequest(0),
- _pResponse(0),
- _pForm(0)
-{
-}
-
-
-AbstractHTTPRequestHandler::~AbstractHTTPRequestHandler()
-{
- delete _pForm;
-}
-
-
-void AbstractHTTPRequestHandler::handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
-{
- _pRequest = &request;
- _pResponse = &response;
- if (authenticate())
- {
- try
- {
- run();
- }
- catch (Poco::Exception& exc)
- {
- if (!response.sent())
- {
- sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.displayText());
- }
- }
- catch (std::exception& exc)
- {
- if (!response.sent())
- {
- sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.what());
- }
- }
- }
- else
- {
- sendErrorResponse(HTTPResponse::HTTP_UNAUTHORIZED, "");
- }
-}
-
-
-bool AbstractHTTPRequestHandler::authenticate()
-{
- return true;
-}
-
-
-HTMLForm& AbstractHTTPRequestHandler::form()
-{
- if (!_pForm)
- _pForm = new HTMLForm(request(), request().stream());
-
- return *_pForm;
-}
-
-
-void AbstractHTTPRequestHandler::sendErrorResponse(HTTPResponse::HTTPStatus status, const std::string& message)
-{
- response().setStatusAndReason(status);
- std::string statusAndReason(NumberFormatter::format(static_cast<int>(response().getStatus())));
- statusAndReason += " - ";
- statusAndReason += response().getReason();
- std::string page("<HTML><HEAD><TITLE>");
- page += statusAndReason;
- page += "</TITLE></HEAD><BODY><H1>";
- page += statusAndReason;
- page += "</H1>";
- page += "<P>";
- page += message;
- page += "</P></BODY></HTML>";
- response().sendBuffer(page.data(), page.size());
-}
-
-
-} } // namespace Poco::Net
+//
+// AbstractHTTPRequestHandler.cpp
+//
+// Library: Net
+// Package: HTTPServer
+// Module: AbstractHTTPRequestHandler
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Net/AbstractHTTPRequestHandler.h"
+#include "Poco/Net/HTTPServerRequest.h"
+#include "Poco/Net/HTTPServerResponse.h"
+#include "Poco/Net/HTMLForm.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/Exception.h"
+
+
+using Poco::NumberFormatter;
+
+
+namespace Poco {
+namespace Net {
+
+
+AbstractHTTPRequestHandler::AbstractHTTPRequestHandler():
+ _pRequest(0),
+ _pResponse(0),
+ _pForm(0)
+{
+}
+
+
+AbstractHTTPRequestHandler::~AbstractHTTPRequestHandler()
+{
+ delete _pForm;
+}
+
+
+void AbstractHTTPRequestHandler::handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
+{
+ _pRequest = &request;
+ _pResponse = &response;
+ if (authenticate())
+ {
+ try
+ {
+ run();
+ }
+ catch (Poco::Exception& exc)
+ {
+ if (!response.sent())
+ {
+ sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.displayText());
+ }
+ }
+ catch (std::exception& exc)
+ {
+ if (!response.sent())
+ {
+ sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.what());
+ }
+ }
+ }
+ else
+ {
+ sendErrorResponse(HTTPResponse::HTTP_UNAUTHORIZED, "");
+ }
+}
+
+
+bool AbstractHTTPRequestHandler::authenticate()
+{
+ return true;
+}
+
+
+HTMLForm& AbstractHTTPRequestHandler::form()
+{
+ if (!_pForm)
+ _pForm = new HTMLForm(request(), request().stream());
+
+ return *_pForm;
+}
+
+
+void AbstractHTTPRequestHandler::sendErrorResponse(HTTPResponse::HTTPStatus status, const std::string& message)
+{
+ response().setStatusAndReason(status);
+ std::string statusAndReason(NumberFormatter::format(static_cast<int>(response().getStatus())));
+ statusAndReason += " - ";
+ statusAndReason += response().getReason();
+ std::string page("<HTML><HEAD><TITLE>");
+ page += statusAndReason;
+ page += "</TITLE></HEAD><BODY><H1>";
+ page += statusAndReason;
+ page += "</H1>";
+ page += "<P>";
+ page += message;
+ page += "</P></BODY></HTML>";
+ response().sendBuffer(page.data(), page.size());
+}
+
+
+} } // namespace Poco::Net