Allow yum-style setting of per-repo proxy including
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 20 Sep 2010 15:29:18 +0000 (17:29 +0200)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 20 Sep 2010 15:38:30 +0000 (17:38 +0200)
setting it to _none_ overriding the system proxy.

Patch from Zhang, Qiang <qiang.z.zhang@intel.com>

zypp/media/MediaCurl.cc
zypp/parser/RepoFileReader.cc

index 086bdf1..f7cce4e 100644 (file)
@@ -285,12 +285,17 @@ void fillSettingsFromUrl( const Url &url, TransferSettings &s )
     string proxy = url.getQueryParam( "proxy" );
     if ( ! proxy.empty() )
     {
-        string proxyport( url.getQueryParam( "proxyport" ) );
-        if ( ! proxyport.empty() ) {
-            proxy += ":" + proxyport;
+        if ( proxy == "_none_" ) {
+            s.setProxyEnabled(false);
         }
-        s.setProxy(proxy);
-        s.setProxyEnabled(true);
+        else {
+            string proxyport( url.getQueryParam( "proxyport" ) );
+            if ( ! proxyport.empty() ) {
+                proxy += ":" + proxyport;
+            }
+            s.setProxy(proxy);
+            s.setProxyEnabled(true);
+        }        
     }
 
     // HTTP authentication type
@@ -600,7 +605,11 @@ void MediaCurl::setupEasy()
         SET_OPTION(CURLOPT_PROXYUSERPWD, proxyuserpwd.c_str());
     }
   }
-
+  else
+  {
+      SET_OPTION(CURLOPT_NOPROXY, "*");
+  }
+  
   /** Speed limits */
   if ( _settings.minDownloadSpeed() != 0 )
   {
index 7a41431..d915757 100644 (file)
@@ -12,6 +12,7 @@
 #include <iostream>
 #include "zypp/base/Logger.h"
 #include "zypp/base/String.h"
+#include "zypp/base/Regex.h"
 #include "zypp/base/InputStream.h"
 #include "zypp/base/UserRequestException.h"
 
@@ -44,6 +45,7 @@ namespace zypp
       {
         RepoInfo info;
         info.setAlias(*its);
+        Url url;
 
         for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
               it != dict.entriesEnd(*its);
@@ -57,7 +59,7 @@ namespace zypp
           else if ( it->first == "priority" )
             info.setPriority( str::strtonum<unsigned>( it->second ) );
           else if ( it->first == "baseurl" && !it->second.empty())
-            info.addBaseUrl( Url(it->second) );
+            url = it->second;
           else if ( it->first == "path" )
             info.setPath( Pathname(it->second) );
           else if ( it->first == "type" )
@@ -74,10 +76,24 @@ namespace zypp
            info.setKeepPackages( str::strToTrue( it->second ) );
          else if ( it->first == "service" )
            info.setService( it->second );
-          else
+          else if ( it->first == "proxy" )
+          {
+           if (it->second != "_none_" )
+            { 
+              str::regex ex("^(.*):([0-9]+)$");
+              str::smatch what;
+              if(str::regex_match(it->second, what, ex)){
+               url.setQueryParam("proxy", what[1]);
+               url.setQueryParam("proxyport", what[2]);
+              }
+            }
+          } else
             ERR << "Unknown attribute in [" << *its << "]: " << it->second << " ignored" << endl;
         }
-        info.setFilepath(file);
+        if (url.isValid())
+            info.addBaseUrl(url);
+
+        info.setFilepath(is.path());
         MIL << info << endl;
         // add it to the list.
         callback(info);