6 #include <zypp-media/MediaException> 30 if (scheme ==
"cd" || scheme ==
"dvd")
32 else if (scheme ==
"nfs" || scheme ==
"nfs4")
34 else if (scheme ==
"iso")
36 else if (scheme ==
"file" || scheme ==
"dir")
38 else if (scheme ==
"hd" )
40 else if (scheme ==
"cifs" || scheme ==
"smb")
42 else if (scheme ==
"ftp" || scheme ==
"tftp" || scheme ==
"http" || scheme ==
"https")
44 else if (scheme ==
"plugin" )
52 MIL <<
"Url is not valid" << std::endl;
58 MIL <<
"Trying scheme '" << url.
getScheme() <<
"'" << std::endl;
65 std::unique_ptr<MediaHandler>
_handler;
68 _handler = std::make_unique<MediaCD> (url,preferred_attach_point);
72 _handler = std::make_unique<MediaNFS> (url,preferred_attach_point);
76 _handler = std::make_unique<MediaISO> (url,preferred_attach_point);
80 _handler = std::make_unique<MediaDIR> (url,preferred_attach_point);
84 _handler = std::make_unique<MediaDISK> (url,preferred_attach_point);
88 _handler = std::make_unique<MediaCIFS> (url,preferred_attach_point);
92 enum WhichHandler { choose, curl, multicurl };
93 WhichHandler which = choose;
95 if (
const std::string & queryparam = url.
getQueryParam(
"mediahandler"); ! queryparam.empty() ) {
96 if ( queryparam ==
"network" || queryparam ==
"multicurl" )
98 else if ( queryparam ==
"curl" )
101 WAR <<
"Unknown mediahandler='" << queryparam <<
"' in URL; Choosing the default" << std::endl;
104 if ( which == choose ) {
105 auto getenvIs = []( std::string_view var, std::string_view val )->
bool {
106 const char * v = ::getenv( var.data() );
107 return v && v == val;
110 if ( getenvIs(
"ZYPP_MULTICURL",
"0" ) ) {
111 WAR <<
"multicurl manually disabled." << std::endl;
118 std::unique_ptr<MediaNetworkCommonHandler> handler;
122 handler = std::make_unique<MediaMultiCurl>( url, preferred_attach_point );
125 handler = std::make_unique<MediaCurl>( url, preferred_attach_point );
129 for (
const auto & el : custom_headers ) {
130 std::string header { el.first };
133 MIL <<
"Added custom header -> " << header << std::endl;
134 handler->settings().addHeader( std::move(header) );
154 ERR <<
"Failed to create media handler" << std::endl;
std::string getScheme() const
Returns the scheme name of the URL.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
bool isValid() const
Verifies the Url.