libzypp  13.10.6
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);
47 
48  virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, RequestOptions options = OPTION_NONE ) const;
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;
51 
52 protected:
53 
54  bool isDNSok(const std::string &host) const;
55  void setDNSok(const std::string &host) const;
56 
57  CURL *fromEasyPool(const std::string &host) const;
58  void toEasyPool(const std::string &host, CURL *easy) const;
59 
60  virtual void setupEasy();
61  void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const;
62  static int progressCallback( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow );
63 
64 private:
65  // the custom headers from MediaCurl plus a "Accept: metalink" header
67  mutable CURLM *_multi; // reused for all fetches so we can make use of the dns cache
68  mutable std::set<std::string> _dnsok;
69  mutable std::map<std::string, CURL *> _easypool;
70 };
71 
73 
74  } // namespace media
75 } // namespace zypp
76 
77 #endif // ZYPP_MEDIA_MEDIAMULTICURL_H
void setDNSok(const std::string &host) const
virtual void setupEasy()
initializes the curl easy handle with the data from the url
std::set< std::string > _dnsok
Implementation class for FTP, HTTP and HTTPS MediaHandler.
Definition: MediaCurl.h:32
std::map< std::string, CURL * > _easypool
CURL * fromEasyPool(const std::string &host) const
void toEasyPool(const std::string &host, CURL *easy) const
bool isDNSok(const std::string &host) const
MediaMultiCurl(const Url &url_r, const Pathname &attach_point_hint_r)
void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:178
curl_slist * _customHeadersMetalink
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
virtual void doGetFileCopy(const Pathname &srcFilename, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const
static int progressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
Url url() const
Url used.
Definition: MediaHandler.h:506
Url manipulation class.
Definition: Url.h:87