some fixes to enhance authentication url
authorGui Chen <gui.chen@intel.com>
Sat, 2 Jun 2012 04:16:12 +0000 (12:16 +0800)
committerGui Chen <gui.chen@intel.com>
Sat, 2 Jun 2012 07:34:07 +0000 (15:34 +0800)
the fixed issues includes:
1. "https://url" can't get https proxy properly
2. "http://host/a//bc" (inculde "//" in abc) is not supported in some server
3. "http://a+bc" (include "+" in abc) is quoted so that failed to download

Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/utils/misc.py
mic/utils/rpmmisc.py
plugins/backend/zypppkgmgr.py

index 7bdb81a..8b5224a 100644 (file)
@@ -370,7 +370,7 @@ def _get_uncompressed_data_from_url(url, filename, proxies):
     return filename
 
 def _get_metadata_from_repo(baseurl, proxies, cachedir, reponame, filename):
-    url = str(baseurl + "/" + filename)
+    url = os.path.join(baseurl, filename)
     filename_tmp = str("%s/%s/%s" % (cachedir, reponame, os.path.basename(filename)))
     return _get_uncompressed_data_from_url(url,filename_tmp,proxies)
 
@@ -395,9 +395,9 @@ def get_metadata_from_repos(repostrs, cachedir):
             proxy = get_proxy_for(baseurl)
         proxies = None
         if proxy:
-           proxies = {str(proxy.split(":")[0]):str(proxy)}
+           proxies = {str(baseurl.split(":")[0]):str(proxy)}
         makedirs(cachedir + "/" + reponame)
-        url = str(baseurl + "/repodata/repomd.xml")
+        url = os.path.join(baseurl, "repodata/repomd.xml")
         filename = str("%s/%s/repomd.xml" % (cachedir, reponame))
         repomd = myurlgrab(url, filename, proxies)
         try:
@@ -570,7 +570,7 @@ def get_package(pkg, repometadata, arch = None):
             con.close()
     if target_repo:
         makedirs("%s/%s/packages" % (target_repo["cachedir"], target_repo["name"]))
-        url = str(target_repo["baseurl"] + "/" + pkgpath)
+        url = os.path.join(target_repo["baseurl"], pkgpath)
         filename = str("%s/%s/packages/%s" % (target_repo["cachedir"], target_repo["name"], os.path.basename(pkgpath)))
         pkg = myurlgrab(url, filename, target_repo["proxies"])
         return pkg
index 4e49715..c1b0c95 100644 (file)
@@ -41,7 +41,8 @@ def myurlgrab(url, filename, proxies, progress_obj = None):
         try:
             filename = g.urlgrab(url = url, filename = filename,
                 ssl_verify_host = False, ssl_verify_peer = False,
-                proxies = proxies, http_headers = (('Pragma', 'no-cache'),), progress_obj = progress_obj)
+                proxies = proxies, http_headers = (('Pragma', 'no-cache'),),
+                quote = 0, progress_obj = progress_obj)
         except URLGrabError, e:
             raise CreatorError("URLGrabber error: %s" % url)
 
index 3abf6c7..15e1850 100755 (executable)
@@ -651,7 +651,7 @@ class Zypp(BackendPlugin):
             if location.startswith("./"):
                 location = location[2:]
 
-            url = baseurl + "/%s" % location
+            url = os.path.join(baseurl, location)
 
             try:
                 filename = rpmmisc.myurlgrab(url,