wsd/ServerURL.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
New commits: commit 526dd304b7625087d54a75df034058c493321999 Author: Michael Meeks <[email protected]> AuthorDate: Thu May 7 17:30:04 2020 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Thu May 7 21:00:04 2020 +0200 Proxy: getSubURLForEndpoint - don't return wss:// URLs in error. Separate _ssl and _websocket state and construct the URLs from them. Change-Id: Ida4eee868c7815eb68e3029682d603d13d193153 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93669 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Meeks <[email protected]> diff --git a/wsd/ServerURL.hpp b/wsd/ServerURL.hpp index 3e96fff98..647ca966d 100644 --- a/wsd/ServerURL.hpp +++ b/wsd/ServerURL.hpp @@ -19,7 +19,8 @@ */ class ServerURL { - std::string _schemeProtocol; + bool _ssl; + bool _websocket; std::string _schemeAuthority; std::string _pathPlus; public: @@ -38,9 +39,9 @@ public: // The user can override the ServerRoot with a new prefix. _pathPlus = LOOLWSD::ServiceRoot; - bool ssl = (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()); + _ssl = (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()); + _websocket = true; std::string serverName = LOOLWSD::ServerName.empty() ? host : LOOLWSD::ServerName; - _schemeProtocol = (ssl ? "wss://" : "ws://"); _schemeAuthority = serverName; // A well formed ProxyPrefix will override it. @@ -54,7 +55,9 @@ public: auto hostEndPos = url.find("/", pos); if (hostEndPos != std::string::npos) { - _schemeProtocol = url.substr(0, pos); + _websocket = false; + std::string schemeProtocol = url.substr(0, pos); + _ssl = (schemeProtocol != "http://"); _schemeAuthority = url.substr(pos, hostEndPos - pos); _pathPlus = url.substr(hostEndPos); return; @@ -72,12 +75,15 @@ public: std::string getWebSocketUrl() const { - return _schemeProtocol + _schemeAuthority; + std::string schemeProtocol = (_websocket ? "ws" : "http"); + if (_ssl) + schemeProtocol += "s"; + return schemeProtocol + "://" + _schemeAuthority; } std::string getSubURLForEndpoint(const std::string &path) const { - return _schemeProtocol + _schemeAuthority + _pathPlus + path; + return std::string("http") + (_ssl ? "s" : "") + "://" + _schemeAuthority + _pathPlus + path; } }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
