allow libcurl to take proxy from environment iff proxy is not configured or disallowe...
authorMichael Andres <ma@suse.de>
Mon, 25 Jun 2012 10:33:05 +0000 (12:33 +0200)
committerMichael Andres <ma@suse.de>
Mon, 25 Jun 2012 10:33:05 +0000 (12:33 +0200)
zypp/media/MediaCurl.cc
zypp/media/MediaManager.h

index 9dc8596..8165d74 100644 (file)
@@ -43,6 +43,8 @@
 #define  TRANSFER_TIMEOUT       60 * 3
 #define  TRANSFER_TIMEOUT_MAX   60 * 60
 
+#define EXPLICITLY_NO_PROXY "_none_"
+
 #undef CURLVERSION_AT_LEAST
 #define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
 
@@ -286,12 +288,12 @@ void fillSettingsFromUrl( const Url &url, TransferSettings &s )
     param = url.getQueryParam( "proxy" );
     if ( ! param.empty() )
     {
-        if ( param == "_none_" ) {
+        if ( param == EXPLICITLY_NO_PROXY ) {
            // Workaround TransferSettings shortcoming: With an
            // empty proxy string, code will continue to look for
            // valid proxy settings. So set proxy to some non-empty
            // string, to indicate it has been explicitly disabled.
-           s.setProxy("_none_");
+           s.setProxy(EXPLICITLY_NO_PROXY);
             s.setProxyEnabled(false);
         }
         else {
@@ -669,12 +671,19 @@ void MediaCurl::setupEasy()
       SET_OPTION(CURLOPT_PROXYUSERPWD, unEscape( proxyuserpwd ).c_str());
     }
   }
-  else
-  {
-      DBG << "Proxy: NOPROXY" << endl;
 #if CURLVERSION_AT_LEAST(7,19,4)
-      SET_OPTION(CURLOPT_NOPROXY, "*");
+  else if ( _settings.proxy() == EXPLICITLY_NO_PROXY )
+  {
+    // Explicitly disabled in URL (see fillSettingsFromUrl()).
+    // This should also prevent libcurl from looking into the environment.
+    DBG << "Proxy: explicitly NOPROXY" << endl;
+    SET_OPTION(CURLOPT_NOPROXY, "*");
+  }
 #endif
+  else
+  {
+    // libcurl may look into the enviroanment
+    DBG << "Proxy: not explicitly set" << endl;
   }
 
   /** Speed limits */
index 107201e..c3a3155 100644 (file)
@@ -383,6 +383,8 @@ namespace zypp
      *       Turn off using cookies by setting it to "0" (or false, no, off).
      *     - <tt>proxy</tt>:
      *       A proxy hostname or hostname and port separated by ':'.
+     *       Setting the hostname to '_none_' explicitly disables the use of a
+     *       proxy even if configured in /etc/sysconfig/proxy or the environment.
      *     - <tt>proxyport</tt>:
      *       Alternative way to provide the proxy port.
      *     - <tt>proxyuser</tt>: