23#include <zypp-media/auth/CredentialManager> 
   24#include <zypp-curl/auth/CurlAuthData> 
   37    : 
MediaHandler( origin_r, attach_point_r, urlpath_below_attachpoint_r, does_download_r )
 
 
   69    return ::internal::clearQueryString(
url);
 
 
   76      if ( !conf.geoipEnabled() ) {
 
   77        MIL << 
"GeoIp rewrites disabled via ZConfig." << std::endl;
 
   81      if ( !( 
url.getQueryParam(
"COUNTRY").empty() && 
url.getQueryParam(
"AVOID_COUNTRY").empty() )) {
 
   82        MIL << 
"GeoIp rewrites disabled since the baseurl " << 
url << 
" uses an explicit country setting." << std::endl;
 
   86      const auto &hostname = 
url.getHost();
 
   87      auto geoipFile = conf.geoipCachePath() / hostname ;
 
   88      if ( 
PathInfo( geoipFile ).isFile() ) {
 
   90        MIL << 
"Found GeoIP file for host: " << hostname << std::endl;
 
   92        std::ifstream in( geoipFile.asString() );
 
   94          MIL << 
"Failed to open GeoIP for host: " << hostname << std::endl;
 
  105          MIL << 
"Found GeoIP rewrite: " << hostname << 
" -> " << newHost << std::endl;
 
  111          MIL << 
"No valid GeoIP rewrite target found for " << 
url << std::endl;
 
  116      MIL << 
"Failed to query GeoIP data, url rewriting disabled." << std::endl;
 
 
  137    for ( filesystem::DirContent::const_iterator it = content.begin(); it != content.end(); ++it ) {
 
  138        Pathname filename = dirname + it->name;
 
  141        switch ( it->type ) {
 
  148            getDir( filename, recurse_r );
 
  150            res = assert_dir( 
localPath( filename ) );
 
  152              WAR << 
"Ignore error (" << res <<  
") on creating local directory '" << 
localPath( filename ) << 
"'" << endl;
 
 
  164                                 const Pathname & dirname, 
bool dots )
 const 
 
  170                              const Pathname & dirname, 
bool dots )
 const 
 
  183                                                  "X-ZYpp-AnonymousId: %s",
 
  186    return _value.c_str();
 
 
  197                                                  "X-ZYpp-DistributionFlavor: %s",
 
  200    return _value.c_str();
 
 
  205    static const zypp::str::regex invalidRewrites(
"^.*\\/repomd.xml(.asc|.key)?$|^\\/geoip$");
 
  214      MIL << 
"Redirecting " << filename_r << 
" request to geoip location." << std::endl;
 
  217    Url newurl { baseUrl };
 
 
  229                                                "ZYpp " LIBZYPP_VERSION_STRING 
" (curl %s) %s",
 
  230                                                curl_version_info(CURLVERSION_NOW)->version,
 
  232    return _value.c_str();
 
 
  257        if ( u.hasConfig (
"http-headers") ) {
 
  260            std::string header { el.first };
 
  263            MIL << 
"Added custom header -> " << header << std::endl;
 
  269        if ( u.url().getHost() == 
"download.opensuse.org" )
 
  280        if ( set.
proxy().empty() )
 
  296          const auto cred = cm.
getCred( u.url() );
 
  297          if ( cred && cred->valid() ) {
 
 
  329    std::vector<unsigned> mirrOrder;
 
  331      MIL << 
"Fetching file " << loc << 
" from authority only: " << 
_origin << std::endl;
 
  332      mirrOrder.push_back (0); 
 
  334      mirrOrder.reserve( 
_origin.endpointCount() );
 
  335      for( 
unsigned i = 1; i < 
_origin.endpointCount () ; i++ ) { mirrOrder.push_back(i) ;}
 
  336      mirrOrder.push_back(0); 
 
 
  348    if (cmcred && firstTry)
 
  351      DBG << 
"got stored credentials:" << endl << *credentials << endl;
 
  362      if (!
url.getUsername().empty() && firstTry)
 
  363        curlcred->setUsername(
url.getUsername());
 
  366        curlcred->setUsername(cmcred->username());
 
  371      std::string prompt_msg = 
str::Format(
_(
"Authentication required for '%s'")) % 
url.asString();
 
  375      curlcred->setAuthType(availAuthTypes);
 
  378      if (auth_report->prompt(
url, prompt_msg, *curlcred))
 
  380        DBG << 
"callback answer: retry" << endl
 
  381            << 
"CurlAuthData: " << *curlcred << endl;
 
  383        if (curlcred->valid())
 
  385          credentials = curlcred;
 
  399        DBG << 
"callback answer: cancel" << endl;
 
  410      if (credentials->authType() == CURLAUTH_NONE)
 
  411        credentials->setAuthType(availAuthTypes);
 
  414      if (credentials->authType() != CURLAUTH_NONE) {
 
  415        settings.
setAuthType(credentials->authTypeAsString());
 
  420        credentials->setUrl(
url);
 
 
Base class for Exception.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Represents a single, configurable network endpoint, combining a URL with specific access settings.
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
std::string anonymousUniqueId() const
anonymous unique id
std::string targetDistribution() const
This is register.target attribute of the installed base product.
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
static ZConfig & instance()
Singleton ctor.
Wrapper class for stat/lstat.
const std::string & asString() const
String representation.
Pathname absolutename() const
Return this path, adding a leading '/' if relative.
bool matches(const char *s, str::smatch &matches, int flags=none) const
void fillSettingsFromUrl(const Url &url, media::TransferSettings &s)
Fills the settings structure using options passed on the url for example ?timeout=x&proxy=foo.
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
std::list< DirEntry > DirContent
Returned by readdir.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string trim(const std::string &s, const Trim trim_r)
std::string asString(const Patch::Category &obj)
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.