[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/FileServer.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sat Apr 16 17:29:03 UTC 2016
loolwsd/Admin.cpp | 2 +-
loolwsd/FileServer.hpp | 12 ++++++------
loolwsd/LOOLWSD.cpp | 14 +++++++-------
loolwsd/LOOLWSD.hpp | 2 --
4 files changed, 14 insertions(+), 16 deletions(-)
New commits:
commit 93d3f806e1bed9f5c43cf16f3c824a5fcb962f3d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Apr 16 08:10:52 2016 -0400
loolwsd: logging and cosmetics
Change-Id: I413a2e40f480ba41e37c7442724c3f037528f89b
Reviewed-on: https://gerrit.libreoffice.org/24130
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp
index d5d4557..e647ae7 100644
--- a/loolwsd/Admin.cpp
+++ b/loolwsd/Admin.cpp
@@ -403,7 +403,7 @@ void MemoryStats::run()
AdminModel& model = _admin->getModel();
unsigned totalMem = _admin->getTotalMemoryUsage(model);
- Log::info("Total memory used: " + std::to_string(totalMem));
+ Log::trace("Total memory used: " + std::to_string(totalMem));
model.addMemStats(totalMem);
}
diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index a749f06..6338989 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -148,7 +148,7 @@ public:
requestUri.getPathSegments(requestSegments);
if (requestSegments.size() < 1)
{
- throw Poco::FileNotFoundException("Invalid file.");
+ throw Poco::FileNotFoundException("Invalid URI request: [" + requestUri.toString() + "].");
}
const std::string endPoint = requestSegments[requestSegments.size() - 1];
@@ -173,7 +173,7 @@ public:
if (filepath.find(LOOLWSD::FileServerRoot) != 0)
{
// Accessing unauthorized path.
- throw Poco::FileNotFoundException("Invalid file path.");
+ throw Poco::FileNotFoundException("Invalid or forbidden file path: [" + filepath + "].");
}
const std::size_t extPoint = endPoint.find_last_of(".");
@@ -195,17 +195,17 @@ public:
response.sendFile(filepath, mimeType);
}
}
- catch (Poco::Net::NotAuthenticatedException& exc)
+ catch (const Poco::Net::NotAuthenticatedException& exc)
{
- Log::error("FileServerRequestHandler::NotAuthenticated");
+ Log::error("FileServerRequestHandler::NotAuthenticated: " + exc.displayText());
response.set("WWW-Authenticate", "Basic realm=\"online\"");
response.setStatus(HTTPResponse::HTTP_UNAUTHORIZED);
response.setContentLength(0);
response.send();
}
- catch (Poco::FileNotFoundException& exc)
+ catch (const Poco::FileNotFoundException& exc)
{
- Log::error("FileServerRequestHandler:: File [" + request.getURI() + "] not found.");
+ Log::error("FileServerRequestHandler: " + exc.displayText());
response.setStatus(HTTPResponse::HTTP_NOT_FOUND);
response.setContentLength(0);
response.send();
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index db27edc..a60d90d 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -638,31 +638,31 @@ private:
static void handleGetDiscovery(HTTPServerRequest& request, HTTPServerResponse& response)
{
- DOMParser parser;
- DOMWriter writer;
-
std::string discoveryPath = Path(Application::instance().commandPath()).parent().toString() + "discovery.xml";
if (!File(discoveryPath).exists())
{
discoveryPath = LOOLWSD_DATADIR "/discovery.xml";
}
+
const std::string mediaType = "text/xml";
const std::string action = "action";
const std::string urlsrc = "urlsrc";
- const std::string uriValue = (LOOLWSD::SSLEnabled? "https://": "http://") +
- (LOOLWSD::ServerName.empty()? request.getHost(): LOOLWSD::ServerName) +
+ const std::string uriValue = (LOOLWSD::SSLEnabled ? "https://" : "http://") +
+ (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName) +
"/loleaflet/dist/loleaflet.html?";
InputSource inputSrc(discoveryPath);
+ DOMParser parser;
AutoPtr<Poco::XML::Document> docXML = parser.parse(&inputSrc);
AutoPtr<NodeList> listNodes = docXML->getElementsByTagName(action);
- for (unsigned long it = 0; it < listNodes->length(); it++)
+ for (unsigned long it = 0; it < listNodes->length(); ++it)
{
static_cast<Element*>(listNodes->item(it))->setAttribute(urlsrc, uriValue);
}
std::ostringstream ostrXML;
+ DOMWriter writer;
writer.writeNode(ostrXML, docXML);
response.set("User-Agent", "LOOLWSD WOPI Agent");
@@ -672,6 +672,7 @@ private:
std::ostream& ostr = response.send();
ostr << ostrXML.str();
+ Log::debug("Sent discovery.xml successfully.");
}
public:
@@ -707,7 +708,6 @@ public:
}
else
{
- //authenticate(request, response, id);
handleGetRequest(request, response, id);
}
}
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 5562837..1fcdac6 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -25,8 +25,6 @@
#include "DocumentBroker.hpp"
#include "Util.hpp"
-class MasterProcessSession;
-
class LOOLWSD: public Poco::Util::ServerApplication
{
public:
More information about the Libreoffice-commits
mailing list