libzypp 17.37.17
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
28using GPollFD = struct _GPollFD;
29
30namespace 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
46namespace internal {
47
49
50uint curlVersion();
51
53void setupZYPP_MEDIA_CURL_DEBUG( CURL *curl );
54size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
55
61
64
65void curlEscape( std::string & str_r, const char char_r, const std::string & escaped_r );
66std::string curlEscapedPath( std::string path_r );
67std::string curlUnEscape( const std::string& text_r );
68
70zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
71
72CURLcode setCurlRedirProtocols(CURL *curl);
73
79{
80 struct CurlPoll {
81 CURLM *_multi = nullptr;
82 };
83
86
91 CURLMcode handleSocketActions( const std::vector<GPollFD> &actionsFds, int first = 0 );
92
96 CURLMcode handleTimout ();
97
101 static int socketcb (CURL * easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp );
102
106 static int timercb( CURLM *, long timeout_ms, CurlPollHelper *thatPtr );
107
109 std::vector<GPollFD> socks; //< This is the list of fd's we need to track, events have been set by curl
110 std::optional<long> timeout_ms = 0; //if set curl wants a timeout
111};
112
113}
114
115#endif //ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
struct _GPollFD GPollFD
Definition ZYppImpl.h:26
Url manipulation class.
Definition Url.h:93
Holds transfer setting.
void prepareSettingsAndUrl(zypp::Url &url_r, zypp::media::TransferSettings &s)
void fillSettingsFromUrl(const Url &url, media::TransferSettings &s)
Fills the settings structure using options passed on the url for example ?timeout=x&proxy=foo.
size_t log_redirects_curl(char *ptr, size_t size, size_t nmemb, void *userdata)
void globalInitCurlOnce()
Definition curlhelper.cc:64
uint curlVersion()
Definition curlhelper.cc:74
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
std::string curlUnEscape(const std::string &text_r)
void setupZYPP_MEDIA_CURL_DEBUG(CURL *curl)
Setup CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION according to env::ZYPP_MEDIA_CURL_DEBUG.
std::string curlEscapedPath(std::string path_r)
CURLcode setCurlRedirProtocols(CURL *curl)
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
Url clearQueryString(const Url &url)
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
const long & ZYPP_MEDIA_CURL_DEBUG()
const long& for setting CURLOPT_DEBUGDATA Returns a reference to a static variable,...
Definition curlhelper.cc:36
int ZYPP_MEDIA_CURL_IPRESOLVE()
4/6 to force IPv4/v6
Definition curlhelper.cc:45
Url details namespace.
Definition UrlBase.cc:58
Easy-to use interface to the ZYPP dependency resolver.
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
CurlPollHelper(CurlPoll &p)
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
std::vector< GPollFD > socks
std::optional< long > timeout_ms
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)