MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Format

Method Format

lib/remote/url.cpp:184–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184String Url::Format(bool onlyPathAndQuery, bool printCredentials) const
185{
186 String url;
187
188 if (!onlyPathAndQuery) {
189 if (!m_Scheme.IsEmpty())
190 url += m_Scheme + ":";
191
192 if (printCredentials && !GetAuthority().IsEmpty())
193 url += "//" + GetAuthority();
194 else if (!GetHost().IsEmpty())
195 url += "//" + GetHost() + (!GetPort().IsEmpty() ? ":" + GetPort() : "");
196 }
197
198 if (m_Path.empty())
199 url += "/";
200 else {
201 for (const String& segment : m_Path) {
202 url += "/";
203 url += Utility::EscapeString(segment, ACPATHSEGMENT_ENCODE, false);
204 }
205 }
206
207 String param;
208 if (!m_Query.empty()) {
209 for (const auto& kv : m_Query) {
210 String key = Utility::EscapeString(kv.first, ACQUERY_ENCODE, false);
211 if (param.IsEmpty())
212 param = "?";
213 else
214 param += "&";
215
216 param += key;
217 param += kv.second.IsEmpty() ?
218 String() : "=" + Utility::EscapeString(kv.second, ACQUERY_ENCODE, false);
219 }
220 }
221
222 url += param;
223
224 if (!m_Fragment.IsEmpty())
225 url += "#" + Utility::EscapeString(m_Fragment, ACFRAGMENT_ENCODE, false);
226
227 return url;
228}
229
230bool Url::ParseScheme(const String& scheme)
231{

Callers 9

AssembleBaseRequestMethod · 0.45
SendRequestMethod · 0.45
SendRequestMethod · 0.45
ScriptFuncMethod · 0.45
FormatPerfdataMethod · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
FetchDataFunction · 0.45
EnableFeatureMethod · 0.45

Calls 3

StringClass · 0.50
IsEmptyMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected