ó
Ð²Ebc           @@  se   d  d l  m Z d  d l m Z m Z d d l m Z d d l m Z	 d „  Z
 d „  Z d „  Z d	 S(
   i    (   t   absolute_import(   t!   MultipartInvariantViolationDefectt   StartBoundaryNotFoundDefecti   (   t   HeaderParsingError(   t   http_clientc         C@  sv   y |  j  ƒ  SWn t k
 r! n Xy |  j SWn t k
 r@ n Xy |  j d k SWn t k
 re n Xt d ƒ ‚ d S(   st   
    Checks whether a given file-like object is closed.

    :param obj:
        The file-like object to check.
    s)   Unable to determine whether fp is closed.N(   t   isclosedt   AttributeErrort   closedt   fpt   Nonet
   ValueError(   t   obj(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/util/response.pyt   is_fp_closed	   s    c         C@  sø   t  |  t j ƒ s0 t d j t |  ƒ ƒ ƒ ‚ n  t |  d d ƒ } t |  d d ƒ } d } | r™ |  j ƒ  s™ | ƒ  } t  | t	 t
 f ƒ r– | } q– q™ n  | rÐ g  | D]! } t  | t t f ƒ s¦ | ^ q¦ } n  | sÜ | rô t d | d | ƒ ‚ n  d S(   s>  
    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.
    s"   expected httplib.Message, got {0}.t   defectst   get_payloadt   unparsed_dataN(   t
   isinstancet   httplibt   HTTPMessaget	   TypeErrort   formatt   typet   getattrR	   t   is_multipartt   bytest   strR   R   R   (   t   headersR   R   R   t   payloadt   defect(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/util/response.pyt   assert_header_parsing(   s"    	
!c         C@  s2   |  j  } t | t ƒ r" | d k S| j ƒ  d k S(   sõ   
    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.
    i   t   HEAD(   t   _methodR   t   intt   upper(   t   responset   method(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/util/response.pyt   is_response_to_head^   s    
	
N(   t
   __future__R    t   email.errorsR   R   t
   exceptionsR   t   packages.six.movesR   R   R   R   R$   (    (    (    s>   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/util/response.pyt   <module>   s   		6