σ
^κWc           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m	 Z
 d  d l Z d d l m Z y$ d  d l m Z d  d l m Z Wn1 e k
 rΥ d  d l m Z d  d l m Z n Xy d  d l Z e j Z Wn3 e e f k
 r$d Z d e f d	     YZ n Xy
 e Z Wn' e k
 rXd
 e f d     YZ n Xd d l m Z m Z m  Z  m! Z! d d l" m# Z# m$ Z$ d d l% m& Z& m' Z' m( Z( m) Z) d d l* m+ Z+ d d l, m- Z- e j. e/  Z0 i d d 6d d 6Z1 e j2 d d d  Z3 d e4 f d     YZ5 d e e4 f d     YZ d e f d     YZ6 d e6 f d     YZ7 d   Z8 e re6 Z9 e7 Z6 n e5 Z6 d S(   i    (   t   absolute_importN(   t   errort   timeouti   (   t   six(   t   HTTPConnection(   t   HTTPExceptiont   BaseSSLErrorc           B@  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR      s   t   ConnectionErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR	       s   (   t   NewConnectionErrort   ConnectTimeoutErrort   SubjectAltNameWarningt   SystemTimeWarning(   t   match_hostnamet   CertificateError(   t   resolve_cert_reqst   resolve_ssl_versiont   ssl_wrap_sockett   assert_fingerprint(   t
   connection(   t   HTTPHeaderDictiP   t   httpi»  t   httpsiή  t   DummyConnectionc           B@  s   e  Z d  Z RS(   s-   Used to detect a failed ConnectionCls import.(   R   R   t   __doc__(    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR   B   s   R   c           B@  si   e  Z d  Z e d Z e j e j d f g Z e	 Z
 d   Z d   Z d   Z d   Z d d d  Z RS(	   s{  
    Based on httplib.HTTPConnection but provides an extra constructor
    backwards-compatibility layer between older and newer Pythons.

    Additional keyword parameters are used to configure attributes of the connection.
    Accepted parameters include:

      - ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
      - ``source_address``: Set the source address for the current connection.

        .. note:: This is ignored for Python 2.6. It is only applied for 2.7 and 3.x

      - ``socket_options``: Set specific options on the underlying socket. If not specified, then
        defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
        Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.

        For example, if you wish to enable TCP Keep Alive in addition to the defaults,
        you might pass::

            HTTPConnection.default_socket_options + [
                (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
            ]

        Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
    R   i   c         O@  s   t  j r | j d d   n  | j d  |  _ t j d k  rP | j d d   n  | j d |  j  |  _	 t
 j |  | |  d  S(   Nt   strictt   source_addressi   i   t   socket_options(   i   i   (   R   t   PY3t   popt   Nonet   getR   t   syst   version_infot   default_socket_optionsR   t   _HTTPConnectiont   __init__(   t   selft   argst   kw(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR%   k   s    	c         C@  sΎ   i  } |  j  r |  j  | d <n  |  j r8 |  j | d <n  y( t j |  j |  j f |  j |  } WnW t k
 r } t |  d |  j |  j f   n& t	 k
 rΉ } t
 |  d |   n X| S(   sp    Establish a socket connection and set nodelay settings on it.

        :return: New socket connection.
        R   R   s0   Connection to %s timed out. (connect timeout=%s)s(   Failed to establish a new connection: %s(   R   R   R   t   create_connectiont   hostt   portR   t   SocketTimeoutR   t   SocketErrorR
   (   R&   t   extra_kwt   connt   e(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt	   _new_conn   s     		"c         C@  s5   | |  _  t |  d d   r1 |  j   d |  _ n  d  S(   Nt   _tunnel_hosti    (   t   sockt   getattrR   t   _tunnelt	   auto_open(   R&   R/   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt   _prepare_conn   s    	
c         C@  s   |  j    } |  j |  d  S(   N(   R1   R7   (   R&   R/   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt   connect¦   s    c         C@  sx  t  | d k	 r | n i   } d | k } |  j | | d | x* | j   D] \ } } |  j | |  qM Wd | k r |  j d d  n  |  j   | d k	 rgt j t j f } t	 | |  rΠ | f } n  x | D] }	 |	 sι qΧ n  t	 |	 t j  s|	 j
 d  }	 n  t t |	   d }
 |  j |
 j
 d   |  j d	  |  j |	  |  j d	  qΧ Wn  |  j d
  d S(   s   
        Alternative to the common request method, which sends the
        body with chunked encoding and not as one block
        s   accept-encodingt   skip_accept_encodings   transfer-encodings   Transfer-Encodingt   chunkedt   utf8i   s   utf-8s   
s   0

N(   R   R   t
   putrequestt   itemst	   putheadert
   endheadersR   t   string_typest   binary_typet
   isinstancet   encodet   hext   lent   send(   R&   t   methodt   urlt   bodyt   headersR9   t   headert   valuet   stringish_typest   chunkt   len_str(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt   request_chunkedͺ   s.    
N(   R   R   R   t   port_by_schemet   default_portt   sockett   IPPROTO_TCPt   TCP_NODELAYR#   t   Falset   is_verifiedR%   R1   R7   R8   R   RP   (    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR   G   s   
				t   HTTPSConnectionc           B@  s6   e  Z e d  Z d d d d e j d  Z d   Z RS(   R   c      	   K@  sA   t  j |  | | d | d | | | |  _ | |  _ d |  _ d  S(   NR   R   R   (   R   R%   t   key_filet	   cert_filet	   _protocol(   R&   R*   R+   RY   RZ   R   R   R(   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR%   Ξ   s
    
		c         C@  s;   |  j    } |  j |  t j | |  j |  j  |  _ d  S(   N(   R1   R7   t   sslt   wrap_socketRY   RZ   R3   (   R&   R/   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR8   Ϋ   s    N(	   R   R   RQ   RR   R   RS   t   _GLOBAL_DEFAULT_TIMEOUTR%   R8   (    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyRX   Λ   s   
	t   VerifiedHTTPSConnectionc           B@  sS   e  Z d  Z d Z d Z d Z d Z d Z d d d d d d d d  Z	 d   Z
 RS(   s[   
    Based on httplib.HTTPSConnection but wraps the socket with
    SSL certification.
    c         C@  s   | s | r! | d  k r! d } n  | |  _ | |  _ | |  _ | |  _ | |  _ | oc t j j |  |  _	 | o~ t j j |  |  _
 d  S(   Nt   CERT_REQUIRED(   R   RY   RZ   t	   cert_reqst   assert_hostnameR   t   ost   patht
   expandusert   ca_certst   ca_cert_dir(   R&   RY   RZ   Ra   Rf   Rb   R   Rg   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt   set_certμ   s    						c         C@  s§  |  j    } t |  j  } t |  j  } |  j } t |  d d   rm | |  _ |  j	   d |  _
 |  j } n  t j j   t k  } | r€ t j d j t  t  n  t | |  j |  j d | d |  j d |  j d | d | |  _ |  j rt |  j j d	 t  |  j  nt | t j k r|  j t k	 r|  j j   } | j  d
 d  sit j d j |  t!  n  t" | |  j p{|  n  | t j# k p|  j d  k	 |  _$ d  S(   NR2   i    sW   System time is way off (before {0}). This will probably lead to SSL verification errorsRa   Rf   Rg   t   server_hostnamet   ssl_versiont   binary_formt   subjectAltNamesκ   Certificate for {0} has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)(    (%   R1   R   Ra   R   Rj   R*   R4   R   R3   R5   R6   R2   t   datetimet   datet   todayt   RECENT_DATEt   warningst   warnt   formatR   R   RY   RZ   Rf   Rg   R   t   getpeercertt   TrueR\   t	   CERT_NONERb   RV   R    R   t   _match_hostnameR`   RW   (   R&   R/   t   resolved_cert_reqst   resolved_ssl_versiont   hostnamet   is_time_offt   cert(    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR8   ό   sF    		
	
			
N(   R   R   R   R   Ra   Rf   Rg   Rj   R   Rh   R8   (    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyR_   α   s   c         C@  sJ   y t  |  |  Wn2 t k
 rE } t j d | |   |  | _   n Xd  S(   Ns@   Certificate did not match expected hostname: %s. Certificate: %s(   R   R   t   logR   t
   _peer_cert(   R|   t   asserted_hostnameR0   (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyRw   7  s    
	(:   t
   __future__R    Rm   t   loggingRc   R!   RS   R   R-   R   R,   Rq   t   packagesR   t   http.clientR   R$   R   t   ImportErrort   httplibR\   t   SSLErrorR   t   AttributeErrorR   t   BaseExceptionR	   t	   NameErrort	   Exceptiont
   exceptionsR
   R   R   R   t   packages.ssl_match_hostnameR   R   t	   util.ssl_R   R   R   R   t   utilR   t   _collectionsR   t	   getLoggerR   R}   RQ   Rn   Rp   t   objectR   RX   R_   Rw   t   UnverifiedHTTPSConnection(    (    (    s   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/requests/packages/urllib3/connection.pyt   <module>   sV   
""
V		