Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.util.Url
Datastructure for representing an HTTP URL. Used as a return value for parse_url().
For backwards-compatibility with urlparse. We’re nice like that.
Absolute path including the query string.
Checks if given fingerprint matches the supplied certificate.
Parameters: |
|
---|
Deprecated. Use parse_url() instead.
Returns True if the connection is dropped and should be closed.
Parameters: | conn – httplib.HTTPConnection object. |
---|
Note: For platforms like AppEngine, this will always return False to let the platform handle connection recycling transparently for us.
Shortcuts for generating request headers.
Parameters: |
|
---|
Example:
>>> make_headers(keep_alive=True, user_agent="Batman/1.0")
{'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
>>> make_headers(accept_encoding=True)
{'accept-encoding': 'gzip,deflate'}
Given a url, return a parsed Url namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None.
Partly backwards-compatible with urlparse.
Example:
>>> parse_url('http://google.com/mail/')
Url(scheme='http', host='google.com', port=None, path='/', ...)
>>> parse_url('google.com:80')
Url(scheme=None, host='google.com', port=80, path=None, ...)
>>> parse_url('/foo?bar')
Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to ssl.CERT_NONE. If given a string it is assumed to be the name of the constant in the ssl module or its abbrevation. (So you can specify REQUIRED instead of CERT_REQUIRED. If it’s neither None nor a string we assume it is already the numeric constant which can directly be passed to wrap_socket.
like resolve_cert_reqs
Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter.
If not found, then the first part is the full input string.
Example:
>>> split_first('foo/bar?baz', '?/=')
('foo', 'bar?baz', '/')
>>> split_first('foo/bar?baz', '123')
('foo/bar?baz', '', None)
Scales linearly with number of delims. Not ideal for large number of delims.
Bases: object
Bases: object
HTTP Response container.
Backwards-compatible to httplib’s HTTPResponse but the response body is loaded and decoded on-demand when the data property is accessed.
Extra parameters for behaviour not present in httplib.HTTPResponse:
Parameters: |
|
---|
Given an httplib.HTTPResponse instance r, return a corresponding urllib3.response.HTTPResponse object.
Remaining parameters are passed to the HTTPResponse constructor, along with original_response=r.
Should we redirect and where to?
Returns: | Truthy redirect location string if we got a redirect status code and valid location. None if redirect status and no location. False if not a redirect status code. |
---|
Similar to httplib.HTTPResponse.read(), but with two additional parameters: decode_content and cache_content.
Parameters: |
|
---|
Bases: object
Base class for all connection pools, such as HTTPConnectionPool and HTTPSConnectionPool.
alias of LifoQueue
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.connectionpool.ConnectionPool, cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.request.RequestMethods
Thread-safe connection pool for one host.
Parameters: |
|
---|
Get a connection. Will return a pooled connection if one is available.
If no connections are available and :prop:`.block` is False, then a fresh connection is returned.
Parameters: | timeout – Seconds to wait before giving up and raising urllib3.exceptions.EmptyPoolError if the pool is empty and :prop:`.block` is True. |
---|
Perform a request on a given httplib connection object taken from our pool.
Return a fresh httplib.HTTPConnection.
Put a connection back into the pool.
Parameters: | conn – Connection object for the current host and port as returned by _new_conn() or _get_conn(). |
---|
If the pool is already full, the connection is closed and discarded because we exceeded maxsize. If connections are discarded frequently, then maxsize should be increased.
If the pool is closed, then the connection will be closed and discarded.
Close all pooled connections and disable the pool.
Check if the given url is a member of the same host as this connection pool.
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you’ll need to specify all the raw details.
Note
More commonly, it’s appropriate to use a convenience method provided by RequestMethods, such as request().
Note
release_conn will only behave as expected if preload_content=False because we want to make preload_content=False the default behaviour someday soon without breaking backwards compatibility.
Parameters: |
|
---|
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.connectionpool.HTTPConnectionPool
Same as HTTPConnectionPool, but HTTPS.
When Python is compiled with the ssl module, then VerifiedHTTPSConnection is used, which can verify certificates, instead of httplib.HTTPSConnection.
VerifiedHTTPSConnection uses one of assert_fingerprint, assert_hostname and host in this order to verify connections.
The key_file, cert_file, cert_reqs, ca_certs and ssl_version are only used if ssl is available and are fed into urllib3.util.ssl_wrap_socket() to upgrade the connection socket into an SSL socket.
Return a fresh httplib.HTTPSConnection.
Bases: httplib.HTTPSConnection
Based on httplib.HTTPSConnection but wraps the socket with SSL certification.
Given a url, return an ConnectionPool instance of its host.
This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an ConnectionPool instance.
Parameters: |
|
---|
Example:
>>> conn = connection_from_url('http://google.com/')
>>> r = conn.request('GET', '/')
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.request.RequestMethods
Allows for arbitrary requests while transparently keeping track of necessary connection pools for you.
Parameters: |
|
---|
Example:
>>> manager = PoolManager(num_pools=2)
>>> r = manager.request('GET', 'http://google.com/')
>>> r = manager.request('GET', 'http://google.com/mail')
>>> r = manager.request('GET', 'http://yahoo.com/')
>>> len(manager.pools)
2
Create a new ConnectionPool based on host, port and scheme.
This method is used to actually create the connection pools handed out by connection_from_url() and companion methods. It is intended to be overridden for customization.
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be re-used after completion.
Get a ConnectionPool based on the host, port, and scheme.
If port isn’t given, it will be derived from the scheme using urllib3.connectionpool.port_by_scheme.
Similar to urllib3.connectionpool.connection_from_url() but doesn’t pass any additional parameters to the urllib3.connectionpool.ConnectionPool constructor.
Additional parameters are taken from the PoolManager constructor.
Same as urllib3.connectionpool.HTTPConnectionPool.urlopen() with custom cross-host redirect logic and only sends the request-uri portion of the url.
The given url parameter must be absolute, such that an appropriate urllib3.connectionpool.ConnectionPool can be chosen for it.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.request.RequestMethods
Given a ConnectionPool to a proxy, the ProxyManager’s urlopen method will make requests to any url through the defined proxy. The ProxyManager class will automatically set the ‘Host’ header if it is not provided.
Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.
Same as HTTP(S)ConnectionPool.urlopen, url must be absolute.
urllib3 - Thread-safe connection pooling and re-using.
Helper for quickly adding a StreamHandler to the logger. Useful for debugging.
Returns the handler after adding it.
Bases: _abcoll.MutableMapping
Provides a thread-safe dict-like container which maintains up to maxsize keys while throwing away the least-recently-used keys beyond maxsize.
Parameters: |
|
---|
alias of OrderedDict
Our embarassingly-simple replacement for mimetools.choose_boundary.
Encode a dictionary of fields using the multipart/form-data MIME format.
Parameters: |
|
---|
Iterate over fields.
Supports list of (k, v) tuples and dicts.
Bases: object
Convenience mixin for classes who implement a urlopen() method, such as HTTPConnectionPool and PoolManager.
Provides behavior for making common types of HTTP request methods and decides which type of request field encoding to use.
Specifically,
request_encode_url() is for sending requests whose fields are encoded in the URL (such as GET, HEAD, DELETE).
request_encode_body() is for sending requests whose fields are encoded in the body of the request using multipart or www-orm-urlencoded (such as for POST, PUT, PATCH).
request() is for making any kind of request, it will look up the appropriate encoding format and use one of the above two methods to make the request.
Initializer parameters:
Parameters: | headers – Headers to include with all requests, unless other headers are given explicitly. |
---|
Make a request using urlopen() with the appropriate encoding of fields based on the method used.
This is a convenience method that requires the least amount of manual effort. It can be used in most situations, while still having the option to drop down to more specific methods when necessary, such as request_encode_url(), request_encode_body(), or even the lowest level urlopen().
Make a request using urlopen() with the fields encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc.
When encode_multipart=True (default), then urllib3.filepost.encode_multipart_formdata() is used to encode the payload with the appropriate content type. Otherwise urllib.urlencode() is used with the ‘application/x-www-form-urlencoded’ content type.
Multipart encoding must be used when posting files, and it’s reasonably safe to use it in other times too. However, it may break request signing, such as with OAuth.
Supports an optional fields parameter of key/value strings AND key/filetuple. A filetuple is a (filename, data, MIME type) tuple where the MIME type is optional. For example:
fields = {
'foo': 'bar',
'fakefile': ('foofile.txt', 'contents of foofile'),
'realfile': ('barfile.txt', open('realfile').read()),
'typedfile': ('bazfile.bin', open('bazfile').read(),
'image/jpeg'),
'nonamefile': 'contents of nonamefile field',
}
When uploading a file, providing a filename (the first parameter of the tuple) is optional but recommended to best mimick behavior of browsers.
Note that if headers are supplied, the ‘Content-Type’ header will be overwritten because it depends on the dynamic random boundary string which is used to compose the body of the request. The random boundary string can be explicitly set with the multipart_boundary parameter.
Make a request using urlopen() with the fields encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.PoolError
Raised when a request enters a pool after the pool has been closed.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.HTTPError
Raised when automatic decoding based on Content-Type fails.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.PoolError
Raised when a pool runs out of connections and no more are allowed.
Bases: exceptions.Exception
Base exception used by this module.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.RequestError
Raised when an existing pool gets a request for a foreign host.
Bases: exceptions.ValueError, cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.HTTPError
Raised when get_host or similar fails to parse the URL input.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.RequestError
Raised when the maximum number of retries is exceeded.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.HTTPError
Base exception for errors caused within a pool.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.PoolError
Base exception for PoolErrors that have associated URLs.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.HTTPError
Raised when SSL certificate fails in an HTTPS connection.
Bases: cloudfusion.third_party.requests_1_2_3.requests.packages.urllib3.exceptions.RequestError
Raised when a socket timeout occurs.