σ
βYc           @@  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 d d l m Z d d l m Z y 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
 r 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( 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 rR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]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR      s   t   ConnectionErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR	      s   (   t   NewConnectionErrort   ConnectTimeoutErrort   SubjectAltNameWarningt   SystemTimeWarning(   t   match_hostnamet   CertificateError(   t   resolve_cert_reqst   resolve_ssl_versiont   assert_fingerprintt   create_urllib3_contextt   ssl_wrap_socket(   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]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR   A   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]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR&   j   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]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/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'   R0   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyt   _prepare_conn   s    	
c         C@  s   |  j    } |  j |  d  S(   N(   R2   R8   (   R'   R0   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyt   connect₯   s    c         C@  s  t  | d k	 r | n i   } d | k } d | k } |  j | | d | d | x* | j   D] \ } } |  j | |  q_ Wd | k r |  j d d  n  |  j   | d k	 ry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-encodingR+   t   skip_accept_encodingt	   skip_hosts   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   headersR:   R;   t   headert   valuet   stringish_typest   chunkt   len_str(    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyt   request_chunked©   s8    
N(   R   R   R   t   port_by_schemet   default_portt   sockett   IPPROTO_TCPt   TCP_NODELAYR$   t   Falset   is_verifiedR&   R2   R8   R9   R    RR   (    (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR   F   s   
				t   HTTPSConnectionc           B@  s?   e  Z e d  Z d Z d d d d e j d d  Z d   Z	 RS(   R   c   	   	   K@  sJ   t  j |  | | d | d | | | |  _ | |  _ | |  _ d |  _ d  S(   NR   R   R   (   R   R&   t   key_filet	   cert_filet   ssl_contextt	   _protocol(	   R'   R+   R,   R[   R\   R   R   R]   R)   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR&   Υ   s    
			c      	   C@  s   |  j    } |  j |  |  j d  k rO t d t d   d t d    |  _ n  t d | d |  j d |  j	 d |  j  |  _
 d  S(   Nt   ssl_versiont	   cert_reqsR4   t   keyfilet   certfileR]   (   R2   R8   R]   R    R   R   R   R   R[   R\   R4   (   R'   R0   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR9   δ   s    		N(
   R   R   RS   RT   R    R_   RU   t   _GLOBAL_DEFAULT_TIMEOUTR&   R9   (    (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyRZ   Π   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©   | d k rB | s | r! d } qB |  j d k	 rB |  j j } qB n  | |  _ | |  _ | |  _ | |  _ | |  _ | o t j	 j
 |  |  _ | o t j	 j
 |  |  _ d S(   sX   
        This method should only be called once, before the connection is used.
        t   CERT_REQUIREDN(   R    R]   t   verify_modeR[   R\   R`   t   assert_hostnameR   t   ost   patht
   expandusert   ca_certst   ca_cert_dir(   R'   R[   R\   R`   Rk   Rg   R   Rl   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyt   set_cert  s    						c         C@  sι  |  j    } |  j } t |  d d   rO | |  _ |  j   d |  _ |  j } n  t j	 j
   t k  } | r t j d j t  t  n  |  j d  k rΒ t d t |  j  d t |  j   |  _ n  |  j } t |  j  | _ t d | d |  j d |  j d	 |  j d
 |  j d | d |  |  _ |  j rJt |  j j d t  |  j  nw | j t j  k rΑ|  j! t" k	 rΑ|  j j   } | j# d d  s¨t j d j |  t$  n  t% | |  j! pΊ|  n  | j t j& k pί|  j d  k	 |  _' d  S(   NR3   i    sW   System time is way off (before {0}). This will probably lead to SSL verification errorsR_   R`   R4   Ra   Rb   Rk   Rl   t   server_hostnameR]   t   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.)(    ((   R2   R+   R5   R    R4   R6   R7   R3   t   datetimet   datet   todayt   RECENT_DATEt   warningst   warnt   formatR   R]   R   R   R_   R   R`   Rf   R   R[   R\   Rk   Rl   R   t   getpeercertt   Truet   sslt	   CERT_NONERg   RX   R!   R   t   _match_hostnameRe   RY   (   R'   R0   t   hostnamet   is_time_offt   contextt   cert(    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR9     sR    		
	
						
N(   R   R   R   R    R`   Rk   Rl   R_   R   Rm   R9   (    (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyRd   φ   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_hostnameR1   (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyR|   ^  s    
	(:   t
   __future__R    Rq   t   loggingRh   R"   RU   R   R.   R   R-   Ru   t   packagesR   t   packages.six.moves.http_clientR   R%   R   Rz   t   SSLErrorR   t   ImportErrort   AttributeErrorR    t   BaseExceptionR	   t	   NameErrort	   Exceptiont
   exceptionsR
   R   R   R   t   packages.ssl_match_hostnameR   R   t	   util.ssl_R   R   R   R   R   t   utilR   t   _collectionsR   t	   getLoggerR   R   RS   Rr   Rt   t   objectR   RZ   Rd   R|   t   UnverifiedHTTPSConnection(    (    (    s]   /data/av2000/soap/soapenv/lib/python2.7/site-packages/requests/packages/urllib3/connection.pyt   <module>   sN   
"(	
&h		