例外與警告

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

當根據 Content-Type 進行自動解碼失敗時拋出。

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

當主機名稱解析失敗時引發。

參數:
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