libzypp  17.37.5
curlhelper.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include "private/curlhelper_p.h"
13 
14 #include <zypp-core/Globals.h>
15 
16 #include <zypp-core/fs/PathInfo.h>
17 #include <zypp-core/Pathname.h>
19 #include <zypp-core/base/String.h>
20 #include <zypp-core/base/StringV.h>
21 #include <zypp-curl/ProxyInfo>
22 #include <zypp-curl/auth/CurlAuthData>
23 #include <zypp-media/MediaException>
24 #include <string>
25 #include <glib.h>
26 
27 #define TRANSFER_TIMEOUT_MAX 60 * 60
28 
29 using std::endl;
30 using namespace zypp;
31 
32 namespace zypp
33 {
34  namespace env
35  {
36  const long & ZYPP_MEDIA_CURL_DEBUG()
37  {
38  static const long ret = [](){
39  const char * env = getenv("ZYPP_MEDIA_CURL_DEBUG");
40  return env && *env ? str::strtonum<ulong>( env ) : 0;
41  }();
42  return ret;
43  }
44 
46  {
47  static int _v = [](){
48  int ret = 0;
49  if ( const char * envp = getenv( "ZYPP_MEDIA_CURL_IPRESOLVE" ) ) {
50  WAR << "env set: $ZYPP_MEDIA_CURL_IPRESOLVE='" << envp << "'" << std::endl;
51  if ( strcmp( envp, "4" ) == 0 ) ret = 4;
52  else if ( strcmp( envp, "6" ) == 0 ) ret = 6;
53  }
54  return ret;
55  }();
56  return _v;
57  }
58  } // namespace env
59 } // namespace zypp
60 
61 namespace internal
62 {
63 
65 {
66  // function-level static <=> std::call_once
67  static bool once __attribute__ ((__unused__)) = ( [] {
68  MIL << "global_init libcurl: build version: (" << LIBCURL_VERSION << "), runtime version: (" << curl_version_info(CURLVERSION_NOW)->version << ") " << endl;
69  if ( curl_global_init( CURL_GLOBAL_ALL ) != 0 )
70  WAR << "curl global init failed" << std::endl;
71  } (), true );
72 }
73 
75 {
76  auto curlV = curl_version_info ( CURLVERSION_NOW );
77  return curlV->version_num;
78 }
79 
80 int log_curl( CURL * curl, curl_infotype info, char * ptr, size_t len, void * max_lvl )
81 {
82  if ( max_lvl == nullptr )
83  return 0;
84 
85  long maxlvl = *(static_cast<long*>(max_lvl));
86  const char * pfx = "";
87  bool isContent = true; // otherwise it's data
88  switch( info )
89  {
90  case CURLINFO_TEXT: if ( maxlvl < 1 ) return 0; pfx = "*"; break;
91  case CURLINFO_HEADER_IN: if ( maxlvl < 2 ) return 0; pfx = "<"; break;
92  case CURLINFO_HEADER_OUT: if ( maxlvl < 2 ) return 0; pfx = ">"; break;
93  case CURLINFO_SSL_DATA_IN: if ( maxlvl < 3 ) return 0; isContent = false; pfx = "<[SSL]"; break;
94  case CURLINFO_SSL_DATA_OUT: if ( maxlvl < 3 ) return 0; isContent = false; pfx = ">[SSL]"; break;
95  case CURLINFO_DATA_IN: if ( maxlvl < 3 ) return 0; isContent = false; pfx = "<[DTA]"; break;
96  case CURLINFO_DATA_OUT: if ( maxlvl < 3 ) return 0; isContent = false; pfx = ">[DTA]"; break;
97 
98  default:
99  return 0;
100  }
101 
102  // We'd like to keep all log messages within function `log_curl`
103  // because this tag to grep for is known and communicate to users.
104  if ( isContent ) {
105  std::vector<std::string_view> lines; // don't want log from within the lambda
106  strv::split( std::string_view( ptr, len ), "\n", [&lines]( std::string_view line, unsigned, bool last ) {
107  if ( last ) return; // empty word after final \n
108  line = strv::rtrim( line, "\r" );
109  lines.push_back( line );
110  });
111  for ( const auto & line : lines ) {
112  if ( str::hasPrefix( line, "Authorization:" ) ) {
113  std::string_view::size_type pos { line.find( " ", 15 ) }; // Authorization: <type> <credentials>
114  if ( pos == std::string::npos )
115  pos = 15;
116  DBG << curl << " " << pfx << " " << line.substr( 0, pos ) << " <credentials removed>" << endl;
117  }
118  else
119  DBG << curl << " " << pfx << " " << line << endl;
120  }
121  } else {
122  if ( maxlvl < 4 )
123  DBG << curl << " " << pfx << " " << len << " byte" << endl;
124  else
125  hexdumpOn( DBG << curl << " " << pfx << " ", ptr, len );
126  }
127  return 0;
128 }
129 
130 void setupZYPP_MEDIA_CURL_DEBUG( CURL *curl )
131 {
132  if ( not curl ) {
133  INT << "Got a NULL curl handle" << endl;
134  return;
135  }
136  if ( env::ZYPP_MEDIA_CURL_DEBUG() > 0 ) {
137  curl_easy_setopt( curl, CURLOPT_VERBOSE, 1L );
138  curl_easy_setopt( curl, CURLOPT_DEBUGFUNCTION, log_curl );
139  curl_easy_setopt( curl, CURLOPT_DEBUGDATA, &env::ZYPP_MEDIA_CURL_DEBUG() );
140  }
141 }
142 
143 size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata)
144 {
145  //INT << "got header: " << std::string(ptr, ptr + size*nmemb) << endl;
146 
147  char * lstart = ptr, * lend = ptr;
148  size_t pos = 0;
149  size_t max = size * nmemb;
150  while (pos + 1 < max)
151  {
152  // get line
153  for (lstart = lend; *lend != '\n' && pos < max; ++lend, ++pos);
154 
155  // look for "Location"
156  if ( strncasecmp( lstart, "Location:", 9 ) == 0 )
157  {
158  std::string line { lstart, *(lend-1)=='\r' ? lend-1 : lend };
159  DBG << "redirecting to " << line << std::endl;
160  if ( userdata ) {
161  *reinterpret_cast<std::string *>( userdata ) = line;
162  }
163  return max;
164  }
165 
166  // continue with the next line
167  if (pos + 1 < max)
168  {
169  ++lend;
170  ++pos;
171  }
172  else
173  break;
174  }
175 
176  return max;
177 }
178 
179 
181 {
182  ::internal::fillSettingsFromUrl ( url_r, s );
183 
184  // if the proxy was not set (or explicitly unset) by url, then look...
185  if ( s.proxy().empty() )
186  ::internal::fillSettingsSystemProxy( url_r, s );
187 
188  // remove extra options from the URL
189  url_r = ::internal::clearQueryString( url_r );
190 }
191 
197 {
198  {
199  const std::string & param { url.getQueryParam("timeout") };
200  if( ! param.empty() )
201  {
202  long num = str::strtonum<long>(param);
203  if( num >= 0 && num <= TRANSFER_TIMEOUT_MAX )
204  s.setTimeout( num );
205  }
206  }
207  {
208  std::string param { url.getUsername() };
209  if ( ! param.empty() )
210  {
211  s.setUsername( std::move(param) );
212  param = url.getPassword();
213  if ( ! param.empty() )
214  s.setPassword( std::move(param) );
215  }
216  else
217  {
218  // if there is no username, set anonymous auth
219  if ( ( url.getScheme() == "ftp" || url.getScheme() == "tftp" ) && s.username().empty() )
220  s.setAnonymousAuth();
221  }
222  }
223  if ( url.getScheme() == "https" )
224  {
225  s.setVerifyPeerEnabled( false );
226  s.setVerifyHostEnabled( false );
227 
228  const std::string & verify { url.getQueryParam("ssl_verify") };
229  if( verify.empty() || verify == "yes" )
230  {
231  s.setVerifyPeerEnabled( true );
232  s.setVerifyHostEnabled( true );
233  }
234  else if ( verify == "no" )
235  {
236  s.setVerifyPeerEnabled( false );
237  s.setVerifyHostEnabled( false );
238  }
239  else
240  {
241  std::vector<std::string> flags;
242  str::split( verify, std::back_inserter(flags), "," );
243  for ( const auto & flag : flags )
244  {
245  if ( flag == "host" )
246  s.setVerifyHostEnabled( true );
247  else if ( flag == "peer" )
248  s.setVerifyPeerEnabled( true );
249  else
250  ZYPP_THROW( media::MediaBadUrlException(url, "Unknown ssl_verify flag "+flag) );
251  }
252  }
253  }
254  {
255  Pathname ca_path { url.getQueryParam("ssl_capath") };
256  if( ! ca_path.empty() )
257  {
258  if( ! PathInfo(ca_path).isDir() || ! ca_path.absolute() )
259  ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_capath path"));
260  else
261  s.setCertificateAuthoritiesPath( std::move(ca_path) );
262  }
263  }
264  {
265  Pathname client_cert { url.getQueryParam("ssl_clientcert") };
266  if( ! client_cert.empty() )
267  {
268  if( ! PathInfo(client_cert).isFile() || ! client_cert.absolute() )
269  ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_clientcert file"));
270  else
271  s.setClientCertificatePath( std::move(client_cert) );
272  }
273  }
274  {
275  Pathname client_key { url.getQueryParam("ssl_clientkey") };
276  if( ! client_key.empty() )
277  {
278  if( ! PathInfo(client_key).isFile() || ! client_key.absolute() )
279  ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_clientkey file"));
280  else
281  s.setClientKeyPath( std::move(client_key) );
282  }
283  }
284  {
285  std::string param { url.getQueryParam( "proxy" ) };
286  if ( ! param.empty() )
287  {
288  if ( param == EXPLICITLY_NO_PROXY ) {
289  // Workaround TransferSettings shortcoming: With an
290  // empty proxy string, code will continue to look for
291  // valid proxy settings. So set proxy to some non-empty
292  // string, to indicate it has been explicitly disabled.
294  s.setProxyEnabled(false);
295  }
296  else {
297  const std::string & proxyport { url.getQueryParam( "proxyport" ) };
298  if ( ! proxyport.empty() ) {
299  param += ":";
300  param += proxyport;
301  }
302  s.setProxy( std::move(param) );
303  s.setProxyEnabled( true );
304  }
305  }
306  }
307  {
308  std::string param { url.getQueryParam( "proxyuser" ) };
309  if ( ! param.empty() )
310  {
311  s.setProxyUsername( std::move(param) );
312  s.setProxyPassword( url.getQueryParam( "proxypass" ) );
313  }
314  }
315  {
316  // HTTP authentication type
317  std::string param { url.getQueryParam("auth") };
318  if ( ! param.empty() && (url.getScheme() == "http" || url.getScheme() == "https") )
319  {
320  try
321  {
322  media::CurlAuthData::auth_type_str2long (param ); // check if we know it
323  }
324  catch ( const media::MediaException & ex_r )
325  {
326  DBG << "Rethrowing as MediaUnauthorizedException.";
327  ZYPP_THROW(media::MediaUnauthorizedException(url, ex_r.msg(), "", ""));
328  }
329  s.setAuthType( std::move(param) );
330  }
331  }
332  {
333  // workarounds
334  const std::string & param { url.getQueryParam("head_requests") };
335  if( ! param.empty() && param == "no" )
336  s.setHeadRequestsAllowed( false );
337  }
338  {
339  const auto &cookieFileParam = url.getQueryParam( "cookies" );
340  if ( !cookieFileParam.empty() && str::strToBool( cookieFileParam, true ) )
341  s.setEnableCookieFile ( true );
342  else
343  s.setEnableCookieFile ( false );
344  }
345 }
346 
352 {
353  media::ProxyInfo proxy_info;
354  if ( proxy_info.useProxyFor( url ) )
355  {
356  // We must extract any 'user:pass' from the proxy url
357  // otherwise they won't make it into curl (.curlrc wins).
358  try {
359  Url u( proxy_info.proxy( url ) );
360  s.setProxy( u.asString( url::ViewOption::WITH_SCHEME + url::ViewOption::WITH_HOST + url::ViewOption::WITH_PORT ) );
361  // don't overwrite explicit auth settings
362  if ( s.proxyUsername().empty() )
363  {
364  s.setProxyUsername( u.getUsername( url::E_ENCODED ) );
365  s.setProxyPassword( u.getPassword( url::E_ENCODED ) );
366  }
367  s.setProxyEnabled( true );
368  }
369  catch (...) {} // no proxy if URL is malformed
370  }
371 }
372 
373 void curlEscape( std::string & str_r,
374  const char char_r, const std::string & escaped_r ) {
375  for ( std::string::size_type pos = str_r.find( char_r );
376  pos != std::string::npos; pos = str_r.find( char_r, pos ) ) {
377  str_r.replace( pos, 1, escaped_r );
378  }
379 }
380 
381 std::string curlEscapedPath( std::string path_r ) {
382  curlEscape( path_r, ' ', "%20" );
383  return path_r;
384 }
385 
386 std::string curlUnEscape( const std::string& text_r ) {
387  char * tmp = curl_unescape( text_r.c_str(), 0 );
388  std::string ret( tmp );
389  curl_free( tmp );
390  return ret;
391 }
392 
394 {
395  Url curlUrl (url);
396  curlUrl.setUsername( "" );
397  curlUrl.setPassword( "" );
398  curlUrl.setPathParams( "" );
399  curlUrl.setFragment( "" );
400  curlUrl.delQueryParams( {
401  "cookies",
402  "proxy",
403  "proxyport",
404  "proxyuser",
405  "proxypass",
406  "ssl_capath",
407  "ssl_verify",
408  "ssl_clientcert",
409  "ssl_clientkey",
410  "timeout",
411  "auth",
412  "username",
413  "password",
414  "mediahandler",
415  "credentials",
416  "head_requests",
417  "mediahandler",
418  } );
419  return curlUrl;
420 }
421 
422 // bsc#933839: propagate proxy settings passed in the repo URL
423 // boo#1127591: propagate ssl settings passed in the repo URL
424 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r )
425 {
426  using namespace std::literals::string_literals;
427  for ( const std::string &param : { "proxy"s, "proxyport"s, "proxyuser"s, "proxypass"s, "ssl_capath"s, "ssl_verify"s } )
428  {
429  const std::string & value( template_r.getQueryParam( param ) );
430  if ( ! value.empty() )
431  url_r.setQueryParam( param, value );
432  }
433  return url_r;
434 }
435 
436 CurlPollHelper::CurlPollHelper(CurlPoll &p) : _parent(p) {
437  curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETFUNCTION, socketcb );
438  curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETDATA, this );
439  curl_multi_setopt( _parent._multi, CURLMOPT_TIMERFUNCTION, timercb );
440  curl_multi_setopt( _parent._multi, CURLMOPT_TIMERDATA, this );
441 }
442 
444  curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETFUNCTION, nullptr );
445  curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETDATA, nullptr );
446  curl_multi_setopt( _parent._multi, CURLMOPT_TIMERFUNCTION, nullptr );
447  curl_multi_setopt( _parent._multi, CURLMOPT_TIMERDATA, nullptr );
448 }
449 
450 int CurlPollHelper::socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp) {
451  auto it = std::find_if( userp->socks.begin(), userp->socks.end(), [&]( const GPollFD &fd){ return fd.fd == s; });
452  gushort events = 0;
453  if ( what == CURL_POLL_REMOVE ) {
454  if ( it == userp->socks.end() ) {
455  WAR << "Ignoring unknown socket in static_socketcb" << std::endl;
456  return 0;
457  }
458  userp->socks.erase(it);
459  return 0;
460  } else if ( what == CURL_POLL_IN ) {
461  events = G_IO_IN | G_IO_HUP | G_IO_ERR;
462  } else if ( what == CURL_POLL_OUT ) {
463  events = G_IO_OUT | G_IO_ERR;
464  } else if ( what == CURL_POLL_INOUT ) {
465  events = G_IO_IN | G_IO_OUT | G_IO_HUP | G_IO_ERR;
466  }
467 
468  if ( it != userp->socks.end() ) {
469  it->events = events;
470  it->revents = 0;
471  } else {
472  userp->socks.push_back(
473  GPollFD{
474  .fd = s,
475  .events = events,
476  .revents = 0
477  }
478  );
479  }
480  return 0;
481 }
482 
483 int CurlPollHelper::timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr) {
484  if ( !thatPtr )
485  return 0;
486  if ( timeout_ms == -1 )
487  thatPtr->timeout_ms.reset(); // curl wants to delete its timer
488  else
489  thatPtr->timeout_ms = timeout_ms; // maximum time curl wants us to sleep
490  return 0;
491 }
492 
493 CURLMcode internal::CurlPollHelper::handleSocketActions( const std::vector<GPollFD> &actionsFds , int first )
494 {
495  for ( size_t sock = first; sock < actionsFds.size(); sock++ ) {
496  const auto &waitFd = actionsFds[sock];
497  if ( waitFd.revents == 0 )
498  continue;
499 
500  int ev = 0;
501  if ( (waitFd.revents & G_IO_HUP) == G_IO_HUP
502  || (waitFd.revents & G_IO_IN) == G_IO_IN ) {
503  ev = CURL_CSELECT_IN;
504  }
505  if ( (waitFd.revents & G_IO_OUT) == G_IO_OUT ) {
506  ev |= CURL_CSELECT_OUT;
507  }
508  if ( (waitFd.revents & G_IO_ERR) == G_IO_ERR ) {
509  ev |= CURL_CSELECT_ERR;
510  }
511 
512  int runn = 0;
513  CURLMcode mcode = curl_multi_socket_action( _parent._multi, waitFd.fd, ev, &runn );
514  if (mcode != CURLM_OK)
515  return mcode;
516  }
517  return CURLM_OK;
518 }
519 
521 {
522  int handles = 0;
523  return curl_multi_socket_action( _parent._multi, CURL_SOCKET_TIMEOUT, 0, &handles );
524 }
525 
536 CURLcode setCurlRedirProtocols(CURL *curl)
537 {
538 #if CURLVERSION_AT_LEAST(7,19,4)
539 #if CURLVERSION_AT_LEAST(7,85,0)
540  // runtime version might be different from build version
541  if( ::internal::curlVersion() >= CURL_VERSION_BITS(7,85,0) ) {
542  return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS_STR, "https" );
543  } else {
544  return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
545  }
546 #else
547  return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
548 #endif
549 #endif // #if CURLVERSION_AT_LEAST(7,19,4)
550  return CURLE_OK;
551 }
552 
553 }
std::string getScheme() const
Returns the scheme name of the URL.
Definition: Url.cc:551
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition: Url.cc:757
void globalInitCurlOnce()
Definition: curlhelper.cc:64
#define MIL
Definition: Logger.h:100
std::string curlUnEscape(const std::string &text_r)
Definition: curlhelper.cc:386
Namespace intended to collect all environment variables we use.
Definition: Env.h:24
size_t log_redirects_curl(char *ptr, size_t size, size_t nmemb, void *userdata)
Definition: curlhelper.cc:143
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: Url.cc:894
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:459
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition: curlhelper.cc:424
Flag to request encoded string(s).
Definition: UrlUtils.h:53
void setPassword(const std::string &val_r)
sets the auth password
Holds transfer setting.
const std::string & proxyUsername() const
proxy auth username
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
Definition: curlhelper.cc:450
#define INT
Definition: Logger.h:104
Url clearQueryString(const Url &url)
Definition: curlhelper.cc:393
bool useProxyFor(const Url &url_r) const
Return true if enabled and url_r does not match noProxy.
Definition: proxyinfo.cc:56
void setPathParams(const std::string &params)
Set the path parameters.
Definition: Url.cc:847
void setUsername(const std::string &val_r)
sets the auth username
std::string curlEscapedPath(std::string path_r)
Definition: curlhelper.cc:381
void setHeadRequestsAllowed(bool allowed)
set whether HEAD requests are allowed
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition: Url.cc:748
Provides API related macros.
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition: Url.cc:740
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition: curlhelper.cc:493
const std::string & username() const
auth username
static const char * lines[][3]
Definition: Table.cc:36
void prepareSettingsAndUrl(zypp::Url &url_r, zypp::media::TransferSettings &s)
Definition: curlhelper.cc:180
void setAnonymousAuth()
sets anonymous authentication (ie: for ftp)
int ZYPP_MEDIA_CURL_IPRESOLVE()
4/6 to force IPv4/v6
Definition: curlhelper.cc:45
struct _GPollFD GPollFD
Definition: ZYppImpl.h:26
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition: curlhelper.cc:373
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition: String.h:602
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition: Url.cc:678
void setAuthType(const std::string &val_r)
set the allowed authentication types
void setProxy(const std::string &val_r)
proxy to use if it is enabled
std::vector< GPollFD > socks
Definition: curlhelper_p.h:109
Just inherits Exception to separate media exceptions.
#define WAR
Definition: Logger.h:101
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:196
void setTimeout(long t)
set the transfer timeout
std::string proxy(const Url &url) const
Definition: proxyinfo.cc:44
std::ostream & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
Definition: LogTools.h:472
std::string rtrim(const std::string &s)
Definition: String.h:582
struct zypp::media::MediaBlock __attribute__
void setProxyPassword(const std::string &val_r)
sets the proxy password
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)
Definition: curlhelper.cc:483
void setupZYPP_MEDIA_CURL_DEBUG(CURL *curl)
Setup CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION according to env::ZYPP_MEDIA_CURL_DEBUG.
Definition: curlhelper.cc:130
void delQueryParams(const std::set< std::string > &params)
remove multiple query parameters at once
Definition: Url.cc:907
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Definition: String.h:500
static long auth_type_str2long(std::string &auth_type_str)
Converts a string of comma separated list of authetication type names into a long of ORed CURLAUTH_* ...
Definition: curlauthdata.cc:50
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:225
uint curlVersion()
Definition: curlhelper.cc:74
void setClientCertificatePath(const Pathname &val_r)
Sets the SSL client certificate file.
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
Definition: curlhelper.cc:351
void setProxyUsername(const std::string &val_r)
sets the proxy user
std::optional< long > timeout_ms
Definition: curlhelper_p.h:110
void setEnableCookieFile(bool enable=true)
Enable or disable the use of the cookie file.
#define TRANSFER_TIMEOUT_MAX
Definition: curlhelper.cc:27
void setCertificateAuthoritiesPath(const Pathname &val_r)
Sets the SSL certificate authorities path.
#define EXPLICITLY_NO_PROXY
Definition: curlhelper_p.h:23
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
SolvableIdType size_type
Definition: PoolMember.h:126
int log_curl(CURL *curl, curl_infotype info, char *ptr, size_t len, void *max_lvl)
Definition: curlhelper.cc:80
CURLcode setCurlRedirProtocols(CURL *curl)
Definition: curlhelper.cc:536
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1098
const std::string & proxy() const
proxy host
void setVerifyPeerEnabled(bool enabled)
Sets whether to verify host for ssl.
void setClientKeyPath(const Pathname &val_r)
Sets the SSL client key file.
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition: Url.cc:598
void setVerifyHostEnabled(bool enabled)
Sets whether to verify host for ssl.
Url manipulation class.
Definition: Url.h:92
void setProxyEnabled(bool enabled)
whether the proxy is used or not
#define DBG
Definition: Logger.h:99
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition: Url.cc:590
const std::string & msg() const
Return the message string provided to the ctor.
Definition: Exception.h:206