libzypp  17.23.5
MediaMultiCurl.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_MEDIA_MEDIAMULTICURL_H
13 #define ZYPP_MEDIA_MEDIAMULTICURL_H
14 
15 #include <string>
16 #include <vector>
17 #include <list>
18 #include <set>
19 
21 #include <zypp/media/MediaCurl.h>
24 #include <zypp/ZYppCallbacks.h>
25 
26 namespace zypp {
27  namespace media {
28 
37 class multifetchrequest;
38 class multifetchworker;
39 
40 class MediaMultiCurl : public MediaCurl {
41 public:
42  friend class multifetchrequest;
43  friend class multifetchworker;
44 
45  MediaMultiCurl(const Url &url_r, const Pathname & attach_point_hint_r);
46  ~MediaMultiCurl() override;
47 
48  virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, const ByteCount &expectedFileSize_r, RequestOptions options = OPTION_NONE ) const override;
49 
50  void multifetch(const Pathname &filename, FILE *fp, std::vector<Url> *urllist, callback::SendReport<DownloadProgressReport> *report = 0, MediaBlockList *blklist = 0, off_t filesize = off_t(-1)) const;
55  void multifetch(const Pathname &filename, FILE *fp, std::vector<Url> *urllist, callback::SendReport<DownloadProgressReport> *report, MediaBlockList *blklist, const ByteCount & filesize ) const
56  { multifetch( filename, fp, urllist, report, blklist, ( filesize ? off_t(filesize) : off_t(-1) ) ); }
57 
58 protected:
59 
60  bool isDNSok(const std::string &host) const;
61  void setDNSok(const std::string &host) const;
62 
63  CURL *fromEasyPool(const std::string &host) const;
64  void toEasyPool(const std::string &host, CURL *easy) const;
65 
66  virtual void setupEasy() override;
67  void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const;
68  static int progressCallback( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow );
69 
70 private:
71  // the custom headers from MediaCurl plus a "Accept: metalink" header
73  mutable CURLM *_multi; // reused for all fetches so we can make use of the dns cache
74  mutable std::set<std::string> _dnsok;
75  mutable std::map<std::string, CURL *> _easypool;
76 };
77 
79 
80  } // namespace media
81 } // namespace zypp
82 
83 #endif // ZYPP_MEDIA_MEDIAMULTICURL_H
zypp::media::MediaMultiCurl::_customHeadersMetalink
curl_slist * _customHeadersMetalink
Definition: MediaMultiCurl.h:72
zypp::media::MediaMultiCurl::_dnsok
std::set< std::string > _dnsok
Definition: MediaMultiCurl.h:74
zypp::media::MediaMultiCurl::multifetch
void multifetch(const Pathname &filename, FILE *fp, std::vector< Url > *urllist, callback::SendReport< DownloadProgressReport > *report, MediaBlockList *blklist, const ByteCount &filesize) const
Definition: MediaMultiCurl.h:55
zypp::callback::SendReport
Definition: Callback.h:236
zypp::media::MediaBlockList
Definition: MediaBlockList.h:35
zypp::media::MediaMultiCurl::setupEasy
virtual void setupEasy() override
initializes the curl easy handle with the data from the url
Definition: MediaMultiCurl.cc:1194
MediaHandler.h
zypp::media::MediaCurl
Implementation class for FTP, HTTP and HTTPS MediaHandler.
Definition: MediaCurl.h:32
report
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:70
zypp::media::MediaMultiCurl::toEasyPool
void toEasyPool(const std::string &host, CURL *easy) const
Definition: MediaMultiCurl.cc:1584
zypp::media::MediaMultiCurl::setDNSok
void setDNSok(const std::string &host) const
Definition: MediaMultiCurl.cc:1570
zypp::ByteCount
Store and operate with byte count.
Definition: ByteCount.h:30
MediaBlockList.h
ZYppCallbacks.h
TransferSettings.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::media::MediaHandler::url
Url url() const
Url used.
Definition: MediaHandler.h:507
zypp::media::MediaMultiCurl::fromEasyPool
CURL * fromEasyPool(const std::string &host) const
Definition: MediaMultiCurl.cc:1575
zypp::media::MediaMultiCurl::progressCallback
static int progressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
Definition: MediaMultiCurl.cc:1248
zypp::media::MediaMultiCurl::~MediaMultiCurl
~MediaMultiCurl() override
Definition: MediaMultiCurl.cc:1170
zypp::media::MediaMultiCurl::_multi
CURLM * _multi
Definition: MediaMultiCurl.h:73
zypp::media::MediaMultiCurl::checkFileDigest
void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const
Definition: MediaMultiCurl.cc:1549
zypp::media::MediaMultiCurl
Definition: MediaMultiCurl.h:40
zypp::media::multifetchworker
Definition: MediaMultiCurl.cc:50
zypp::media::multifetchrequest
Definition: MediaMultiCurl.cc:115
zypp::media::MediaMultiCurl::doGetFileCopy
virtual void doGetFileCopy(const Pathname &srcFilename, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, const ByteCount &expectedFileSize_r, RequestOptions options=OPTION_NONE) const override
Definition: MediaMultiCurl.cc:1299
zypp::media::MediaCurl::OPTION_NONE
Defaults.
Definition: MediaCurl.h:38
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zypp::media::MediaMultiCurl::MediaMultiCurl
MediaMultiCurl(const Url &url_r, const Pathname &attach_point_hint_r)
Definition: MediaMultiCurl.cc:1162
zypp::media::MediaMultiCurl::isDNSok
bool isDNSok(const std::string &host) const
Definition: MediaMultiCurl.cc:1565
MediaCurl.h
zypp::Url
Url manipulation class.
Definition: Url.h:87
zypp::media::MediaMultiCurl::_easypool
std::map< std::string, CURL * > _easypool
Definition: MediaMultiCurl.h:75
zypp::media::MediaMultiCurl::multifetch
void multifetch(const Pathname &filename, FILE *fp, std::vector< Url > *urllist, callback::SendReport< DownloadProgressReport > *report=0, MediaBlockList *blklist=0, off_t filesize=off_t(-1)) const
Definition: MediaMultiCurl.cc:1497