ó
ÅVEXc           @@  sO   d  d l  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   http_clienti   (   t   HeaderParsingErrorc         C@  sT   y |  j  SWn t k
 r n Xy |  j d k SWn t k
 rC 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   closedt   AttributeErrort   fpt   Nonet
   ValueError(   t   obj(    (    s9   /usr/lib/python2.7/dist-packages/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 } | rl | ƒ  } n  | sx | r t d | d | ƒ ‚ n  d S(   sP  
    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.
    s"   expected httplib.Message, got {0}.t   defectst   get_payloadt   unparsed_dataN(	   t
   isinstancet   httplibt   HTTPMessaget	   TypeErrort   formatt   typet   getattrR   R   (   t   headersR
   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/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 conn:
    :type conn: :class:`httplib.HTTPResponse`
    i   t   HEAD(   t   _methodR   t   intt   upper(   t   responset   method(    (    s9   /usr/lib/python2.7/dist-packages/urllib3/util/response.pyt   is_response_to_head>   s    		
N(
   t
   __future__R    t	   six.movesR   R   t
   exceptionsR   R	   R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/urllib3/util/response.pyt   <module>   s
   		