Commit Diff


commit - 7574997132990398779c424b9860c85fae499d31
commit + a5e47fe514a610305cc713d8db041054887744be
blob - dc7bc644ba226294bc67aa1472bbdaa571b486a8
blob + 054be7e3c9fa3de5813c11211ac88df99fd2d3ce
--- NEWS
+++ NEWS
@@ -17,6 +17,9 @@
  * objects: Define a stricter return type for _parse_message
    (Vincent Lorentz)
 
+ * Raise GitProtocolError when encountering HTTP Errors in
+   HTTPGitClient. (Jelmer Vernooij, #1199)
+
 0.21.5	2023-05-04
 
  * Be more tolerant to non-3-length tuple versions.
blob - 87d69bad94d9b3ffd6d33cffcf06ff7f595919f3
blob + bf6b9086caaaf69f33873e012000da2e0f9e5e4d
--- dulwich/client.py
+++ dulwich/client.py
@@ -1949,6 +1949,8 @@ class AbstractHttpGitClient(GitClient):
           redirect_location properties, and read is a consumable read
           method for the response data.
 
+        Raises:
+          GitProtocolError
         """
         raise NotImplementedError(self._http_request)
 
@@ -2225,13 +2227,16 @@ class Urllib3HttpGitClient(AbstractHttpGitClient):
             req_headers.update(headers)
         req_headers["Pragma"] = "no-cache"
 
-        if data is None:
-            resp = self.pool_manager.request(
-                "GET", url, headers=req_headers, preload_content=False)
-        else:
-            resp = self.pool_manager.request(
-                "POST", url, headers=req_headers, body=data, preload_content=False
-            )
+        try:
+            if data is None:
+                resp = self.pool_manager.request(
+                    "GET", url, headers=req_headers, preload_content=False)
+            else:
+                resp = self.pool_manager.request(
+                    "POST", url, headers=req_headers, body=data, preload_content=False
+                )
+        except urllib3.exceptions.HTTPError as e:
+            raise GitProtocolError(str(e)) from e
 
         if resp.status == 404:
             raise NotGitRepository()