libzypp 17.37.17
MediaNetworkCommonHandler.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_MEDIA_MEDIANETWORKCOMMONHANDLER_H
12#define ZYPP_MEDIA_MEDIANETWORKCOMMONHANDLER_H
13
15#include <zypp-curl/TransferSettings>
16
18namespace zypp
19{
21 namespace media
22 {
23
25
31 // to avoid duplicated code.
34 {
35 public:
36
37 static constexpr std::string_view MIRR_SETTINGS_KEY = "_zypp_transfersettings";
38
40 const Pathname & attach_point_r,
41 const Pathname & urlpath_below_attachpoint_r,
42 const bool does_download_r );
43
44 public:
49 static zypp::Url findGeoIPRedirect ( const zypp::Url &url );
50
51 void getFile( const OnMediaLocation & file ) const override;
52 void getDir( const Pathname & dirname, bool recurse_r ) const override;
53 void getDirInfo( std::list<std::string> & retlist,
54 const Pathname & dirname, bool dots = true ) const override;
55 void getDirInfo( filesystem::DirContent & retlist,
56 const Pathname & dirname, bool dots = true ) const override;
57
58 protected:
59
60 void attachTo (bool next) override;
61
62 bool checkAttachPoint(const Pathname &apoint) const override;
63
64 Url clearQueryString(const Url &url) const;
65
66
71 Url getFileUrl( int mirrorIdx, const Pathname & filename) const;
72
73
80
81 bool authenticate( const Url &url, TransferSettings &settings, const std::string & availAuthTypes, bool firstTry );
82
87 virtual void checkProtocol(const Url &url) const = 0;
88
89 std::vector<unsigned> mirrorOrder( const OnMediaLocation &loc ) const;
90
91 public:
92
93 // standard auth procedure, shared with CommitPackagePreloader
94 static bool authenticate( const Url &url, CredentialManager &cm, TransferSettings &settings, const std::string & availAuthTypes, bool firstTry);
95
96 static const char *anonymousIdHeader();
97
98 static const char *distributionFlavorHeader();
99
100 static const char *agentString();
101
102 template <typename Excpt>
103 static bool canTryNextMirror( const Excpt &excpt_r ) {
104 // check if we can retry on the next mirror
105 bool fatal = (
106 typeid(excpt_r) == typeid( MediaRequestCancelledException ) ||
107 typeid(excpt_r) == typeid( MediaWriteException ) ||
108 typeid(excpt_r) == typeid( MediaSystemException ) ||
109 typeid(excpt_r) == typeid( MediaCurlInitException ) ||
110 typeid(excpt_r) == typeid( MediaUnauthorizedException )
111 );
112 return !fatal;
113 }
114
115 protected:
116 std::vector<Url> _redirTargets;
117 };
118
119 } // namespace media
121} // namespace zypp
123#endif // ZYPP_MEDIA_MEDIANETWORKCOMMONHANDLER_H
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Describes a resource file located on a medium.
Url manipulation class.
Definition Url.h:93
MediaHandler(MirroredOrigin origin_r, const Pathname &attach_point_r, Pathname urlpath_below_attachpoint_r, const bool does_download_r)
If the concrete media handler provides a nonempty attach_point, it must be an existing directory.
Url url() const
Primary Url used.
bool authenticate(const Url &url, TransferSettings &settings, const std::string &availAuthTypes, bool firstTry)
static bool canTryNextMirror(const Excpt &excpt_r)
void getDir(const Pathname &dirname, bool recurse_r) const override
Call concrete handler to provide directory content (not recursive!) below attach point.
bool checkAttachPoint(const Pathname &apoint) const override
Verify if the specified directory as attach point (root) as requires by the particular media handler ...
std::vector< unsigned > mirrorOrder(const OnMediaLocation &loc) const
Url getFileUrl(int mirrorIdx, const Pathname &filename) const
concatenate the attach url and the filename to a complete download url
void setupTransferSettings()
initializes the curl easy handle with the data from the url
MediaNetworkCommonHandler(const MirroredOrigin &origin_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
virtual void checkProtocol(const Url &url) const =0
check the url is supported by the curl library
void attachTo(bool next) override
Call concrete handler to attach the media.
static constexpr std::string_view MIRR_SETTINGS_KEY
void getFile(const OnMediaLocation &file) const override
Call concrete handler to provide file below attach point.
void getDirInfo(std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const override
Call concrete handler to provide a content list of directory on media via retlist.
static zypp::Url findGeoIPRedirect(const zypp::Url &url)
Rewrites the baseURL to the geoIP target if one is found in the metadata cache, otherwise simply retu...
Holds transfer setting.
std::list< DirEntry > DirContent
Returned by readdir.
Definition PathInfo.h:526
Easy-to use interface to the ZYPP dependency resolver.