ó
^†êWc           @@  s©   d  d l  m Z d  d l Z y d  d l m Z m Z WnE e k
 r} e Z y d  d l m Z Wq~ e k
 ry e Z q~ Xn Xd „  Z e j	 d d d „ Z d „  Z d S(   i    (   t   absolute_importN(   t   pollt   POLLIN(   t   selectc         C@  sÎ   t  |  d t ƒ } | t k r" t S| d k r2 t St s{ t sB t Sy t | g g  g  d ƒ d SWq{ t j k
 rw t SXn  t ƒ  } | j | t	 ƒ x3 | j d ƒ D]" \ } } | | j
 ƒ  k r¤ t Sq¤ Wd S(   s   
    Returns True if the connection is dropped and should be closed.

    :param conn:
        :class:`httplib.HTTPConnection` object.

    Note: For platforms like AppEngine, this will always return ``False`` to
    let the platform handle connection recycling transparently for us.
    t   sockg        i    N(   t   getattrt   Falset   Nonet   TrueR   R   t   sockett   errort   registerR   t   fileno(   t   connR   t   pt   fnot   ev(    (    s†   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/util/connection.pyt   is_connection_dropped   s"    
	c         C@  sF  |  \ } } | j  d ƒ r- | j d ƒ } n  d } xè t j | | d t j ƒ D]Ë } | \ } }	 }
 } } d } yl t j | |	 |
 ƒ } t | | ƒ | t j k	 r´ | j | ƒ n  | rÊ | j	 | ƒ n  | j
 | ƒ | SWqO t j k
 r} | } | d k	 r| j ƒ  d } qqO XqO W| d k	 r3| ‚ n  t j d ƒ ‚ d S(   sd  Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    t   [s   []i    s!   getaddrinfo returns an empty listN(   t
   startswitht   stripR   R	   t   getaddrinfot   SOCK_STREAMt   _set_socket_optionst   _GLOBAL_DEFAULT_TIMEOUTt
   settimeoutt   bindt   connectR
   t   close(   t   addresst   timeoutt   source_addresst   socket_optionst   hostt   portt   errt   rest   aft   socktypet   protot	   canonnamet   saR   t   e(    (    s†   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/util/connection.pyt   create_connection1   s0    "
	c         C@  s2   | d  k r d  Sx | D] } |  j | Œ  q Wd  S(   N(   R   t
   setsockopt(   R   t   optionst   opt(    (    s†   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/util/connection.pyR   `   s    (   t
   __future__R    R	   R   R   R   t   ImportErrorR   R   R   R   R+   R   (    (    (    s†   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/util/connection.pyt   <module>   s   	$.