libzypp 17.36.7

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
20#include <zypp/media/MediaHandler.h>
21#include <zypp/media/MediaCurl.h>
22#include <zypp-curl/parser/MediaBlockList>
23#include <zypp-curl/TransferSettings>
24#include <zypp/ZYppCallbacks.h>
25
26 namespace zypp {
27 namespace media {
28
36
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 void doGetFileCopy( const OnMediaLocation & srcFile, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, RequestOptions options = OPTION_NONE ) const override;
49
50 void multifetch(const Pathname &filename, FILE *fp, std::vector<Url> *urllist, MediaBlockList &&blklist, callback::SendReport<DownloadProgressReport> *report = 0, off_t filesize = off_t(-1)) const;
51
56 void multifetch(const Pathname &filename, FILE *fp, std::vector<Url> *urllist, callback::SendReport<DownloadProgressReport> *report, MediaBlockList &&blklist, const ByteCount & filesize ) const
57 { multifetch( filename, fp, urllist, std::move(blklist), report, ( filesize ? off_t(filesize) : off_t(-1) ) ); }
58
59 protected:
60
61 bool isDNSok(const std::string &host) const;
62 void setDNSok(const std::string &host) const;
63
64 CURL *fromEasyPool(const std::string &host) const;
65 void toEasyPool(const std::string &host, CURL *easy) const;
66
67 void setupEasy() override;
68 void checkFileDigest(Url &url, FILE *fp, MediaBlockList &blklist) const;
69 static int progressCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow );
70
71 private:
72 // the custom headers from MediaCurl plus a "Accept: metalink" header
73 curl_slist *_customHeadersMetalink;
74 mutable CURLM *_multi; // reused for all fetches so we can make use of the dns cache
75 mutable std::set<std::string> _dnsok;
76 mutable std::map<std::string, CURL *> _easypool;
77};
78
80
81 } // namespace media
82} // namespace zypp
83
84#endif // ZYPP_MEDIA_MEDIAMULTICURL_H
MediaCurl.h
MediaHandler.h
ZYppCallbacks.h
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition onmedialocation.h:37
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::media::MediaBlockList
Definition mediablocklist.h:36
zypp::media::MediaCurl::OPTION_NONE
@ OPTION_NONE
Defaults.
Definition MediaCurl.h:37
zypp::media::MediaCurl::MediaCurl
MediaCurl(const Url &url_r, const Pathname &attach_point_hint_r)
Definition MediaCurl.cc:207
zypp::media::MediaMultiCurl::setupEasy
void setupEasy() override
initializes the curl easy handle with the data from the url
Definition MediaMultiCurl.cc:1404
zypp::media::MediaMultiCurl::_easypool
std::map< std::string, CURL * > _easypool
Definition MediaMultiCurl.h:76
zypp::media::MediaMultiCurl::multifetchrequest
friend class multifetchrequest
Definition MediaMultiCurl.h:42
zypp::media::MediaMultiCurl::_customHeadersMetalink
curl_slist * _customHeadersMetalink
Definition MediaMultiCurl.h:73
zypp::media::MediaMultiCurl::checkFileDigest
void checkFileDigest(Url &url, FILE *fp, MediaBlockList &blklist) const
Definition MediaMultiCurl.cc:1782
zypp::media::MediaMultiCurl::setDNSok
void setDNSok(const std::string &host) const
Definition MediaMultiCurl.cc:1803
zypp::media::MediaMultiCurl::MediaMultiCurl
MediaMultiCurl(const Url &url_r, const Pathname &attach_point_hint_r)
Definition MediaMultiCurl.cc:1372
zypp::media::MediaMultiCurl::_dnsok
std::set< std::string > _dnsok
Definition MediaMultiCurl.h:75
zypp::media::MediaMultiCurl::multifetchworker
friend class multifetchworker
Definition MediaMultiCurl.h:43
zypp::media::MediaMultiCurl::isDNSok
bool isDNSok(const std::string &host) const
Definition MediaMultiCurl.cc:1798
zypp::media::MediaMultiCurl::multifetch
void multifetch(const Pathname &filename, FILE *fp, std::vector< Url > *urllist, MediaBlockList &&blklist, callback::SendReport< DownloadProgressReport > *report=0, off_t filesize=off_t(-1)) const
Definition MediaMultiCurl.cc:1716
zypp::media::MediaMultiCurl::progressCallback
static int progressCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
Definition MediaMultiCurl.cc:1423
zypp::media::MediaMultiCurl::fromEasyPool
CURL * fromEasyPool(const std::string &host) const
Definition MediaMultiCurl.cc:1808
zypp::media::MediaMultiCurl::~MediaMultiCurl
~MediaMultiCurl() override
Definition MediaMultiCurl.cc:1380
zypp::media::MediaMultiCurl::doGetFileCopy
void doGetFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const override
Definition MediaMultiCurl.cc:1474
zypp::media::MediaMultiCurl::toEasyPool
void toEasyPool(const std::string &host, CURL *easy) const
Definition MediaMultiCurl.cc:1817
zypp::media::MediaMultiCurl::_multi
CURLM * _multi
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:56
zypp::media::multifetchrequest
Definition MediaMultiCurl.cc:232
zypp::media::multifetchworker
Definition MediaMultiCurl.cc:142
zypp::media
Definition MediaCD.cc:47
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::callback::SendReport
Definition Callback.h:237