]> granicus.if.org Git - icinga2/commitdiff
Don't sent scheme and hostname in request 5558/head
authorJean Flach <jean-marcel.flach@icinga.com>
Wed, 6 Sep 2017 14:01:02 +0000 (16:01 +0200)
committerJean Flach <jean-marcel.flach@icinga.com>
Wed, 6 Sep 2017 14:01:02 +0000 (16:01 +0200)
icinga-studio/icinga-studio.cpp
lib/remote/httprequest.cpp
lib/remote/url.cpp
lib/remote/url.hpp

index 19d03263f02bf32f32773e762887b056a9e6650f..8bfe2e5496bafe318676d27b3277066eee5f5933 100644 (file)
@@ -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 {
index a32f5fd6189c80d24fd566d2114fa318d6bd6b4f..43918c3223fa4c422f32b4a110e68822a914a635 100644 (file)
@@ -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;
        }
index b6cdcb8baf519c16978ec55e399079ab1608ed3c..16a0dbd8864af20ad48f50ce7aead2482cfa61e7 100644 (file)
@@ -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 += "/";
index 20b5810fc9b5687a6199e466d6e9269de6c51101..43b169fc246c043d6f3b4b988ecf00335b9eb820 100644 (file)
@@ -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;