[Libreoffice-commits] online.git: loolwsd/Storage.cpp
Pranav Kant
pranavk at collabora.co.uk
Thu Oct 6 06:00:31 UTC 2016
loolwsd/Storage.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
New commits:
commit 2f59e19252650249f328b718a360c19e0c5a8e90
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Oct 5 13:44:38 2016 +0530
loolwsd: Also handle WOPI urls with spaces
URI::getPath() returns a _decoded_ path which was then being used
for the requests. This leads to failure for WOPI urls having
space in them.
Change-Id: I47bef643b09a919c56f9f0ec7b4dee8604dde089
Reviewed-on: https://gerrit.libreoffice.org/29536
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index 631b300..57e3c5f 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -316,12 +316,12 @@ std::string WopiStorage::loadStorageFileToLocal()
// WOPI URI to download files ends in '/contents'.
// Add it here to get the payload instead of file info.
Poco::URI uriObject(_uri);
- const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery();
- Log::debug("Wopi requesting: " + url);
+ uriObject.setPath(uriObject.getPath() + "/contents");
+ Log::debug("Wopi requesting: " + uriObject.toString());
std::unique_ptr<Poco::Net::HTTPClientSession> psession(getHTTPClientSession(uriObject));
- Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, url, Poco::Net::HTTPMessage::HTTP_1_1);
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
request.set("User-Agent", "LOOLWSD WOPI Agent");
psession->sendRequest(request);
@@ -344,7 +344,7 @@ std::string WopiStorage::loadStorageFileToLocal()
std::ostreambuf_iterator<char>(ofs));
const auto size = getFileSize(_jailedFilePath);
- Log::info() << "WOPI::GetFile downloaded " << size << " bytes from [" << url
+ Log::info() << "WOPI::GetFile downloaded " << size << " bytes from [" << uriObject.toString()
<< "] -> " << _jailedFilePath << ": "
<< response.getStatus() << " " << response.getReason() << Log::end;
@@ -358,12 +358,12 @@ bool WopiStorage::saveLocalFileToStorage()
const auto size = getFileSize(_jailedFilePath);
Poco::URI uriObject(_uri);
- const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery();
- Log::debug("Wopi posting: " + url);
+ uriObject.setPath(uriObject.getPath() + "/contents");
+ Log::debug("Wopi posting: " + uriObject.toString());
std::unique_ptr<Poco::Net::HTTPClientSession> psession(getHTTPClientSession(uriObject));
- Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, url, Poco::Net::HTTPMessage::HTTP_1_1);
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
request.set("X-WOPIOverride", "PUT");
request.setContentType("application/octet-stream");
request.setContentLength(size);
@@ -380,7 +380,7 @@ bool WopiStorage::saveLocalFileToStorage()
Log::info("WOPI::PutFile response: " + oss.str());
const auto success = (response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK);
Log::info() << "WOPI::PutFile uploaded " << size << " bytes from [" << _jailedFilePath << "]:"
- << "] -> [" << url << "]: "
+ << "] -> [" << uriObject.toString() << "]: "
<< response.getStatus() << " " << response.getReason() << Log::end;
return success;
More information about the Libreoffice-commits
mailing list