MCPcopy
hub / github.com/urllib3/urllib3 / _wrap_proxy_error

Function _wrap_proxy_error

src/urllib3/connection.py:1052–1074  ·  view source on GitHub ↗
(err: Exception, proxy_scheme: str | None)

Source from the content-addressed store, hash-verified

1050
1051
1052def _wrap_proxy_error(err: Exception, proxy_scheme: str | None) -> ProxyError:
1053 # Look for the phrase 'wrong version number', if found
1054 # then we should warn the user that we're very sure that
1055 # this proxy is HTTP-only and they have a configuration issue.
1056 error_normalized = " ".join(re.split("[^a-z]", str(err).lower()))
1057 is_likely_http_proxy = (
1058 "wrong version number" in error_normalized
1059 or "unknown protocol" in error_normalized
1060 or "record layer failure" in error_normalized
1061 )
1062 http_proxy_warning = (
1063 ". Your proxy appears to only use HTTP and not HTTPS, "
1064 "try changing your proxy URL to be HTTP. See: "
1065 "https://urllib3.readthedocs.io/en/latest/advanced-usage.html"
1066 "#https-proxy-error-http-proxy"
1067 )
1068 new_err = ProxyError(
1069 f"Unable to connect to proxy"
1070 f"{http_proxy_warning if is_likely_http_proxy and proxy_scheme == 'https' else ''}",
1071 err,
1072 )
1073 new_err.__cause__ = err
1074 return new_err
1075
1076
1077def _get_default_user_agent() -> str:

Callers 3

test_wrap_proxy_errorMethod · 0.90
_make_requestMethod · 0.85
urlopenMethod · 0.85

Calls 1

ProxyErrorClass · 0.85

Tested by 1

test_wrap_proxy_errorMethod · 0.72