59 MIL <<
"MirroredOrigin is invalid" << std::endl;
63 std::optional<MirroredOrigin> resolvedOrigin;
64 std::optional<MediaHandlerFactory::MediaHandlerType> hdlType;
68 MIL <<
"OriginEndpoint is not valid" << std::endl;
73 if ( u.hasConfig(
"http-headers") )
77 MIL <<
"Trying scheme '" <<
url.getScheme() <<
"'" << std::endl;
84 if ( !custom_headers.empty () ) {
85 resolvedEndpoint.setConfig (
"http-headers", std::move(custom_headers) );
91 using zyppng::operators::operator |;
101 |
and_then([&]( std::vector<OriginEndpoint> resolvedMirrs ) {
102 std::for_each( resolvedMirrs.begin (), resolvedMirrs.end(), [&](
const OriginEndpoint &rEp ){
104 if ( handlerType (rEp.url()) != hdlType ) {
107 MIL <<
"Different handler type than primary URL, ignoring" << std::endl;
110 resolvedOrigin->addMirror(rEp);
120 if ( !resolvedOrigin ) {
124 if ( resolvedOrigin->endpointCount() > 1 && *hdlType != MediaCURLType )
125 ERR <<
"Got mirrors for handler type: " << *hdlType <<
" they will be ignored!" << std::endl;
127 std::unique_ptr<MediaHandler> _handler;
130 _handler = std::make_unique<MediaCD> (*resolvedOrigin,preferred_attach_point);
134 _handler = std::make_unique<MediaNFS> (*resolvedOrigin,preferred_attach_point);
138 _handler = std::make_unique<MediaISO> (*resolvedOrigin,preferred_attach_point);
141 case MediaFileType: {
142 _handler = std::make_unique<MediaDIR> (*resolvedOrigin,preferred_attach_point);
145 case MediaDISKType: {
146 _handler = std::make_unique<MediaDISK> (*resolvedOrigin,preferred_attach_point);
149 case MediaCIFSType: {
150 _handler = std::make_unique<MediaCIFS> (*resolvedOrigin,preferred_attach_point);
153 case MediaCURLType: {
154 enum WhichHandler { choose, curl, curl2 };
155 WhichHandler which = choose;
157 if (
const std::string & queryparam = resolvedOrigin->authority().url().getQueryParam(
"mediahandler"); ! queryparam.empty() ) {
158 if ( queryparam ==
"curl" )
160 else if ( queryparam ==
"curl2" )
162 else if ( queryparam ==
"network" || queryparam ==
"multicurl" )
165 WAR <<
"Unknown mediahandler='" << queryparam <<
"' in URL; Choosing the default" << std::endl;
168 if ( which == choose ) {
170 if ( indeterminate(envstate) ) {
171#if APIConfig(LIBZYPP_CONFIG_USE_LEGACY_CURL_BACKEND_BY_DEFAULT)
177 which = bool(envstate) ? curl2 : curl;
181 std::unique_ptr<MediaNetworkCommonHandler> handler;
185 handler = std::make_unique<MediaCurl2>( *resolvedOrigin, preferred_attach_point );
188 handler = std::make_unique<MediaCurl>( *resolvedOrigin, preferred_attach_point );
191 _handler = std::move(handler);
194 case MediaPluginType: {
209 ERR <<
"Failed to create media handler" << std::endl;
213 MIL <<
"Opened: " << *_handler << std::endl;