[Libreoffice-commits] online.git: common/Common.hpp wsd/FileServer.cpp wsd/LOOLWSD.cpp wsd/Storage.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon May 15 03:10:24 UTC 2017
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 d267b86bbdc74b51348b2eac9c1e0ae40a17ec76
Author: Ashod Nakashian <ashod.nakashian at 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 <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.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 ad665fb2..60b6a710 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -193,7 +193,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());
@@ -251,7 +251,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";
@@ -265,7 +265,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());
@@ -278,7 +278,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());
@@ -406,7 +406,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());
@@ -465,7 +465,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 fb4c5829..8c116654 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1669,7 +1669,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());
@@ -1716,7 +1716,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";
@@ -1787,7 +1787,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: " << mediaType << "\r\n"
<< "X-Content-Type-Options: nosniff\r\n"
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 10849e48..ff78adc1 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -422,7 +422,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);
psession->sendRequest(request);
Poco::Net::HTTPResponse response;
@@ -539,7 +539,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);
psession->sendRequest(request);
Poco::Net::HTTPResponse response;
More information about the Libreoffice-commits
mailing list