libzypp 17.35.19
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
22#include <zypp-curl/parser/MediaBlockList>
23#include <zypp-curl/TransferSettings>
24#include <zypp/ZYppCallbacks.h>
25
26namespace zypp {
27 namespace media {
28
37class multifetchrequest;
38class multifetchworker;
39
40class MediaMultiCurl : public MediaCurl {
41public:
42 friend class multifetchrequest;
43 friend class multifetchworker;
44
46 ~MediaMultiCurl() override;
47
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
59protected:
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
71private:
72 // the custom headers from MediaCurl plus a "Accept: metalink" header
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
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Store and operate with byte count.
Definition ByteCount.h:32
Describes a resource file located on a medium.
Url manipulation class.
Definition Url.h:93
Implementation class for FTP, HTTP and HTTPS MediaHandler.
Definition MediaCurl.h:32
@ OPTION_NONE
Defaults.
Definition MediaCurl.h:37
Url url() const
Url used.
void setupEasy() override
initializes the curl easy handle with the data from the url
std::map< std::string, CURL * > _easypool
void checkFileDigest(Url &url, FILE *fp, MediaBlockList &blklist) const
void setDNSok(const std::string &host) const
MediaMultiCurl(const Url &url_r, const Pathname &attach_point_hint_r)
std::set< std::string > _dnsok
bool isDNSok(const std::string &host) const
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
static int progressCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
CURL * fromEasyPool(const std::string &host) const
void doGetFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const override
void toEasyPool(const std::string &host, CURL *easy) const
void multifetch(const Pathname &filename, FILE *fp, std::vector< Url > *urllist, callback::SendReport< DownloadProgressReport > *report, MediaBlockList &&blklist, const ByteCount &filesize) const
Easy-to use interface to the ZYPP dependency resolver.