Hi, thanks for the patch! Some comments: Thanks for your comments:)
baseurl=http://172.16.119.175 proxy=_none_ #Disable proxy #proxy=http://host:port #enable proxy enabled=1 It also gives the user the option to specify a proxy in the repository file (like with yum). [Zhang, Qiang] Yes.
/** diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc index f0a769d..2f139bc 100644 --- a/zypp/media/MediaAccess.cc +++ b/zypp/media/MediaAccess.cc @@ -132,6 +132,7 @@ MediaAccess::open (const Url& url, const Pathname &
preferred_attach_point)
bool use_multicurl = true; const char *ariaenv = getenv( "ZYPP_ARIA2C" ); const char *multicurlenv = getenv( "ZYPP_MULTICURL" ); + bool disable_proxy = false; // if user disabled it manually if ( use_multicurl && multicurlenv && ( strcmp(multicurlenv, "0" )
== 0 ) )
{ @@ -162,12 +163,18 @@ MediaAccess::open (const Url& url, const Pathname &
preferred_attach_point)
use_aria = false; }
+ Url curlUrl( url ); + if ( curlUrl.getQueryParam("noproxy") == "yes" ){ + curlUrl.removeQueryParam("noproxy"); + disable_proxy = true; + }
Hmm, why handle "noproxy" different from "proxy"? I.e. why is there an extra disable_proxy argument, but all other settings (like "proxy" are detected later on in fillSettingsFromUrl()? [Zhang, Qiang] The "noproxy" param is just added to track the repo not to use proxy, so I think I need to remove this param before transfer to MediaCurl, as MediaCurl -> MediaHandler -> _url is a const type(const Url _url), so I can't remove param from MediaCurl.
So, I add an additional argument in the constructor of MediaCurl and add an additional variable in MediaCurl to note the proxy info for Url.
[...]
{ _curlError[0] = '\0'; @@ -1298,6 +1299,8 @@ void MediaCurl::doGetFileCopyFile( const Pathname & filename , const Pathname & string urlBuffer( curlUrl.asString()); CURLcode ret = curl_easy_setopt( _curl, CURLOPT_URL, urlBuffer.c_str() ); + if (_noproxy == true) + curl_easy_setopt(_curl, CURLOPT_NOPROXY, url.getHost().c_str());
Shouldn't that simply be: curl_easy_setopt(_curl, CURLOPT_NOPROXY, "*");
Yes, that's more easy and general.
[...] + if (it->second != "_none_" ) + { + int pos = it->second.find(":", 0); + url.setQueryParam("proxy", it->second.substr(0, pos)); + url.setQueryParam("proxyport", it->second.substr(pos + 1));
What if there is no ':' in the proxy string? find will return "npos" in that case.
[Zhang, Qiang] yeah, there's some issue. I needs write a simple reg to parse proxy. Attached is my new patch. Thanks Xiaoqiang