Skip to content

Commit

Permalink
Merge pull request #1366 from dmach/connection-proxy-no-auth
Browse files Browse the repository at this point in the history
Fix crash when HTTP_PROXY env contains no auth
  • Loading branch information
dirkmueller authored Jul 20, 2023
2 parents 6f58d4f + eaad34f commit b8f6f07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions osc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ def get_proxy_manager(env):
user_agent=f"osc/{__version__}",
)

proxy_basic_auth = urllib.parse.unquote(proxy_purl.auth)
proxy_basic_auth = proxy_basic_auth.encode("utf-8")
proxy_basic_auth = base64.b64encode(proxy_basic_auth).decode()
proxy_headers["Proxy-Authorization"] = f"Basic {proxy_basic_auth:s}"
if proxy_purl.auth:
proxy_basic_auth = urllib.parse.unquote(proxy_purl.auth)
proxy_basic_auth = proxy_basic_auth.encode("utf-8")
proxy_basic_auth = base64.b64encode(proxy_basic_auth).decode()
proxy_headers["Proxy-Authorization"] = f"Basic {proxy_basic_auth:s}"

manager = urllib3.ProxyManager(proxy_url, proxy_headers=proxy_headers)
return manager
Expand Down

0 comments on commit b8f6f07

Please sign in to comment.