Exceptions and Warnings

exception urllib3.exceptions.BodyNotHttplibCompatible

基类:HTTPError

Body should be http.client.HTTPResponse like (have an fp attribute which returns raw chunks) for read_chunked().

exception urllib3.exceptions.ClosedPoolError(pool, message)

基类:PoolError

Raised when a request enters a pool after the pool has been closed.

参数:
返回类型:

None

exception urllib3.exceptions.ConnectTimeoutError

基类:TimeoutError

Raised when a socket timeout occurs while connecting to a server

urllib3.exceptions.ConnectionError

Renamed to ProtocolError but aliased for backwards compatibility.

exception urllib3.exceptions.DecodeError

基类:HTTPError

Raised when automatic decoding based on Content-Type fails.

exception urllib3.exceptions.DependencyWarning

基类:HTTPWarning

Warned when an attempt is made to import a module with missing optional dependencies.

exception urllib3.exceptions.EmptyPoolError(pool, message)

基类:PoolError

Raised when a pool runs out of connections and no more are allowed.

参数:
返回类型:

None

exception urllib3.exceptions.FullPoolError(pool, message)

基类:PoolError

Raised when we try to add a connection to a full pool in blocking mode.

参数:
返回类型:

None

exception urllib3.exceptions.HTTPError

基类:Exception

Base exception used by this module.

exception urllib3.exceptions.HTTPWarning

基类:Warning

Base warning used by this module.

exception urllib3.exceptions.HeaderParsingError(defects, unparsed_data)

基类:HTTPError

Raised by assert_header_parsing, but we convert it to a log.warning statement.

参数:
  • defects (list[MessageDefect])

  • unparsed_data (bytes | str | None)

返回类型:

None

exception urllib3.exceptions.HostChangedError(pool, url, retries=3)

基类:RequestError

Raised when an existing pool gets a request for a foreign host.

参数:
返回类型:

None

exception urllib3.exceptions.IncompleteRead(partial, expected)

基类:HTTPError, IncompleteRead

Response length doesn't match expected Content-Length

Subclass of http.client.IncompleteRead to allow int value for partial to avoid creating large objects on streamed reads.

参数:
  • partial (int)

  • expected (int)

返回类型:

None

expected: int
partial: int
exception urllib3.exceptions.InsecurePlatformWarning

基类:SecurityWarning

Warned when certain TLS/SSL configuration is not available on a platform.

exception urllib3.exceptions.InsecureRequestWarning

基类:SecurityWarning

Warned when making an unverified HTTPS request.

exception urllib3.exceptions.InvalidChunkLength(response, length)

基类:HTTPError, IncompleteRead

Invalid chunk length in a chunked response.

参数:
返回类型:

None

exception urllib3.exceptions.InvalidHeader

基类:HTTPError

The header provided was somehow invalid.

exception urllib3.exceptions.LocationParseError(location)

基类:LocationValueError

Raised when get_host or similar fails to parse the URL input.

参数:

location (str)

返回类型:

None

exception urllib3.exceptions.LocationValueError

基类:ValueError, HTTPError

Raised when there is something wrong with a given URL input.

exception urllib3.exceptions.MaxRetryError(pool, url, reason=None)

基类:RequestError

Raised when the maximum number of retries is exceeded.

参数:
返回类型:

None

exception urllib3.exceptions.NameResolutionError(host, conn, reason)

基类:NewConnectionError

Raised when host name resolution fails.

参数:
exception urllib3.exceptions.NewConnectionError(conn, message)

基类:ConnectTimeoutError, HTTPError

Raised when we fail to establish a new connection. Usually ECONNREFUSED.

参数:
返回类型:

None

property pool: HTTPConnection
exception urllib3.exceptions.NotOpenSSLWarning

基类:SecurityWarning

Warned when using unsupported SSL library

exception urllib3.exceptions.PoolError(pool, message)

基类:HTTPError

Base exception for errors caused within a pool.

参数:
返回类型:

None

exception urllib3.exceptions.ProtocolError

基类:HTTPError

Raised when something unexpected happens mid-request/response.

exception urllib3.exceptions.ProxyError(message, error)

基类:HTTPError

Raised when the connection to a proxy fails.

参数:
返回类型:

None

original_error: Exception
exception urllib3.exceptions.ProxySchemeUnknown(scheme)

基类:AssertionError, URLSchemeUnknown

ProxyManager does not support the supplied scheme

参数:

scheme (str | None)

返回类型:

None

exception urllib3.exceptions.ProxySchemeUnsupported

基类:ValueError

Fetching HTTPS resources through HTTPS proxies is unsupported

exception urllib3.exceptions.ReadTimeoutError(pool, url, message)

基类:TimeoutError, RequestError

Raised when a socket timeout occurs while receiving data from a server

参数:
返回类型:

None

exception urllib3.exceptions.RequestError(pool, url, message)

基类:PoolError

Base exception for PoolErrors that have associated URLs.

参数:
返回类型:

None

exception urllib3.exceptions.ResponseError

基类:HTTPError

Used as a container for an error reason supplied in a MaxRetryError.

GENERIC_ERROR = 'too many error responses'
SPECIFIC_ERROR = 'too many {status_code} error responses'
exception urllib3.exceptions.ResponseNotChunked

基类:ProtocolError, ValueError

Response needs to be chunked in order to read it as chunks.

exception urllib3.exceptions.SSLError

基类:HTTPError

Raised when SSL certificate fails in an HTTPS connection.

exception urllib3.exceptions.SecurityWarning

基类:HTTPWarning

Warned when performing security reducing actions

exception urllib3.exceptions.SystemTimeWarning

基类:SecurityWarning

Warned when system time is suspected to be wrong

exception urllib3.exceptions.TimeoutError

基类:HTTPError

Raised when a socket timeout error occurs.

Catching this error will catch both ReadTimeoutErrors and ConnectTimeoutErrors.

exception urllib3.exceptions.TimeoutStateError

基类:HTTPError

Raised when passing an invalid state to a timeout

exception urllib3.exceptions.URLSchemeUnknown(scheme)

基类:LocationValueError

Raised when a URL input has an unsupported scheme.

参数:

scheme (str)

exception urllib3.exceptions.UnrewindableBodyError

基类:HTTPError

urllib3 encountered an error when trying to rewind a body

urllib3.disable_warnings(category=<class 'urllib3.exceptions.HTTPWarning'>)

Helper for quickly disabling all urllib3 warnings.

参数:

category (type[Warning])

返回类型:

None