libzypp: zypp-core/Url.cc Source File

libzypp 17.36.6

Url.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12
13#include <zypp-core/Url.h>
14#include <zypp-core/Pathname.h>
15#include <zypp-core/base/Gettext.h>
16#include <zypp-core/base/String.h>
17#include <zypp-core/base/Regex.h>
18#include <stdexcept>
19#include <iostream>
20#include <utility>
21
22
24namespace zypp
25{
26
27
28 using namespace zypp::url;
29
30
31 // -----------------------------------------------------------------
32 /*
33 * url = [scheme:] [//authority] /path [?query] [#fragment]
34 */
35 #define RX_SPLIT_URL "^([^:/?#]+:|)" \
36 "(//[^/?#]*|)" \
37 "([^?#]*)" \
38 "([?][^#]*|)" \
39 "(#.*|)"
40
41
43 namespace
44 {
45
46
47 // ---------------------------------------------------------------
48 class LDAPUrl: public UrlBase
49 {
50 public:
51 LDAPUrl(): UrlBase()
52 {
53 configure();
54 }
55
56 LDAPUrl(LDAPUrl &&) = default;
57 LDAPUrl &operator=(const LDAPUrl &) = default;
58 LDAPUrl &operator=(LDAPUrl &&) = default;
59 LDAPUrl(const LDAPUrl &url) : UrlBase(url) {}
60 ~LDAPUrl() override = default;
61
62 UrlBase *
63 clone() const override
64 {
65 return new LDAPUrl(*this);
66 }
67
68 UrlSchemes
69 getKnownSchemes() const override
70 {
71 UrlSchemes schemes(2);
72 schemes[0] = "ldap";
73 schemes[1] = "ldaps";
74 return schemes;
75 }
76
77 void
78 configure() override
79 {
80 config("sep_pathparams", "");
81
82 config("psep_querystr", "?");
83 config("vsep_querystr", "");
84
85 // host is required (isValid=>false)
86 // but not mandatory (see RFC 2255),
87 // that is, accept empty host.
88 config("require_host", "y");
89
90 // not allowed here
91 config("rx_username", "");
92 config("rx_password", "");
93 config("rx_fragment", "");
94 config("rx_pathparams", "");
95 }
96
97 zypp::url::ParamMap
98 getQueryStringMap(zypp::url::EEncoding eflag) const override
99 {
100 static const char * const keys[] = {
101 "attrs", "scope", "filter", "exts", NULL
102 };
103 zypp::url::ParamMap pmap;
104 zypp::url::ParamVec pvec( getQueryStringVec());
105 if( pvec.size() <= 4)
106 {
107 for(size_t i=0; i<pvec.size(); i++)
108 {
109 if(eflag == zypp::url::E_ENCODED)
110 pmap[keys[i]] = pvec[i];
111 else
112 pmap[keys[i]] = zypp::url::decode( pvec[i]);
113 }
114 }
115 else
116 {
117 ZYPP_THROW(url::UrlNotSupportedException(
118 _("Invalid LDAP URL query string")
119 ));
120 }
121 return pmap;
122 }
123
124 void
125 setQueryStringMap(const zypp::url::ParamMap &pmap, EEncoding eflag ) override
126 {
127 static const char * const keys[] = {
128 "attrs", "scope", "filter", "exts", NULL
129 };
130
131 if ( eflag == url::E_DECODED )
132 {
133 // remove psep ("?") from safe chars
134 std::string join_safe;
135 std::string safe(config("safe_querystr"));
136 std::string psep(config("psep_querystr"));
137 for(std::string::size_type i=0; i<safe.size(); i++)
138 {
139 if( psep.find(safe[i]) == std::string::npos)
140 join_safe.append(1, safe[i]);
141 }
142
143 zypp::url::ParamVec pvec(4);
144 zypp::url::ParamMap::const_iterator p;
145 for(p=pmap.begin(); p!=pmap.end(); ++p)
146 {
147 bool found=false;
148 for(size_t i=0; i<4; i++)
149 {
150 if(p->first == keys[i])
151 {
152 found=true;
153 pvec[i] = zypp::url::encode(p->second, join_safe);
154 }
155 }
156 if( !found)
157 {
158 ZYPP_THROW(url::UrlNotSupportedException(
159 str::form(_("Invalid LDAP URL query parameter '%s'"),
160 p->first.c_str())
161 ));
162 }
163 }
164 setQueryStringVec(pvec);
165 }
166 else
167 {
168 setQueryString(
169 zypp::url::join(
170 pmap,
171 config("psep_querystr"),
172 config("vsep_querystr"),
173 config("safe_querystr"),
174 url::E_ENCODED
175 )
176 );
177 }
178 }
179 };
180
181 // ---------------------------------------------------------------
182 // FIXME: hmm..
183 class UrlByScheme
184 {
185 private:
186 using UrlBySchemeMap = std::map<std::string, UrlRef>;
187 UrlBySchemeMap urlByScheme;
188
189 public:
190 UrlByScheme()
191 {
192 UrlRef ref;
193
194 // =====================================
195 ref.reset( new LDAPUrl());
196 addUrlByScheme("ldap", ref);
197 addUrlByScheme("ldaps", ref);
198
199
200 // =====================================
201 ref.reset( new UrlBase());
202 // don't show empty authority
203 ref->setViewOptions( zypp::url::ViewOption::DEFAULTS -
204 zypp::url::ViewOption::EMPTY_AUTHORITY);
205
206 ref->config("with_authority", "n"); // disallow host,...
207 ref->config("require_pathname", "m"); // path is mandatory
208 addUrlByScheme("hd", ref);
209 addUrlByScheme("cd", ref);
210 addUrlByScheme("dvd", ref);
211 addUrlByScheme("dir", ref);
212 addUrlByScheme("iso", ref);
213
214 addUrlByScheme("mailto", ref);
215 addUrlByScheme("urn", ref);
216 addUrlByScheme("plugin", ref); // zypp plugable media handler:
217
218 // RFC1738, 3.10: may contain a host
219 ref->config("with_authority", "y"); // allow host,
220 ref->config("with_port", "n"); // but no port,
221 ref->config("rx_username", ""); // username or
222 ref->config("rx_password", ""); // password ...
223 addUrlByScheme("file", ref);
224
225 // =====================================
226 ref.reset( new UrlBase());
227 ref->config("require_host", "m"); // host is mandatory
228 addUrlByScheme("nfs", ref);
229 addUrlByScheme("nfs4", ref);
230 addUrlByScheme("smb", ref);
231 addUrlByScheme("cifs", ref);
232 addUrlByScheme("http", ref);
233 addUrlByScheme("https", ref);
234 ref->config("path_encode_slash2", "y"); // always encode 2. slash
235 addUrlByScheme("ftp", ref);
236 addUrlByScheme("sftp", ref);
237 addUrlByScheme("tftp", ref);
238 }
239
240 bool
241 addUrlByScheme(const std::string &scheme,
242 UrlRef urlImpl)
243 {
244 if( urlImpl && urlImpl->isValidScheme(scheme))
245 {
246 UrlRef ref(urlImpl);
247 ref->clear();
248 urlByScheme[str::toLower(scheme)] = ref;
249 return true;
250 }
251 return false;
252 }
253
254 UrlRef
255 getUrlByScheme(const std::string &scheme) const
256 {
257 UrlBySchemeMap::const_iterator i(urlByScheme.find(str::toLower(scheme)));
258 if( i != urlByScheme.end())
259 {
260 return i->second;
261 }
262 return UrlRef();
263 }
264
265 bool
266 isRegisteredScheme(const std::string &scheme) const
267 {
268 return urlByScheme.find(str::toLower(scheme)) != urlByScheme.end();
269 }
270
271 UrlSchemes
272 getRegisteredSchemes() const
273 {
274 UrlBySchemeMap::const_iterator i(urlByScheme.begin());
275 UrlSchemes schemes;
276
277 schemes.reserve(urlByScheme.size());
278 for( ; i != urlByScheme.end(); ++i)
279 {
280 schemes.push_back(i->first);
281 }
282 return schemes;
283 }
284 };
285
286
287 // ---------------------------------------------------------------
288 UrlByScheme & g_urlSchemeRepository()
289 {
290 static UrlByScheme _v;
291 return _v;
292 }
293
295 } // anonymous namespace
297
298
299 // -----------------------------------------------------------------
300 Url::~Url()
301 {
302 }
303
304
305 // -----------------------------------------------------------------
306 Url::Url()
307 : m_impl( new UrlBase())
308 {
309 }
310
311
312 // -----------------------------------------------------------------
313 Url::Url(const Url &url)
314 : m_impl( url.m_impl)
315 {
316 if( !m_impl)
317 {
318 ZYPP_THROW(url::UrlException(
319 _("Unable to clone Url object")
320 ));
321 }
322 }
323
324
325 // -----------------------------------------------------------------
326 Url::Url(zypp::url::UrlRef url)
327 : m_impl(std::move( url))
328 {
329 if( !m_impl)
330 {
331 ZYPP_THROW(url::UrlException(
332 _("Invalid empty Url object reference")
333 ));
334 }
335 }
336
337
338 // -----------------------------------------------------------------
339 Url::Url(const std::string &encodedUrl)
340 : m_impl( parseUrl(encodedUrl))
341 {
342 if( !m_impl)
343 {
344 ZYPP_THROW(url::UrlParsingException(
345 _("Unable to parse Url components")
346 ));
347 }
348 }
349
350
351 // -----------------------------------------------------------------
352 Url&
353 Url::operator = (const std::string &encodedUrl)
354 {
355 UrlRef url( parseUrl(encodedUrl));
356 if( !url)
357 {
358 ZYPP_THROW(url::UrlParsingException(
359 _("Unable to parse Url components")
360 ));
361 }
362 m_impl = url;
363 return *this;
364 }
365
366
367 // -----------------------------------------------------------------
368 Url&
369 Url::operator = (const Url &url)
370 {
371 m_impl = url.m_impl;
372 return *this;
373 }
374
375
376 // -----------------------------------------------------------------
377 // static
378 bool
379 Url::registerScheme(const std::string &scheme,
380 UrlRef urlImpl)
381 {
382 return g_urlSchemeRepository().addUrlByScheme(scheme, std::move(urlImpl));
383 }
384
385
386 // -----------------------------------------------------------------
387 // static
388 UrlRef
389 Url::parseUrl(const std::string &encodedUrl)
390 {
391 UrlRef url;
392 str::smatch out;
393 bool ret = false;
394
395 try
396 {
397 str::regex rex(RX_SPLIT_URL);
398 ret = str::regex_match(encodedUrl, out, rex);
399 }
400 catch( ... )
401 {}
402
403 if(ret && out.size() == 6)
404 {
405 std::string scheme = out[1];
406 if (scheme.size() > 1)
407 scheme.pop_back();
408 std::string authority = out[2];
409 if (authority.size() >= 2)
410 authority = authority.substr(2);
411 std::string query = out[4];
412 if (query.size() > 1)
413 query = query.substr(1);
414 std::string fragment = out[5];
415 if (fragment.size() > 1)
416 fragment = fragment.substr(1);
417
418 url = g_urlSchemeRepository().getUrlByScheme(scheme);
419 if( !url)
420 {
421 url.reset( new UrlBase());
422 }
423 url->init(scheme, authority, out[3],
424 query, fragment);
425 }
426 return url;
427 }
428
429
430 // -----------------------------------------------------------------
431 // static
432 zypp::url::UrlSchemes
433 Url::getRegisteredSchemes()
434 {
435 return g_urlSchemeRepository().getRegisteredSchemes();
436 }
437
438
439 // -----------------------------------------------------------------
440 // static
441 bool
442 Url::isRegisteredScheme(const std::string &scheme)
443 {
444 return g_urlSchemeRepository().isRegisteredScheme(scheme);
445 }
446
447
448 // -----------------------------------------------------------------
449 zypp::url::UrlSchemes
450 Url::getKnownSchemes() const
451 {
452 return m_impl->getKnownSchemes();
453 }
454
455
456 // -----------------------------------------------------------------
457 bool
458 Url::isValidScheme(const std::string &scheme) const
459 {
460 return m_impl->isValidScheme(scheme);
461 }
462
463
465 namespace
466 {
467 inline bool isInList( const char ** begin_r, const char ** end_r, const std::string & scheme_r )
468 {
469 for ( ; begin_r != end_r; ++begin_r )
470 if ( scheme_r == *begin_r )
471 return true;
472 return false;
473 }
474 }
475 bool Url::schemeIsLocal( const std::string & scheme_r )
476 {
477 static const char * val[] = { "cd", "dvd", "dir", "hd", "iso", "file" };
478 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
479 }
480
481 bool Url::schemeIsRemote( const std::string & scheme_r )
482 {
483 static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp", "tftp" };
484 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
485 }
486
487 bool Url::schemeIsVolatile( const std::string & scheme_r )
488 {
489 static const char * val[] = { "cd", "dvd" };
490 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
491 }
492
493 bool Url::schemeIsDownloading( const std::string & scheme_r )
494 {
495 static const char * val[] = { "http", "https", "ftp", "sftp", "tftp" };
496 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
497 }
498
499 bool Url::schemeIsPlugin( const std::string & scheme_r )
500 {
501 return scheme_r == "plugin";
502 }
503
504
505 // -----------------------------------------------------------------
506 bool
507 Url::isValid() const
508 {
509 return m_impl->isValid();
510 }
511
512
513 // -----------------------------------------------------------------
514 std::string
515 Url::asString() const
516 {
517 return m_impl->asString();
518 }
519
520
521 // -----------------------------------------------------------------
522 std::string
523 Url::asCompleteString() const
524 {
525 // make sure, all url components are included;
526 // regardless of the current configuration...
527 ViewOptions opts(getViewOptions() +
528 ViewOption::WITH_SCHEME +
529 ViewOption::WITH_USERNAME +
530 ViewOption::WITH_PASSWORD +
531 ViewOption::WITH_HOST +
532 ViewOption::WITH_PORT +
533 ViewOption::WITH_PATH_NAME +
534 ViewOption::WITH_PATH_PARAMS +
535 ViewOption::WITH_QUERY_STR +
536 ViewOption::WITH_FRAGMENT);
537 return m_impl->asString(opts);
538 }
539
540
541 // -----------------------------------------------------------------
542 std::string
543 Url::asString(const ViewOptions &opts) const
544 {
545 return m_impl->asString(opts);
546 }
547
548
549 // -----------------------------------------------------------------
550 std::string
551 Url::getScheme() const
552 {
553 return m_impl->getScheme();
554 }
555
556
557 // -----------------------------------------------------------------
558 std::string
559 Url::getAuthority() const
560 {
561 return m_impl->getAuthority();
562 }
563
564 // -----------------------------------------------------------------
565 std::string
566 Url::getPathData() const
567 {
568 return m_impl->getPathData();
569 }
570
571
572 // -----------------------------------------------------------------
573 std::string
574 Url::getQueryString() const
575 {
576 return m_impl->getQueryString();
577 }
578
579
580 // -----------------------------------------------------------------
581 std::string
582 Url::getFragment(zypp::url::EEncoding eflag) const
583 {
584 return m_impl->getFragment(eflag);
585 }
586
587
588 // -----------------------------------------------------------------
589 std::string
590 Url::getUsername(EEncoding eflag) const
591 {
592 return m_impl->getUsername(eflag);
593 }
594
595
596 // -----------------------------------------------------------------
597 std::string
598 Url::getPassword(EEncoding eflag) const
599 {
600 return m_impl->getPassword(eflag);
601 }
602
603
604 // -----------------------------------------------------------------
605 std::string
606 Url::getHost(EEncoding eflag) const
607 {
608 return m_impl->getHost(eflag);
609 }
610
611
612 // -----------------------------------------------------------------
613 std::string
614 Url::getPort() const
615 {
616 return m_impl->getPort();
617 }
618
619
620 // -----------------------------------------------------------------
621 std::string
622 Url::getPathName(EEncoding eflag) const
623 {
624 return m_impl->getPathName(eflag);
625 }
626
627
628 // -----------------------------------------------------------------
629 std::string
630 Url::getPathParams() const
631 {
632 return m_impl->getPathParams();
633 }
634
635
636 // -----------------------------------------------------------------
637 zypp::url::ParamVec
638 Url::getPathParamsVec() const
639 {
640 return m_impl->getPathParamsVec();
641 }
642
643
644 // -----------------------------------------------------------------
645 zypp::url::ParamMap
646 Url::getPathParamsMap(EEncoding eflag) const
647 {
648 return m_impl->getPathParamsMap(eflag);
649 }
650
651
652 // -----------------------------------------------------------------
653 std::string
654 Url::getPathParam(const std::string &param, EEncoding eflag) const
655 {
656 return m_impl->getPathParam(param, eflag);
657 }
658
659
660 // -----------------------------------------------------------------
661 zypp::url::ParamVec
662 Url::getQueryStringVec() const
663 {
664 return m_impl->getQueryStringVec();
665 }
666
667
668 // -----------------------------------------------------------------
669 zypp::url::ParamMap
670 Url::getQueryStringMap(EEncoding eflag) const
671 {
672 return m_impl->getQueryStringMap(eflag);
673 }
674
675
676 // -----------------------------------------------------------------
677 std::string
678 Url::getQueryParam(const std::string &param, EEncoding eflag) const
679 {
680 return m_impl->getQueryParam(param, eflag);
681 }
682
683
684 // -----------------------------------------------------------------
685 void
686 Url::setScheme(const std::string &scheme)
687 {
688 if(scheme == m_impl->getScheme())
689 {
690 return;
691 }
692 if( m_impl->isKnownScheme(scheme))
693 {
694 m_impl->setScheme(scheme);
695 return;
696 }
697
698 UrlRef url = g_urlSchemeRepository().getUrlByScheme(scheme);
699 if( !url)
700 {
701 url.reset( new UrlBase());
702 }
703 url->init(
704 scheme,
705 m_impl->getAuthority(),
706 m_impl->getPathData(),
707 m_impl->getQueryString(),
708 m_impl->getFragment(zypp::url::E_ENCODED)
709 );
710 m_impl = url;
711 }
712
713
714 // -----------------------------------------------------------------
715 void
716 Url::setAuthority(const std::string &authority)
717 {
718 m_impl->setAuthority(authority);
719 }
720
721
722 // -----------------------------------------------------------------
723 void
724 Url::setPathData(const std::string &pathdata)
725 {
726 m_impl->setPathData(pathdata);
727 }
728
729
730 // -----------------------------------------------------------------
731 void
732 Url::setQueryString(const std::string &querystr)
733 {
734 m_impl->setQueryString(querystr);
735 }
736
737
738 // -----------------------------------------------------------------
739 void
740 Url::setFragment(const std::string &fragment, EEncoding eflag)
741 {
742 m_impl->setFragment(fragment, eflag);
743 }
744
745
746 // -----------------------------------------------------------------
747 void
748 Url::setUsername(const std::string &user,
749 EEncoding eflag)
750 {
751 m_impl->setUsername(user, eflag);
752 }
753
754
755 // -----------------------------------------------------------------
756 void
757 Url::setPassword(const std::string &pass,
758 EEncoding eflag)
759 {
760 m_impl->setPassword(pass, eflag);
761 }
762
763
764 // -----------------------------------------------------------------
765 void
766 Url::setHost(const std::string &host)
767 {
768 m_impl->setHost(host);
769 }
770
771
772 // -----------------------------------------------------------------
773 void
774 Url::setPort(const std::string &port)
775 {
776 m_impl->setPort(port);
777 }
778
779
780 // -----------------------------------------------------------------
781 void
782 Url::setPathName(const std::string &path,
783 EEncoding eflag)
784 {
785 m_impl->setPathName(path, eflag);
786 }
787
788 void
789 Url::setPathName(const Pathname &path,
790 EEncoding eflag)
791 {
792 m_impl->setPathName(path.asString(), eflag);
793 }
794
795 void
796 Url::setPathName(const char *path,
797 EEncoding eflag)
798 {
799 m_impl->setPathName(path, eflag);
800 }
801
802 // -----------------------------------------------------------------
803
804 void Url::appendPathName( const Pathname & path_r, EEncoding eflag_r )
805 {
806 if ( ! path_r.emptyOrRoot() ) {
807 // Check on string level to restore leading double slashes "//" (E_DECODED)
808 // Most important for ftp: where "/%2f" (E_ENCODED) denotes an absolute path.
809 std::string upath { getPathName( url::E_DECODED ) };
810 if ( upath.empty() ) {
811 setPathName( path_r.absolutename(), eflag_r );
812 } else {
813 bool doubleslhash = str::startsWith( upath, "//" );
814 Pathname npath { upath }; // now let Pathname handle the correct concatenation
815 if ( eflag_r == url::E_DECODED ) {
816 npath /= path_r;
817 } else {
818 npath /= url::decode( path_r.asString() );
819 }
820 if ( doubleslhash ) {
821 setPathName( "/" + npath.asString(), url::E_DECODED );
822 } else {
823 setPathName( npath.asString(), url::E_DECODED );
824 }
825 }
826 }
827 }
828
829 // -----------------------------------------------------------------
830 void
831 Url::setPathParams(const std::string &params)
832 {
833 m_impl->setPathParams(params);
834 }
835
836
837 // -----------------------------------------------------------------
838 void
839 Url::setPathParamsVec(const zypp::url::ParamVec &pvec)
840 {
841 m_impl->setPathParamsVec(pvec);
842 }
843
844
845 // -----------------------------------------------------------------
846 void
847 Url::setPathParamsMap(const zypp::url::ParamMap &pmap)
848 {
849 m_impl->setPathParamsMap(pmap);
850 }
851
852
853 // -----------------------------------------------------------------
854 void
855 Url::setPathParam(const std::string &param, const std::string &value)
856 {
857 m_impl->setPathParam(param, value);
858 }
859
860
861 // -----------------------------------------------------------------
862 void
863 Url::setQueryStringVec(const zypp::url::ParamVec &pvec)
864 {
865 m_impl->setQueryStringVec(pvec);
866 }
867
868
869 // -----------------------------------------------------------------
870 void
871 Url::setQueryStringMap(const zypp::url::ParamMap &pmap)
872 {
873 m_impl->setQueryStringMap(pmap, url::E_DECODED);
874 }
875
876 // -----------------------------------------------------------------
877 void
878 Url::setQueryParam(const std::string &param, const std::string &value)
879 {
880 m_impl->setQueryParam(param, value);
881 }
882
883 // -----------------------------------------------------------------
884 void
885 Url::delQueryParam(const std::string &param)
886 {
887 m_impl->delQueryParam(param);
888 }
889
890 void
891 Url::delQueryParams(const std::set<std::string> &params)
892 {
893 m_impl->delQueryParams(params);
894 }
895
896 // -----------------------------------------------------------------
897 ViewOptions
898 Url::getViewOptions() const
899 {
900 return m_impl->getViewOptions();
901 }
902
903 // -----------------------------------------------------------------
904 void
905 Url::setViewOptions(const ViewOptions &vopts)
906 {
907 m_impl->setViewOptions(vopts);
908 }
909
910 // -----------------------------------------------------------------
911 std::ostream & operator<<( std::ostream & str, const Url & url )
912 {
913 return str << url.asString();
914 }
915
916 bool operator<( const Url &lhs, const Url &rhs )
917 {
918 return (lhs.asCompleteString() < rhs.asCompleteString());
919 }
920
921 bool operator==( const Url &lhs, const Url &rhs )
922 {
923 return (lhs.asCompleteString() == rhs.asCompleteString());
924 }
925
926 bool operator!=( const Url &lhs, const Url &rhs )
927 {
928 return (lhs.asCompleteString() != rhs.asCompleteString());
929 }
930
931 namespace hotfix1050625 {
932 std::string asString( const Url & url_r )
933 { return url_r.m_impl->asString1050625(); }
934 }
935
937} // namespace zypp
939/*
940** vim: set ts=2 sts=2 sw=2 ai et:
941*/
RX_SPLIT_URL
#define RX_SPLIT_URL
Definition Url.cc:35
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::Url::schemeIsPlugin
bool schemeIsPlugin() const
Definition Url.h:294
zypp::Url::delQueryParams
void delQueryParams(const std::set< std::string > &params)
remove multiple query parameters at once
Definition Url.cc:891
zypp::Url::getScheme
std::string getScheme() const
Returns the scheme name of the URL.
Definition Url.cc:551
zypp::Url::asCompleteString
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition Url.cc:523
zypp::Url::setViewOptions
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition Url.cc:905
zypp::Url::setAuthority
void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition Url.cc:716
zypp::Url::getPathParamsMap
zypp::url::ParamMap getPathParamsMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with path parameter keys and values.
Definition Url.cc:646
zypp::Url::getPathParamsVec
zypp::url::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
Definition Url.cc:638
zypp::Url::ViewOptions
zypp::url::ViewOptions ViewOptions
View options.
Definition Url.h:103
zypp::Url::setQueryString
void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition Url.cc:732
zypp::Url::schemeIsRemote
bool schemeIsRemote() const
Definition Url.h:279
zypp::Url::getPathParams
std::string getPathParams() const
Returns the path parameters from the URL.
Definition Url.cc:630
zypp::Url::asString
std::string asString() const
Returns a default string representation of the Url object.
Definition Url.cc:515
zypp::Url::getPathData
std::string getPathData() const
Returns the encoded path component of the URL.
Definition Url.cc:566
zypp::Url::getPathParam
std::string getPathParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified path parameter.
Definition Url.cc:654
zypp::Url::getAuthority
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition Url.cc:559
zypp::Url::getUsername
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition Url.cc:590
zypp::Url::isRegisteredScheme
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
Definition Url.cc:442
zypp::Url::setFragment
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition Url.cc:740
zypp::Url::getPathName
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition Url.cc:622
zypp::Url::setQueryStringVec
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition Url.cc:863
zypp::Url::Url
Url()
Definition Url.cc:306
zypp::Url::getQueryParam
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition Url.cc:678
zypp::Url::setPathName
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition Url.cc:782
zypp::Url::setPathParamsMap
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition Url.cc:847
zypp::Url::getViewOptions
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition Url.cc:898
zypp::Url::schemeIsDownloading
bool schemeIsDownloading() const
Definition Url.h:289
zypp::Url::setPathData
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition Url.cc:724
zypp::Url::getHost
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Definition Url.cc:606
zypp::Url::m_impl
url::UrlRef m_impl
Definition Url.h:851
zypp::Url::setHost
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition Url.cc:766
zypp::Url::setPort
void setPort(const std::string &port)
Set the port number in the URL authority.
Definition Url.cc:774
zypp::Url::~Url
~Url()
Definition Url.cc:300
zypp::Url::delQueryParam
void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition Url.cc:885
zypp::Url::setPathParamsVec
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition Url.cc:839
zypp::Url::isValid
bool isValid() const
Verifies the Url.
Definition Url.cc:507
zypp::Url::getFragment
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
Definition Url.cc:582
zypp::Url::parseUrl
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
Definition Url.cc:389
zypp::Url::setPathParam
void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition Url.cc:855
zypp::Url::setPassword
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition Url.cc:757
zypp::Url::setPathParams
void setPathParams(const std::string &params)
Set the path parameters.
Definition Url.cc:831
zypp::Url::operator=
Url & operator=(const std::string &encodedUrl)
Assigns parsed percent-encoded URL string to the object.
Definition Url.cc:353
zypp::Url::EEncoding
zypp::url::EEncoding EEncoding
Encoding flags.
Definition Url.h:98
zypp::Url::registerScheme
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
Definition Url.cc:379
zypp::Url::getQueryString
std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition Url.cc:574
zypp::Url::isValidScheme
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
Definition Url.cc:458
zypp::Url::setQueryParam
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition Url.cc:878
zypp::Url::getRegisteredSchemes
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
Definition Url.cc:433
zypp::Url::getQueryStringVec
zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition Url.cc:662
zypp::Url::schemeIsLocal
bool schemeIsLocal() const
Definition Url.h:274
zypp::Url::setUsername
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition Url.cc:748
zypp::Url::getKnownSchemes
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
Definition Url.cc:450
zypp::Url::appendPathName
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition Url.cc:804
zypp::Url::setScheme
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition Url.cc:686
zypp::Url::getPassword
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition Url.cc:598
zypp::Url::schemeIsVolatile
bool schemeIsVolatile() const
Definition Url.h:284
zypp::Url::getQueryStringMap
zypp::url::ParamMap getQueryStringMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with query parameter and their values.
Definition Url.cc:670
zypp::Url::getPort
std::string getPort() const
Returns the port from the URL authority.
Definition Url.cc:614
zypp::Url::setQueryStringMap
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition Url.cc:871
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::emptyOrRoot
bool emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:123
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition Pathname.h:93
zypp::filesystem::Pathname::absolutename
Pathname absolutename() const
Return this path, adding a leading '/' if relative.
Definition Pathname.h:141
zypp::str::regex
Regular expression.
Definition Regex.h:95
zypp::str::smatch
Regular expression match result.
Definition Regex.h:168
zypp::str::smatch::size
unsigned size() const
Definition Regex.cc:106
zypp::url::UrlBase
Generic Url base class.
Definition UrlBase.h:272
zypp::url::UrlBase::config
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
Definition UrlBase.cc:368
zypp::url::UrlBase::clear
virtual void clear()
Clears all data in the object.
Definition UrlBase.cc:396
zypp::url::UrlBase::isValidScheme
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
Definition UrlBase.cc:441
zypp::url::UrlBase::setViewOptions
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition UrlBase.cc:388
zypp::url::UrlBase::asString1050625
std::string asString1050625() const
Definition UrlBase.cc:510
zypp::url::UrlException
Base class for all URL exceptions.
Definition UrlException.h:32
zypp::url::UrlNotSupportedException
Thrown if a feature e.g.
Definition UrlException.h:125
zypp::url::UrlParsingException
Thrown if the url or a component can't be parsed at all.
Definition UrlException.h:68
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::hotfix1050625
Definition Url.cc:931
zypp::hotfix1050625::asString
std::string asString(const Url &url_r)
Definition Url.cc:932
zypp::str::toLower
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:178
zypp::str::startsWith
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition String.h:1084
zypp::str::regex_match
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition Regex.h:70
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp::url::UrlRef
RWCOW_pointer< UrlBase > UrlRef
Copy-On-Write Url reference.
Definition UrlBase.h:1093
zypp::url::encode
std::string encode(const std::string &str, const std::string &safe, EEncoding eflag)
Encodes a string using URL percent encoding.
Definition UrlUtils.cc:32
zypp::url::ParamVec
std::vector< std::string > ParamVec
A parameter vector container.
Definition UrlUtils.h:40
zypp::url::ViewOptions
ViewOption ViewOptions
ViewOptions is just an alias for ViewOption.
Definition UrlBase.h:245
zypp::url::join
std::string join(const ParamVec &pvec, const std::string &psep)
Join parameter vector to a string.
Definition UrlUtils.cc:252
zypp::url::ParamMap
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition UrlUtils.h:47
zypp::url::UrlSchemes
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition UrlBase.h:252
zypp::url::EEncoding
EEncoding
Encoding flags.
Definition UrlUtils.h:52
zypp::url::E_DECODED
@ E_DECODED
Flag to request decoded string(s).
Definition UrlUtils.h:54
zypp::url::E_ENCODED
@ E_ENCODED
Flag to request encoded string(s).
Definition UrlUtils.h:53
zypp::url::decode
std::string decode(const std::string &str, bool allowNUL)
Decodes a URL percent encoded string.
Definition UrlUtils.cc:87
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator<
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
Definition StrMatcher.cc:340
zypp::operator==
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition SetRelationMixin.h:84
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52
zypp::operator!=
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition SetRelationMixin.h:109
zypp::RWCOW_pointer::reset
void reset()
Definition PtrTypes.h:498
Pathname.h
Url.h
arrayBegin
#define arrayBegin(A)
Simple C-array iterator.
Definition Easy.h:36
arrayEnd
#define arrayEnd(A)
Definition Easy.h:38
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:424
Gettext.h
_
#define _(MSG)
Definition Gettext.h:39
Regex.h
String.h