3

Z'íc¶
ã@sPddlmZddlmZmZddlmZddlmZ	dd„Z
dd	„Zd
d„ZdS)
é)Úabsolute_import)Ú!MultipartInvariantViolationDefectÚStartBoundaryNotFoundDefecté)ÚHeaderParsingError)Úhttp_clientcCsfy|jƒStk
rYnXy|jStk
r8YnXy
|jdkStk
rXYnXtdƒ‚dS)zt
    Checks whether a given file-like object is closed.

    :param obj:
        The file-like object to check.
    Nz)Unable to determine whether fp is closed.)ÚisclosedÚAttributeErrorÚclosedÚfpÚ
ValueError)Úobj©rú8/tmp/pip-build-gk9425m9/urllib3/urllib3/util/response.pyÚis_fp_closed	s
rcCsˆt|tjƒstdjt|ƒƒƒ‚t|ddƒ}t|ddƒ}d}|r^|jƒs^|ƒ}t|tt	fƒr^|}|rpdd„|Dƒ}|sx|r„t
||d‚dS)a>
    Asserts whether all headers have been successfully parsed.
    Extracts encountered errors from the result of parsing headers.

    Only works on Python 3.

    :param http.client.HTTPMessage headers: Headers to verify.

    :raises urllib3.exceptions.HeaderParsingError:
        If parsing errors are found.
    z"expected httplib.Message, got {0}.ÚdefectsNÚget_payloadcSsg|]}t|ttfƒs|‘qSr)Ú
isinstancerr)Ú.0Údefectrrrú
<listcomp>Ssz)assert_header_parsing.<locals>.<listcomp>)rÚ
unparsed_data)rÚhttplibÚHTTPMessageÚ	TypeErrorÚformatÚtypeÚgetattrÚis_multipartÚbytesÚstrr)ÚheadersrrrÚpayloadrrrÚassert_header_parsing(s
r#cCs$|j}t|tƒr|dkS|jƒdkS)zõ
    Checks whether the request of a response has been a HEAD-request.
    Handles the quirks of AppEngine.

    :param http.client.HTTPResponse response:
        Response to check if the originating request
        used 'HEAD' as a method.
    éÚHEAD)Ú_methodrÚintÚupper)ÚresponseÚmethodrrrÚis_response_to_head^s

r+N)
Ú
__future__rZemail.errorsrrÚ
exceptionsrZpackages.six.movesrrrr#r+rrrrÚ<module>s6