Răsfoiți Sursa

Update the setting of resp.redirect_location, using code from master in the "try" and 0.19.10 (the last version to not use geturl) in the "catch"

Håvard Tveite 5 ani în urmă
părinte
comite
5274f14d48
1 a modificat fișierele cu 8 adăugiri și 3 ștergeri
  1. 8 3
      dulwich/client.py

+ 8 - 3
dulwich/client.py

@@ -1603,9 +1603,14 @@ class HttpGitClient(GitClient):
         read = BytesIO(resp.data).read
 
         resp.content_type = resp.getheader("Content-Type")
-        resp_url = resp.geturl()
-        resp.redirect_location = resp_url if resp_url != url else ''
-
+        # Check if geturl() is available (urllib3 version >= 1.23)
+        try:
+            resp_url = resp.geturl()
+        except AttributeError:
+            # get_redirect_location() is available for urllib3 >= 1.1
+            resp.redirect_location = resp.get_redirect_location()
+        else:
+            resp.redirect_location = resp_url if resp_url != url else ''
         return resp, read
 
     def _discover_references(self, service, base_url):