net/Socket.hpp | 20 +++----------------- wsd/FileServer.cpp | 12 ++++++------ wsd/LOOLWSD.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 27 deletions(-)
New commits: commit 8b9623010a1878f6afdddd4509af939f3fceafca Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon Mar 13 19:38:19 2017 -0400 wsd: sendHttpResponse -> send Change-Id: I7c94f6d4cd1054ea86585bfcd4079140471f3518 Reviewed-on: https://gerrit.libreoffice.org/35157 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/net/Socket.hpp b/net/Socket.hpp index f85fa9b..75d92ee 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -290,7 +290,6 @@ public: return _stop || std::this_thread::get_id() == _owner; } -public: /// Poll the sockets for available data to read or buffer to write. void poll(const int timeoutMaxMs) { @@ -586,26 +585,13 @@ public: send(str.data(), str.size(), flush); } - /// Sends HTTP response data. - void sendHttpResponse(const char* data, const int len) - { - // Send the data and flush. - send(data, len, true); - } - - /// Sends HTTP response string. - void sendHttpResponse(const std::string& str) - { - sendHttpResponse(str.data(), str.size()); - } - /// Sends HTTP response. - void sendHttpResponse(Poco::Net::HTTPResponse& response) + void send(Poco::Net::HTTPResponse& response) { response.set("User-Agent", HTTP_AGENT_STRING); std::ostringstream oss; response.write(oss); - sendHttpResponse(oss.str()); + send(oss.str()); } /// Reads data by invoking readData() and buffering. @@ -836,7 +822,7 @@ namespace HttpHelper response.write(oss); const std::string header = oss.str(); LOG_TRC("Sending file [" << path << "]: " << header); - socket->sendHttpResponse(header); + socket->send(header); std::ifstream file(path, std::ios::binary); bool flush = true; diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 8c35f3f..2189205 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -190,7 +190,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M << "User-Agent: LOOLWSD WOPI Agent\r\n" << "Cache-Control: max-age=11059200\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); socket->shutdown(); return; } @@ -212,7 +212,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M << "Content-Length: 0\r\n" << "WWW-Authenticate: Basic realm=\"online\"\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); } catch (const Poco::FileAccessDeniedException& exc) { @@ -225,7 +225,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M << "User-Agent: LOOLWSD WOPI Agent\r\n" << "Content-Length: 0\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); } catch (const Poco::FileNotFoundException& exc) { @@ -238,7 +238,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M << "User-Agent: LOOLWSD WOPI Agent\r\n" << "Content-Length: 0\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); } } @@ -273,7 +273,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: << "User-Agent: LOOLWSD WOPI Agent\r\n" << "Content-Length: 0\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); return; } @@ -336,7 +336,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: << "\r\n" << preprocess; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); LOG_DBG("Sent file: " << path.toString() << ": " << preprocess); } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 7c5a5a3..9f44137 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1779,7 +1779,7 @@ private: << "User-Agent: LOOLWSD WOPI Agent\r\n" << "Content-Length: 0\r\n" << "\r\n"; - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); socket->shutdown(); } } @@ -1845,7 +1845,7 @@ private: } auto socket = _socket.lock(); - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); socket->shutdown(); LOG_INF("Sent / response successfully."); } @@ -1911,7 +1911,7 @@ private: << xml; auto socket = _socket.lock(); - socket->sendHttpResponse(oss.str()); + socket->send(oss.str()); socket->shutdown(); LOG_INF("Sent discovery.xml successfully."); } @@ -2097,7 +2097,7 @@ private: std::string fileName = dirPath + "/" + form.get("name"); File(tmpPath).moveTo(fileName); response.setContentLength(0); - socket->sendHttpResponse(response); + socket->send(response); return; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits