libzypp: zypp-curl/private/curlhelper_p.h Source File

libzypp 17.36.6

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
41 int ZYPP_MEDIA_CURL_IPRESOLVE();
42 } // namespace env
43} //namespace zypp
44
45//do not export
46namespace internal {
47
48void globalInitCurlOnce();
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
56void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
57void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
58
59void curlEscape( std::string & str_r, const char char_r, const std::string & escaped_r );
60std::string curlEscapedPath( std::string path_r );
61std::string curlUnEscape( const std::string& text_r );
62
63 zypp::Url clearQueryString(const zypp::Url &url);
64 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
65
66CURLcode setCurlRedirProtocols(CURL *curl);
67
72 struct CurlPollHelper
73{
74 struct CurlPoll {
75 CURLM *_multi = nullptr;
76 };
77
78 CurlPollHelper( CurlPoll &p );
79 ~CurlPollHelper();
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
102 CurlPoll &_parent;
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
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::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:183
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:411
internal::curlUnEscape
std::string curlUnEscape(const std::string &text_r)
Definition curlhelper.cc:373
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:368
internal::setCurlRedirProtocols
CURLcode setCurlRedirProtocols(CURL *curl)
Definition curlhelper.cc:523
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:338
internal::clearQueryString
Url clearQueryString(const Url &url)
Definition curlhelper.cc:380
internal::curlEscape
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition curlhelper.cc:360
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:74
internal::CurlPollHelper::CurlPoll::_multi
CURLM * _multi
Definition curlhelper_p.h:75
internal::CurlPollHelper::socketcb
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
Definition curlhelper.cc:437
internal::CurlPollHelper::CurlPollHelper
CurlPollHelper(CurlPoll &p)
Definition curlhelper.cc:423
internal::CurlPollHelper::handleSocketActions
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition curlhelper.cc:480
internal::CurlPollHelper::handleTimout
CURLMcode handleTimout()
Definition curlhelper.cc:507
internal::CurlPollHelper::~CurlPollHelper
~CurlPollHelper()
Definition curlhelper.cc:430
internal::CurlPollHelper::socks
std::vector< GPollFD > socks
Definition curlhelper_p.h:103
internal::CurlPollHelper::_parent
CurlPoll & _parent
Definition curlhelper_p.h:102
internal::CurlPollHelper::timeout_ms
std::optional< long > timeout_ms
Definition curlhelper_p.h:104
internal::CurlPollHelper::timercb
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)
Definition curlhelper.cc:470
Url.h