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

libzypp 17.38.11

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
60void prepareSettingsAndUrl(zypp::Url &url_r, zypp::media::TransferSettings &s );
61
62void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
63void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
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
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
Url.h
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:432
internal::curlUnEscape
std::string curlUnEscape(const std::string &text_r)
Definition curlhelper.cc:394
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:389
internal::setCurlRedirProtocols
CURLcode setCurlRedirProtocols(CURL *curl)
Definition curlhelper.cc:544
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:359
internal::clearQueryString
Url clearQueryString(const Url &url)
Definition curlhelper.cc:401
internal::curlEscape
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition curlhelper.cc:381
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 CodePitfalls.doc:2
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:458
internal::CurlPollHelper::CurlPollHelper
CurlPollHelper(CurlPoll &p)
Definition curlhelper.cc:444
internal::CurlPollHelper::handleSocketActions
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition curlhelper.cc:501
internal::CurlPollHelper::handleTimout
CURLMcode handleTimout()
Definition curlhelper.cc:528
internal::CurlPollHelper::~CurlPollHelper
~CurlPollHelper()
Definition curlhelper.cc:451
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:491