libzypp  17.31.31
curlhelper_p.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 ----------------------------------------------------------------------/
9 *
10 * This file contains private API, this might break at any time between releases.
11 * You have been warned!
12 *
13 */
14 #ifndef ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
15 #define ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
16 
17 #include <curl/curl.h>
18 #include <zypp-core/Url.h>
19 #include <zypp-curl/TransferSettings>
20 
21 #include <optional>
22 
23 #define EXPLICITLY_NO_PROXY "_none_"
24 
25 #undef CURLVERSION_AT_LEAST
26 #define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
27 
28 typedef struct _GPollFD GPollFD;
29 
30 namespace zypp
31 {
32  namespace env
33  {
38  const long & ZYPP_MEDIA_CURL_DEBUG();
39 
42  } // namespace env
43 } //namespace zypp
44 
45 //do not export
46 namespace internal {
47 
48 void globalInitCurlOnce();
49 
50 uint curlVersion();
51 
53 void setupZYPP_MEDIA_CURL_DEBUG( CURL *curl );
54 size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
55 
58 
59 void curlEscape( std::string & str_r, const char char_r, const std::string & escaped_r );
60 std::string curlEscapedPath( std::string path_r );
61 std::string curlUnEscape( std::string text_r );
62 
64 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
65 
66 CURLcode setCurlRedirProtocols(CURL *curl);
67 
73 {
74  struct CurlPoll {
75  CURLM *_multi = nullptr;
76  };
77 
80 
85  CURLMcode handleSocketActions( const std::vector<GPollFD> &actionsFds, int first = 0 );
86 
90  CURLMcode handleTimout ();
91 
95  static int socketcb (CURL * easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp );
96 
100  static int timercb( CURLM *, long timeout_ms, CurlPollHelper *thatPtr );
101 
103  std::vector<GPollFD> socks; //< This is the list of fd's we need to track, events have been set by curl
104  std::optional<long> timeout_ms = 0; //if set curl wants a timeout
105 };
106 
107 }
108 
109 #endif //ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
void globalInitCurlOnce()
Definition: curlhelper.cc:64
size_t log_redirects_curl(char *ptr, size_t size, size_t nmemb, void *userdata)
Definition: curlhelper.cc:143
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition: curlhelper.cc:400
Holds transfer setting.
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
Definition: curlhelper.cc:426
Url clearQueryString(const Url &url)
Definition: curlhelper.cc:373
struct _GPollFD GPollFD
Definition: ZYppImpl.h:26
std::string curlEscapedPath(std::string path_r)
Definition: curlhelper.cc:361
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition: curlhelper.cc:469
int ZYPP_MEDIA_CURL_IPRESOLVE()
4/6 to force IPv4/v6
Definition: curlhelper.cc:45
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition: curlhelper.cc:353
std::vector< GPollFD > socks
Definition: curlhelper_p.h:103
const long & ZYPP_MEDIA_CURL_DEBUG()
const long& for setting CURLOPT_DEBUGDATA Returns a reference to a static variable, so it&#39;s safe to pass ...
Definition: curlhelper.cc:36
void fillSettingsFromUrl(const Url &url, media::TransferSettings &s)
Fills the settings structure using options passed on the url for example ?timeout=x&proxy=foo.
Definition: curlhelper.cc:183
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)
Definition: curlhelper.cc:459
std::string curlUnEscape(std::string text_r)
Definition: curlhelper.cc:366
void setupZYPP_MEDIA_CURL_DEBUG(CURL *curl)
Setup CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION according to env::ZYPP_MEDIA_CURL_DEBUG.
Definition: curlhelper.cc:130
uint curlVersion()
Definition: curlhelper.cc:74
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
Definition: curlhelper.cc:331
std::optional< long > timeout_ms
Definition: curlhelper_p.h:104
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
CURLcode setCurlRedirProtocols(CURL *curl)
Definition: curlhelper.cc:512
Url manipulation class.
Definition: Url.h:91
CurlPollHelper(CurlPoll &p)
Definition: curlhelper.cc:412