[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.223.125.218: ~ $
from __future__ import absolute_import
from ..packages.six.moves import http_client as httplib

from ..exceptions import HeaderParsingError


def is_fp_closed(obj):
    """
    Checks whether a given file-like object is closed.

    :param obj:
        The file-like object to check.
    """

    try:
        # Check `isclosed()` first, in case Python3 doesn't set `closed`.
        # GH Issue #928
        return obj.isclosed()
    except AttributeError:
        pass

    try:
        # Check via the official file-like-object way.
        return obj.closed
    except AttributeError:
        pass

    try:
        # Check if the object is a container for another file-like object that
        # gets released on exhaustion (e.g. HTTPResponse).
        return obj.fp is None
    except AttributeError:
        pass

    raise ValueError("Unable to determine whether fp is closed.")


def assert_header_parsing(headers):
    """
    Asserts whether all headers have been successfully parsed.
    Extracts encountered errors from the result of parsing headers.

    Only works on Python 3.

    :param headers: Headers to verify.
    :type headers: `httplib.HTTPMessage`.

    :raises urllib3.exceptions.HeaderParsingError:
        If parsing errors are found.
    """

    # This will fail silently if we pass in the wrong kind of parameter.
    # To make debugging easier add an explicit check.
    if not isinstance(headers, httplib.HTTPMessage):
        raise TypeError("expected httplib.Message, got {0}.".format(type(headers)))

    defects = getattr(headers, "defects", None)
    get_payload = getattr(headers, "get_payload", None)

    unparsed_data = None
    if get_payload:
        # get_payload is actually email.message.Message.get_payload;
        # we're only interested in the result if it's not a multipart message
        if not headers.is_multipart():
            payload = get_payload()

            if isinstance(payload, (bytes, str)):
                unparsed_data = payload

    if defects or unparsed_data:
        raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)


def is_response_to_head(response):
    """
    Checks whether the request of a response has been a HEAD-request.
    Handles the quirks of AppEngine.

    :param conn:
    :type conn: :class:`httplib.HTTPResponse`
    """
    # FIXME: Can we do this somehow without accessing private httplib _method?
    method = response._method
    if isinstance(method, int):  # Platform-specific: Appengine
        return method == 3
    return method.upper() == "HEAD"

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
.__init__.pyo.40009 File 1.55 KB 0644
.connection.pyo.40009 File 3.9 KB 0644
.queue.pyo.40009 File 1.43 KB 0644
.request.pyo.40009 File 3.85 KB 0644
.response.pyo.40009 File 2.39 KB 0644
.retry.pyo.40009 File 14.83 KB 0644
.ssl_.pyo.40009 File 11.92 KB 0644
.timeout.pyo.40009 File 9.7 KB 0644
.url.pyo.40009 File 12.76 KB 0644
.wait.pyo.40009 File 4.33 KB 0644
__init__.py File 1.01 KB 0644
__init__.pyc File 1.55 KB 0644
__init__.pyo File 1.55 KB 0644
connection.py File 4.53 KB 0644
connection.pyc File 3.9 KB 0644
connection.pyo File 3.9 KB 0644
queue.py File 497 B 0644
queue.pyc File 1.43 KB 0644
queue.pyo File 1.43 KB 0644
request.py File 3.73 KB 0644
request.pyc File 3.85 KB 0644
request.pyo File 3.85 KB 0644
response.py File 2.51 KB 0644
response.pyc File 2.39 KB 0644
response.pyo File 2.39 KB 0644
retry.py File 15.18 KB 0644
retry.pyc File 14.83 KB 0644
retry.pyo File 14.83 KB 0644
ssl_.py File 14.18 KB 0644
ssl_.pyc File 11.92 KB 0644
ssl_.pyo File 11.92 KB 0644
timeout.py File 9.71 KB 0644
timeout.pyc File 9.7 KB 0644
timeout.pyo File 9.7 KB 0644
url.py File 13.65 KB 0644
url.pyc File 12.76 KB 0644
url.pyo File 12.76 KB 0644
wait.py File 5.28 KB 0644
wait.pyc File 4.33 KB 0644
wait.pyo File 4.33 KB 0644