diff --git a/icinga-studio/icinga-studio.cpp b/icinga-studio/icinga-studio.cpp index 19d03263f..8bfe2e549 100644 --- a/icinga-studio/icinga-studio.cpp +++ b/icinga-studio/icinga-studio.cpp @@ -49,7 +49,7 @@ public: return false; pUrl = f.GetUrl(); - url = pUrl->Format(true); + url = pUrl->Format(false, true); wUrl = url; config.Write("url", wUrl); } else { diff --git a/lib/remote/httprequest.cpp b/lib/remote/httprequest.cpp index a32f5fd61..43918c322 100644 --- a/lib/remote/httprequest.cpp +++ b/lib/remote/httprequest.cpp @@ -165,7 +165,7 @@ void HttpRequest::AddHeader(const String& key, const String& value) void HttpRequest::FinishHeaders(void) { if (m_State == HttpRequestStart) { - String rqline = RequestMethod + " " + RequestUrl->Format() + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\n"; + String rqline = RequestMethod + " " + RequestUrl->Format(true) + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\n"; m_Stream->Write(rqline.CStr(), rqline.GetLength()); m_State = HttpRequestHeaders; } diff --git a/lib/remote/url.cpp b/lib/remote/url.cpp index b6cdcb8ba..16a0dbd88 100644 --- a/lib/remote/url.cpp +++ b/lib/remote/url.cpp @@ -227,17 +227,19 @@ void Url::SetFragment(const String& fragment) { m_Fragment = fragment; } -String Url::Format(bool print_credentials) const +String Url::Format(bool onlyPathAndQuery, bool printCredentials) const { String url; - if (!m_Scheme.IsEmpty()) - url += m_Scheme + ":"; + if (!onlyPathAndQuery) { + if (!m_Scheme.IsEmpty()) + url += m_Scheme + ":"; - if (print_credentials && !GetAuthority().IsEmpty()) - url += "//" + GetAuthority(); - else if (!GetHost().IsEmpty()) - url += "//" + GetHost() + (!GetPort().IsEmpty() ? ":" + GetPort() : ""); + if (printCredentials && !GetAuthority().IsEmpty()) + url += "//" + GetAuthority(); + else if (!GetHost().IsEmpty()) + url += "//" + GetHost() + (!GetPort().IsEmpty() ? ":" + GetPort() : ""); + } if (m_Path.empty()) url += "/"; diff --git a/lib/remote/url.hpp b/lib/remote/url.hpp index 20b5810fc..43b169fc2 100644 --- a/lib/remote/url.hpp +++ b/lib/remote/url.hpp @@ -44,7 +44,7 @@ public: Url(); Url(const String& url); - String Format(bool print_credentials = false) const; + String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const; String GetScheme(void) const; String GetAuthority(void) const;