libzypp 17.37.10

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 using GPollFD = struct _GPollFD;
29
30 namespace zypp
31{
32 namespace env
33 {
38 const long & ZYPP_MEDIA_CURL_DEBUG();
39
41 int ZYPP_MEDIA_CURL_IPRESOLVE();
42 } // namespace env
43} //namespace zypp
44
45//do not export
46 namespace internal {
47
48 void globalInitCurlOnce();
49
50uint 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
60 void prepareSettingsAndUrl(zypp::Url &url_r, zypp::media::TransferSettings &s );
61
62 void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
63 void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
64
65 void 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
69 zypp::Url clearQueryString(const zypp::Url &url);
70 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
71
72CURLcode setCurlRedirProtocols(CURL *curl);
73
78 struct CurlPollHelper
79{
80 struct CurlPoll {
81 CURLM *_multi = nullptr;
82 };
83
84 CurlPollHelper( CurlPoll &p );
85 ~CurlPollHelper();
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
108 CurlPoll &_parent;
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
GPollFD
struct _GPollFD GPollFD
Definition ZYppImpl.h:26
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::media::TransferSettings
Holds transfer setting.
Definition transfersettings.h:34
internal
Definition OptionalDownloadProgressReport.cc:12
internal::prepareSettingsAndUrl
void prepareSettingsAndUrl(zypp::Url &url_r, zypp::media::TransferSettings &s)
Definition curlhelper.cc:180
internal::fillSettingsFromUrl
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:196
internal::log_redirects_curl
size_t log_redirects_curl(char *ptr, size_t size, size_t nmemb, void *userdata)
Definition curlhelper.cc:143
internal::globalInitCurlOnce
void globalInitCurlOnce()
Definition curlhelper.cc:64
internal::curlVersion
uint curlVersion()
Definition curlhelper.cc:74
internal::propagateQueryParams
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition curlhelper.cc:424
internal::curlUnEscape
std::string curlUnEscape(const std::string &text_r)
Definition curlhelper.cc:386
internal::setupZYPP_MEDIA_CURL_DEBUG
void setupZYPP_MEDIA_CURL_DEBUG(CURL *curl)
Setup CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION according to env::ZYPP_MEDIA_CURL_DEBUG.
Definition curlhelper.cc:130
internal::curlEscapedPath
std::string curlEscapedPath(std::string path_r)
Definition curlhelper.cc:381
internal::setCurlRedirProtocols
CURLcode setCurlRedirProtocols(CURL *curl)
Definition curlhelper.cc:536
internal::fillSettingsSystemProxy
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
Definition curlhelper.cc:351
internal::clearQueryString
Url clearQueryString(const Url &url)
Definition curlhelper.cc:393
internal::curlEscape
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition curlhelper.cc:373
zypp::env::ZYPP_MEDIA_CURL_DEBUG
const long & ZYPP_MEDIA_CURL_DEBUG()
const long& for setting CURLOPT_DEBUGDATA Returns a reference to a static variable,...
Definition curlhelper.cc:36
zypp::env::ZYPP_MEDIA_CURL_IPRESOLVE
int ZYPP_MEDIA_CURL_IPRESOLVE()
4/6 to force IPv4/v6
Definition curlhelper.cc:45
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
internal::CurlPollHelper::CurlPoll
Definition curlhelper_p.h:80
internal::CurlPollHelper::CurlPoll::_multi
CURLM * _multi
Definition curlhelper_p.h:81
internal::CurlPollHelper::socketcb
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
Definition curlhelper.cc:450
internal::CurlPollHelper::CurlPollHelper
CurlPollHelper(CurlPoll &p)
Definition curlhelper.cc:436
internal::CurlPollHelper::handleSocketActions
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition curlhelper.cc:493
internal::CurlPollHelper::handleTimout
CURLMcode handleTimout()
Definition curlhelper.cc:520
internal::CurlPollHelper::~CurlPollHelper
~CurlPollHelper()
Definition curlhelper.cc:443
internal::CurlPollHelper::socks
std::vector< GPollFD > socks
Definition curlhelper_p.h:109
internal::CurlPollHelper::_parent
CurlPoll & _parent
Definition curlhelper_p.h:108
internal::CurlPollHelper::timeout_ms
std::optional< long > timeout_ms
Definition curlhelper_p.h:110
internal::CurlPollHelper::timercb
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)
Definition curlhelper.cc:483
Url.h