Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../lib/python2..../site-pac.../urllib3
File: exceptions.py
from __future__ import absolute_import
[0] Fix | Delete
from .packages.six.moves.http_client import (
[1] Fix | Delete
IncompleteRead as httplib_IncompleteRead
[2] Fix | Delete
)
[3] Fix | Delete
# Base Exceptions
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
class HTTPError(Exception):
[7] Fix | Delete
"Base exception used by this module."
[8] Fix | Delete
pass
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
class HTTPWarning(Warning):
[12] Fix | Delete
"Base warning used by this module."
[13] Fix | Delete
pass
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
class PoolError(HTTPError):
[17] Fix | Delete
"Base exception for errors caused within a pool."
[18] Fix | Delete
def __init__(self, pool, message):
[19] Fix | Delete
self.pool = pool
[20] Fix | Delete
HTTPError.__init__(self, "%s: %s" % (pool, message))
[21] Fix | Delete
[22] Fix | Delete
def __reduce__(self):
[23] Fix | Delete
# For pickling purposes.
[24] Fix | Delete
return self.__class__, (None, None)
[25] Fix | Delete
[26] Fix | Delete
[27] Fix | Delete
class RequestError(PoolError):
[28] Fix | Delete
"Base exception for PoolErrors that have associated URLs."
[29] Fix | Delete
def __init__(self, pool, url, message):
[30] Fix | Delete
self.url = url
[31] Fix | Delete
PoolError.__init__(self, pool, message)
[32] Fix | Delete
[33] Fix | Delete
def __reduce__(self):
[34] Fix | Delete
# For pickling purposes.
[35] Fix | Delete
return self.__class__, (None, self.url, None)
[36] Fix | Delete
[37] Fix | Delete
[38] Fix | Delete
class SSLError(HTTPError):
[39] Fix | Delete
"Raised when SSL certificate fails in an HTTPS connection."
[40] Fix | Delete
pass
[41] Fix | Delete
[42] Fix | Delete
[43] Fix | Delete
class ProxyError(HTTPError):
[44] Fix | Delete
"Raised when the connection to a proxy fails."
[45] Fix | Delete
pass
[46] Fix | Delete
[47] Fix | Delete
[48] Fix | Delete
class DecodeError(HTTPError):
[49] Fix | Delete
"Raised when automatic decoding based on Content-Type fails."
[50] Fix | Delete
pass
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
class ProtocolError(HTTPError):
[54] Fix | Delete
"Raised when something unexpected happens mid-request/response."
[55] Fix | Delete
pass
[56] Fix | Delete
[57] Fix | Delete
[58] Fix | Delete
#: Renamed to ProtocolError but aliased for backwards compatibility.
[59] Fix | Delete
ConnectionError = ProtocolError
[60] Fix | Delete
[61] Fix | Delete
[62] Fix | Delete
# Leaf Exceptions
[63] Fix | Delete
[64] Fix | Delete
class MaxRetryError(RequestError):
[65] Fix | Delete
"""Raised when the maximum number of retries is exceeded.
[66] Fix | Delete
[67] Fix | Delete
:param pool: The connection pool
[68] Fix | Delete
:type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
[69] Fix | Delete
:param string url: The requested Url
[70] Fix | Delete
:param exceptions.Exception reason: The underlying error
[71] Fix | Delete
[72] Fix | Delete
"""
[73] Fix | Delete
[74] Fix | Delete
def __init__(self, pool, url, reason=None):
[75] Fix | Delete
self.reason = reason
[76] Fix | Delete
[77] Fix | Delete
message = "Max retries exceeded with url: %s (Caused by %r)" % (
[78] Fix | Delete
url, reason)
[79] Fix | Delete
[80] Fix | Delete
RequestError.__init__(self, pool, url, message)
[81] Fix | Delete
[82] Fix | Delete
[83] Fix | Delete
class HostChangedError(RequestError):
[84] Fix | Delete
"Raised when an existing pool gets a request for a foreign host."
[85] Fix | Delete
[86] Fix | Delete
def __init__(self, pool, url, retries=3):
[87] Fix | Delete
message = "Tried to open a foreign host with url: %s" % url
[88] Fix | Delete
RequestError.__init__(self, pool, url, message)
[89] Fix | Delete
self.retries = retries
[90] Fix | Delete
[91] Fix | Delete
[92] Fix | Delete
class TimeoutStateError(HTTPError):
[93] Fix | Delete
""" Raised when passing an invalid state to a timeout """
[94] Fix | Delete
pass
[95] Fix | Delete
[96] Fix | Delete
[97] Fix | Delete
class TimeoutError(HTTPError):
[98] Fix | Delete
""" Raised when a socket timeout error occurs.
[99] Fix | Delete
[100] Fix | Delete
Catching this error will catch both :exc:`ReadTimeoutErrors
[101] Fix | Delete
<ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
[102] Fix | Delete
"""
[103] Fix | Delete
pass
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
class ReadTimeoutError(TimeoutError, RequestError):
[107] Fix | Delete
"Raised when a socket timeout occurs while receiving data from a server"
[108] Fix | Delete
pass
[109] Fix | Delete
[110] Fix | Delete
[111] Fix | Delete
# This timeout error does not have a URL attached and needs to inherit from the
[112] Fix | Delete
# base HTTPError
[113] Fix | Delete
class ConnectTimeoutError(TimeoutError):
[114] Fix | Delete
"Raised when a socket timeout occurs while connecting to a server"
[115] Fix | Delete
pass
[116] Fix | Delete
[117] Fix | Delete
[118] Fix | Delete
class NewConnectionError(ConnectTimeoutError, PoolError):
[119] Fix | Delete
"Raised when we fail to establish a new connection. Usually ECONNREFUSED."
[120] Fix | Delete
pass
[121] Fix | Delete
[122] Fix | Delete
[123] Fix | Delete
class EmptyPoolError(PoolError):
[124] Fix | Delete
"Raised when a pool runs out of connections and no more are allowed."
[125] Fix | Delete
pass
[126] Fix | Delete
[127] Fix | Delete
[128] Fix | Delete
class ClosedPoolError(PoolError):
[129] Fix | Delete
"Raised when a request enters a pool after the pool has been closed."
[130] Fix | Delete
pass
[131] Fix | Delete
[132] Fix | Delete
[133] Fix | Delete
class LocationValueError(ValueError, HTTPError):
[134] Fix | Delete
"Raised when there is something wrong with a given URL input."
[135] Fix | Delete
pass
[136] Fix | Delete
[137] Fix | Delete
[138] Fix | Delete
class LocationParseError(LocationValueError):
[139] Fix | Delete
"Raised when get_host or similar fails to parse the URL input."
[140] Fix | Delete
[141] Fix | Delete
def __init__(self, location):
[142] Fix | Delete
message = "Failed to parse: %s" % location
[143] Fix | Delete
HTTPError.__init__(self, message)
[144] Fix | Delete
[145] Fix | Delete
self.location = location
[146] Fix | Delete
[147] Fix | Delete
[148] Fix | Delete
class ResponseError(HTTPError):
[149] Fix | Delete
"Used as a container for an error reason supplied in a MaxRetryError."
[150] Fix | Delete
GENERIC_ERROR = 'too many error responses'
[151] Fix | Delete
SPECIFIC_ERROR = 'too many {status_code} error responses'
[152] Fix | Delete
[153] Fix | Delete
[154] Fix | Delete
class SecurityWarning(HTTPWarning):
[155] Fix | Delete
"Warned when performing security reducing actions"
[156] Fix | Delete
pass
[157] Fix | Delete
[158] Fix | Delete
[159] Fix | Delete
class SubjectAltNameWarning(SecurityWarning):
[160] Fix | Delete
"Warned when connecting to a host with a certificate missing a SAN."
[161] Fix | Delete
pass
[162] Fix | Delete
[163] Fix | Delete
[164] Fix | Delete
class InsecureRequestWarning(SecurityWarning):
[165] Fix | Delete
"Warned when making an unverified HTTPS request."
[166] Fix | Delete
pass
[167] Fix | Delete
[168] Fix | Delete
[169] Fix | Delete
class SystemTimeWarning(SecurityWarning):
[170] Fix | Delete
"Warned when system time is suspected to be wrong"
[171] Fix | Delete
pass
[172] Fix | Delete
[173] Fix | Delete
[174] Fix | Delete
class InsecurePlatformWarning(SecurityWarning):
[175] Fix | Delete
"Warned when certain SSL configuration is not available on a platform."
[176] Fix | Delete
pass
[177] Fix | Delete
[178] Fix | Delete
[179] Fix | Delete
class SNIMissingWarning(HTTPWarning):
[180] Fix | Delete
"Warned when making a HTTPS request without SNI available."
[181] Fix | Delete
pass
[182] Fix | Delete
[183] Fix | Delete
[184] Fix | Delete
class DependencyWarning(HTTPWarning):
[185] Fix | Delete
"""
[186] Fix | Delete
Warned when an attempt is made to import a module with missing optional
[187] Fix | Delete
dependencies.
[188] Fix | Delete
"""
[189] Fix | Delete
pass
[190] Fix | Delete
[191] Fix | Delete
[192] Fix | Delete
class ResponseNotChunked(ProtocolError, ValueError):
[193] Fix | Delete
"Response needs to be chunked in order to read it as chunks."
[194] Fix | Delete
pass
[195] Fix | Delete
[196] Fix | Delete
[197] Fix | Delete
class BodyNotHttplibCompatible(HTTPError):
[198] Fix | Delete
"""
[199] Fix | Delete
Body should be httplib.HTTPResponse like (have an fp attribute which
[200] Fix | Delete
returns raw chunks) for read_chunked().
[201] Fix | Delete
"""
[202] Fix | Delete
pass
[203] Fix | Delete
[204] Fix | Delete
[205] Fix | Delete
class IncompleteRead(HTTPError, httplib_IncompleteRead):
[206] Fix | Delete
"""
[207] Fix | Delete
Response length doesn't match expected Content-Length
[208] Fix | Delete
[209] Fix | Delete
Subclass of http_client.IncompleteRead to allow int value
[210] Fix | Delete
for `partial` to avoid creating large objects on streamed
[211] Fix | Delete
reads.
[212] Fix | Delete
"""
[213] Fix | Delete
def __init__(self, partial, expected):
[214] Fix | Delete
super(IncompleteRead, self).__init__(partial, expected)
[215] Fix | Delete
[216] Fix | Delete
def __repr__(self):
[217] Fix | Delete
return ('IncompleteRead(%i bytes read, '
[218] Fix | Delete
'%i more expected)' % (self.partial, self.expected))
[219] Fix | Delete
[220] Fix | Delete
[221] Fix | Delete
class InvalidHeader(HTTPError):
[222] Fix | Delete
"The header provided was somehow invalid."
[223] Fix | Delete
pass
[224] Fix | Delete
[225] Fix | Delete
[226] Fix | Delete
class ProxySchemeUnknown(AssertionError, ValueError):
[227] Fix | Delete
"ProxyManager does not support the supplied scheme"
[228] Fix | Delete
# TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
[229] Fix | Delete
[230] Fix | Delete
def __init__(self, scheme):
[231] Fix | Delete
message = "Not supported proxy scheme %s" % scheme
[232] Fix | Delete
super(ProxySchemeUnknown, self).__init__(message)
[233] Fix | Delete
[234] Fix | Delete
[235] Fix | Delete
class HeaderParsingError(HTTPError):
[236] Fix | Delete
"Raised by assert_header_parsing, but we convert it to a log.warning statement."
[237] Fix | Delete
def __init__(self, defects, unparsed_data):
[238] Fix | Delete
message = '%s, unparsed data: %r' % (defects or 'Unknown', unparsed_data)
[239] Fix | Delete
super(HeaderParsingError, self).__init__(message)
[240] Fix | Delete
[241] Fix | Delete
[242] Fix | Delete
class UnrewindableBodyError(HTTPError):
[243] Fix | Delete
"urllib3 encountered an error when trying to rewind a body"
[244] Fix | Delete
pass
[245] Fix | Delete
[246] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function