Skip to content

Commit bbb4420

Browse files
committed
Proxy authentication exception catch reworked
1 parent 6858bab commit bbb4420

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pulpcore/download/http.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import aiohttp
44
import asyncio
55
import backoff
6+
import socket
67

78
from .base import BaseDownloader, DownloadResult
89
from pulpcore.exceptions import (
@@ -272,7 +273,7 @@ async def download_wrapper():
272273
e.message,
273274
)
274275
)
275-
raise e
276+
raise ProxyAuthenticationRequiredError(self.proxy)
276277

277278
return await download_wrapper()
278279

@@ -299,10 +300,11 @@ async def _run(self, extra_data=None):
299300
self.raise_for_status(response)
300301
to_return = await self._handle_response(response)
301302
await response.release()
302-
except aiohttp.ClientConnectorDNSError:
303-
raise DnsDomainNameException(self.url)
304-
except aiohttp.ClientHttpProxyError:
305-
raise ProxyAuthenticationRequiredError(self.proxy)
303+
except aiohttp.ClientConnectorError as e:
304+
# Check if this is a DNS error
305+
if isinstance(e.os_error, socket.gaierror):
306+
raise DnsDomainNameException(self.url)
307+
raise
306308
if self._close_session_on_finalize:
307309
await self.session.close()
308310
return to_return

0 commit comments

Comments
 (0)