common/Common.hpp | 7 +++++-- wsd/FileServer.cpp | 12 ++++++------ wsd/LOOLWSD.cpp | 6 +++--- wsd/Storage.cpp | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-)
New commits: commit 7519896762ab30693934c79e9681788571b54670 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun May 14 15:17:19 2017 -0400 wsd: include version in http agent strings And move the WOPI agent string to Common.hpp. Change-Id: Ife679705bcd6914ddd45ad50446e690fb22dd317 Reviewed-on: https://gerrit.libreoffice.org/37607 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/40941 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/common/Common.hpp b/common/Common.hpp index 09bafad3..b58c2ca7 100644 --- a/common/Common.hpp +++ b/common/Common.hpp @@ -34,8 +34,11 @@ constexpr auto CHILD_URI = "/loolws/child?"; constexpr auto NEW_CHILD_URI = "/loolws/newchild?"; constexpr auto LO_JAIL_SUBPATH = "lo"; -/// The HTTP response User-Agent. TODO: Include version. -constexpr auto HTTP_AGENT_STRING = "LOOLWSD Agent"; +/// The HTTP response User-Agent. +constexpr auto HTTP_AGENT_STRING = "LOOLWSD HTTP Agent " LOOLWSD_VERSION; + +/// The WOPI User-Agent. +constexpr auto WOPI_AGENT_STRING = "LOOLWSD WOPI Agent " LOOLWSD_VERSION; // The client port number, both loolwsd and the kits have this. extern int ClientPortNumber; diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 0f5fb0aa..c34ac9e6 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -236,7 +236,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M now, Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" << "Expires: " << Poco::DateTimeFormatter::format( later, Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Cache-Control: max-age=11059200\r\n" << "\r\n"; socket->send(oss.str()); @@ -257,7 +257,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M std::ostringstream oss; oss << "HTTP/1.1 401\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: 0\r\n" << "WWW-Authenticate: Basic realm=\"online\"\r\n" << "\r\n"; @@ -271,7 +271,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M std::ostringstream oss; oss << "HTTP/1.1 403\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: 0\r\n" << "\r\n"; socket->send(oss.str()); @@ -284,7 +284,7 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M std::ostringstream oss; oss << "HTTP/1.1 404\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: 0\r\n" << "\r\n"; socket->send(oss.str()); @@ -320,7 +320,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: std::ostringstream oss; oss << "HTTP/1.1 404\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: 0\r\n" << "\r\n"; socket->send(oss.str()); @@ -382,7 +382,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: oss << "HTTP/1.1 200 OK\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" << "Last-Modified: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Cache-Control:max-age=11059200\r\n" << "ETag: \"" LOOLWSD_VERSION_HASH "\"\r\n" << "Content-Length: " << preprocess.size() << "\r\n" diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 92c99154..af0d9c15 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1719,7 +1719,7 @@ private: std::ostringstream oss; oss << "HTTP/1.1 400\r\n" << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: 0\r\n" << "\r\n"; socket->send(oss.str()); @@ -1775,7 +1775,7 @@ private: std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" << "Last-Modified: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: " << responseString.size() << "\r\n" << "Content-Type: " << mimeType << "\r\n" << "\r\n"; @@ -1818,7 +1818,7 @@ private: std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" << "Last-Modified: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" - << "User-Agent: LOOLWSD WOPI Agent\r\n" + << "User-Agent: " << WOPI_AGENT_STRING << "\r\n" << "Content-Length: " << xml.size() << "\r\n" << "Content-Type: text/xml\r\n" << "X-Content-Type-Options: nosniff\r\n" diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index e57d0684..4ce78fa0 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -515,7 +515,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const st std::unique_ptr<Poco::Net::HTTPClientSession> psession(getHTTPClientSession(uriObject)); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1); - request.set("User-Agent", "LOOLWSD WOPI Agent"); + request.set("User-Agent", WOPI_AGENT_STRING); addStorageDebugCookie(request); psession->sendRequest(request); @@ -617,7 +617,7 @@ std::string WopiStorage::loadStorageFileToLocal(const std::string& accessToken) std::unique_ptr<Poco::Net::HTTPClientSession> psession(getHTTPClientSession(uriObject)); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1); - request.set("User-Agent", "LOOLWSD WOPI Agent"); + request.set("User-Agent", WOPI_AGENT_STRING); addStorageDebugCookie(request); psession->sendRequest(request); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits