[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Jan 3 05:54:03 UTC 2017
wsd/LOOLWSD.cpp | 70 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 29 deletions(-)
New commits:
commit 4f46af8856ac388853236489a402cd078edb1de2
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Jan 2 13:19:59 2017 -0500
wsd: refactor handleGetRequest into processGetRequest
Change-Id: Ia8a0e390607e6f69d255027baf417fee25c1de74
Reviewed-on: https://gerrit.libreoffice.org/32670
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 259b2aa..3b86077 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -787,7 +787,46 @@ private:
static void handleGetRequest(const std::string& uri, std::shared_ptr<LOOLWebSocket>& ws, const std::string& id)
{
LOG_INF("Starting GET request handler for session [" << id << "] on url [" << uri << "].");
+ try
+ {
+ // First, setup WS options.
+ // We need blocking here, because the POCO's
+ // non-blocking implementation of websockes is
+ // broken; essentially it leads to sending
+ // incomplete frames.
+ ws->setBlocking(true);
+ ws->setSendTimeout(WS_SEND_TIMEOUT_MS * 1000);
+
+ processGetRequest(uri, ws, id);
+ }
+ catch (const WebSocketErrorMessageException& exc)
+ {
+ // Internal error that should be passed on to the client.
+ const auto msg = exc.toString();
+ LOG_ERR("handleGetRequest: WebSocketErrorMessageException: " << msg);
+ try
+ {
+ ws->sendFrame(msg.data(), msg.size());
+ // abnormal close frame handshake
+ ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY);
+ }
+ catch (const std::exception& exc2)
+ {
+ LOG_ERR("handleGetRequest: exception while sending WS error message [" << msg << "]: " << exc2.what());
+ }
+ }
+ catch (const std::exception& exc)
+ {
+ LOG_INF("Finished GET request handler for session [" << id << "] on uri [" << uri << "] with exception: " << exc.what());
+ throw;
+ }
+
+ LOG_INF("Finished GET request handler for session [" << id << "] on uri [" << uri << "].");
+ }
+ /// Process GET requests.
+ static void processGetRequest(const std::string& uri, std::shared_ptr<LOOLWebSocket>& ws, const std::string& id)
+ {
// Indicate to the client that document broker is searching.
std::string status("statusindicator: find");
LOG_TRC("Sending to Client [" << status << "].");
@@ -1074,8 +1113,6 @@ private:
ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY);
}
}
-
- LOG_INF("Finished GET request handler for session [" << id << "].");
}
/// Sends back the WOPI Discovery XML.
@@ -1209,32 +1246,7 @@ public:
{
auto ws = std::make_shared<LOOLWebSocket>(request, response);
responded = true; // After upgrading to WS we should not set HTTP response.
- try
- {
- // First, setup WS options.
- // We need blocking here, because the POCO's
- // non-blocking implementation of websockes is
- // broken; essentially it leads to sending
- // incomplete frames.
- ws->setBlocking(true);
- ws->setSendTimeout(WS_SEND_TIMEOUT_MS * 1000);
- handleGetRequest(reqPathTokens[1], ws, id);
- }
- catch (const WebSocketErrorMessageException& exc)
- {
- // Internal error that should be passed on to the client.
- LOG_ERR("ClientRequestHandler::handleClientRequest: WebSocketErrorMessageException: " << exc.toString());
- try
- {
- ws->sendFrame(exc.what(), std::strlen(exc.what()));
- // abnormal close frame handshake
- ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY);
- }
- catch (const std::exception& exc2)
- {
- LOG_ERR("ClientRequestHandler::handleClientRequest: exception while sending WS error message: " << exc2.what());
- }
- }
+ handleGetRequest(reqPathTokens[1], ws, id);
}
else
{
@@ -1266,7 +1278,7 @@ public:
if (responded)
{
- LOG_DBG("Already sent response!?");
+ LOG_DBG("Already sent response!?");
}
else
{
More information about the Libreoffice-commits
mailing list