
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
ó
•�abc           @   s+  d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z m Z m Z m Z m Z d d l m Z m Z m Z m Z d d	 l m Z m Z m Z d d
 l m Z m Z d d l 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) d d l m* Z* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 d d l1 m2 Z2 d d l m3 Z3 e j4 ƒ  d k rÑy e j5 Z6 Wn e7 k
 rÍe j8 Z6 n Xn	 e j Z6 e d „ Z9 e d „ Z: d e; f d „  ƒ  YZ< d e< f d „  ƒ  YZ= d „  Z> d S(   s“   
requests.session
~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
iÿÿÿÿN(   t   Mapping(   t	   timedeltai   (   t   _basic_auth_str(   t	   cookielibt   is_py3t   OrderedDictt   urljoint   urlparse(   t   cookiejar_from_dictt   extract_cookies_to_jart   RequestsCookieJart   merge_cookies(   t   Requestt   PreparedRequestt   DEFAULT_REDIRECT_LIMIT(   t   default_hookst   dispatch_hook(   t   to_native_string(   t   to_key_val_listt   default_headers(   t   TooManyRedirectst   InvalidSchemat   ChunkedEncodingErrort   ContentDecodingError(   t   CaseInsensitiveDict(   t   HTTPAdapter(   t   requote_urit   get_environ_proxiest   get_netrc_autht   should_bypass_proxiest   get_auth_from_urlt   rewind_bodyt   DEFAULT_PORTS(   t   codes(   t   REDIRECT_STATIt   Windowsc         C   s´   | d k r |  S|  d k r  | St | t ƒ o; t |  t ƒ sB |  S| t | ƒ ƒ } | j t |  ƒ ƒ g  | j ƒ  D] \ } } | d k rt | ^ qt } x | D] } | | =qŸ W| S(   sè   Determines appropriate setting for a given request, taking into account
    the explicit setting on that request, and the setting in the session. If a
    setting is a dictionary, they will be merged together using `dict_class`
    N(   t   Nonet
   isinstanceR    R   t   updatet   items(   t   request_settingt   session_settingt
   dict_classt   merged_settingt   kt   vt	   none_keyst   key(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   merge_setting2   s    1c         C   sZ   | d k s! | j d ƒ g  k r% |  S|  d k sF |  j d ƒ g  k rJ | St |  | | ƒ S(   s©   Properly merges both requests and session hooks.

    This is necessary because when request_hooks == {'response': []}, the
    merge breaks Session hooks entirely.
    t   responseN(   R$   t   getR0   (   t   request_hookst   session_hooksR*   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   merge_hooksQ   s
    !!t   SessionRedirectMixinc           B   sP   e  Z d  „  Z d „  Z e d e d d e d „ Z d „  Z d „  Z	 d „  Z
 RS(   c         C   s?   | j  r; | j d } t r. | j d ƒ } n  t | d ƒ Sd S(   s7   Receives a Response. Returns a redirect URI or ``None``t   locationt   latin1t   utf8N(   t   is_redirectt   headersR   t   encodeR   R$   (   t   selft   respR7   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   get_redirect_targetb   s    	c         C   sà   t  | ƒ } t  | ƒ } | j | j k r. t S| j d k rn | j d k rn | j d k rn | j d k rn t S| j | j k } | j | j k } t j | j d ƒ d f } | rÖ | j | k rÖ | j | k rÖ t S| pß | S(   sF   Decide whether Authorization header should be removed when redirectingt   httpiP   t   httpsi»  N(   iP   N(   i»  N(	   R   t   hostnamet   Truet   schemet   portR$   t   FalseR    R2   (   R=   t   old_urlt   new_urlt
   old_parsedt
   new_parsedt   changed_portt   changed_schemet   default_port(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   should_strip_authx   s    c	         k   sè  g  }
 |  j  | ƒ } xÌ| rã| j ƒ  } |
 j | ƒ |
 d | _ y | j Wn- t t t f k
 r~ | j j	 d t
 ƒ n Xt | j ƒ |  j k r³ t d |  j d | ƒ‚ n  | j ƒ  | j d ƒ r÷ t | j ƒ } d t | j ƒ | f } n  t | ƒ } | j ƒ  } | j s3t | j t | ƒ ƒ } n t | ƒ } t | ƒ | _ |  j | | ƒ | j t j t j f k r¯d } x! | D] } | j j | d ƒ q†Wd | _  n  | j } y | d
 =Wn t! k
 rÖn Xt" | j# | | j ƒ t$ | j# |  j% ƒ | j& | j# ƒ |  j' | | ƒ } |  j( | | ƒ | j) d k	 oVd | k pVd	 | k } | rlt* | ƒ n  | } | r€| Vq |  j+ | d | d | d | d | d | d t
 |	 �} t" |  j% | | j ƒ |  j  | ƒ } | Vq Wd S(   sB   Receives a Response. Returns a generator of Responses or Requests.i   t   decode_contents   Exceeded %s redirects.R1   s   //s   %s:%ss   Content-Lengths   Content-Types   Transfer-Encodingt   Cookiet   streamt   timeoutt   verifyt   certt   proxiest   allow_redirectsN(   s   Content-Lengths   Content-Types   Transfer-Encoding(,   R?   t   copyt   appendt   historyt   contentR   R   t   RuntimeErrort   rawt   readRF   t   lent   max_redirectsR   t   closet
   startswithR   t   urlR   RD   t   geturlt   netlocR   R   t   rebuild_methodt   status_codeR!   t   temporary_redirectt   permanent_redirectR;   t   popR$   t   bodyt   KeyErrorR	   t   _cookiesR   t   cookiest   prepare_cookiest   rebuild_proxiest   rebuild_autht   _body_positionR   t   send(   R=   R>   t   reqRQ   RR   RS   RT   RU   t   yield_requestst   adapter_kwargst   histRb   t   prepared_requestt   parsed_rurlt   parsedt   purged_headerst   headerR;   t
   rewindable(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   resolve_redirects‘   sr    	
			c         C   s{   | j  } | j } d | k r@ |  j | j j | ƒ r@ | d =n  |  j rU t | ƒ n d } | d k	 rw | j | ƒ n  d S(   sé   When being redirected we may want to strip authentication from the
        request to avoid leaking credentials. This method intelligently removes
        and reapplies authentication where possible to avoid credential loss.
        t   AuthorizationN(   R;   Rb   RN   t   requestt	   trust_envR   R$   t   prepare_auth(   R=   Rw   R1   R;   Rb   t   new_auth(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyRp   ý   s    		$
c         C   s5  | d k	 r | n i  } | j } | j } t | ƒ j } | j ƒ  } | j d ƒ } t | d | ƒ} |  j r¿ | r¿ t	 | d | ƒ}	 |	 j | |	 j d ƒ ƒ }
 |
 r¿ | j
 | |
 ƒ q¿ n  d | k rÕ | d =n  y t | | ƒ \ } } Wn t k
 rd \ } } n X| r1| r1t | | ƒ | d <n  | S(   s°  This method re-evaluates the proxy configuration by considering the
        environment variables. If we are redirected to a URL covered by
        NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
        proxy keys for this URL (in case they were stripped by a previous
        redirect).

        This method also replaces the Proxy-Authorization header where
        necessary.

        :rtype: dict
        t   no_proxyt   alls   Proxy-AuthorizationN(   NN(   R$   R;   Rb   R   RD   RW   R2   R   R€   R   t
   setdefaultR   Rk   R   (   R=   Rw   RU   R;   Rb   RD   t   new_proxiesRƒ   t   bypass_proxyt   environ_proxiest   proxyt   usernamet   password(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyRo     s*    		
c         C   s‹   | j  } | j t j k r0 | d k r0 d } n  | j t j k rW | d k rW d } n  | j t j k r~ | d k r~ d } n  | | _  d S(   s‚   When being redirected we may want to change the method of the request
        based on certain specs or browser behavior.
        t   HEADt   GETt   POSTN(   t   methodRf   R!   t	   see_othert   foundt   moved(   R=   Rw   R1   R�   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyRe   :  s    				N(   t   __name__t
   __module__R?   RN   RF   R$   RC   R}   Rp   Ro   Re   (    (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR6   `   s   		k		)t   Sessionc           B   s  e  Z d  Z d d d d d d d d d	 d
 d d d g Z d „  Z d „  Z d „  Z d „  Z d! d! d! d! d! d! d! e	 d! d! d! d! d! d! d „ Z
 d „  Z d „  Z d „  Z d! d! d „ Z d! d „ Z d! d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d  „  Z RS("   s~  A Requests session.

    Provides cookie persistence, connection-pooling, and configuration.

    Basic Usage::

      >>> import requests
      >>> s = requests.Session()
      >>> s.get('http://httpbin.org/get')
      <Response [200]>

    Or as a context manager::

      >>> with requests.Session() as s:
      >>>     s.get('http://httpbin.org/get')
      <Response [200]>
    R;   Rm   t   authRU   t   hookst   paramsRS   RT   t   prefetcht   adaptersRQ   R€   R_   c         C   s¥   t  ƒ  |  _ d  |  _ i  |  _ t ƒ  |  _ i  |  _ t |  _	 t
 |  _ d  |  _ t |  _ t
 |  _ t i  ƒ |  _ t ƒ  |  _ |  j d t ƒ  ƒ |  j d t ƒ  ƒ d  S(   Ns   https://s   http://(   R   R;   R$   R–   RU   R   R—   R˜   RF   RQ   RC   RS   RT   R   R_   R€   R   Rm   R   Rš   t   mountR   (   R=   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   __init__j  s    								c         C   s   |  S(   N(    (   R=   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt	   __enter__¡  s    c         G   s   |  j  ƒ  d  S(   N(   R`   (   R=   t   args(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   __exit__¤  s    c         C   s*  | j  p i  } t | t j ƒ s0 t | ƒ } n  t t t ƒ  |  j  ƒ | ƒ } | j } |  j rƒ | rƒ |  j rƒ t	 | j
 ƒ } n  t ƒ  } | j d | j j ƒ  d | j
 d | j d | j d | j d t | j |  j d t ƒd t | j |  j ƒ d	 t | |  j ƒ d
 | d t | j |  j ƒ ƒ 
| S(   s‹  Constructs a :class:`PreparedRequest <PreparedRequest>` for
        transmission and returns it. The :class:`PreparedRequest` has settings
        merged from the :class:`Request <Request>` instance and those of the
        :class:`Session`.

        :param request: :class:`Request` instance to prepare with this
            session's settings.
        :rtype: requests.PreparedRequest
        R�   Rb   t   filest   datat   jsonR;   R*   R˜   R–   Rm   R—   (   Rm   R%   R   t	   CookieJarR   R   R
   R–   R€   R   Rb   R   t   prepareR�   t   upperR    R¡   R¢   R0   R;   R   R˜   R5   R—   (   R=   R   Rm   t   merged_cookiesR–   t   p(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   prepare_request§  s*    
							c         C   sÇ   t  d | j ƒ  d | d | d | d | p- i  d | d | p? i  d | d	 | d
 | ƒ 
} |  j | ƒ } | po i  } |  j | j | | | | ƒ } i |	 d 6|
 d 6} | j | ƒ |  j | | � } | S(   sñ  Constructs a :class:`Request <Request>`, prepares it and sends it.
        Returns :class:`Response <Response>` object.

        :param method: method for the new :class:`Request` object.
        :param url: URL for the new :class:`Request` object.
        :param params: (optional) Dictionary or bytes to be sent in the query
            string for the :class:`Request`.
        :param data: (optional) Dictionary, bytes, or file-like object to send
            in the body of the :class:`Request`.
        :param json: (optional) json to send in the body of the
            :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the
            :class:`Request`.
        :param cookies: (optional) Dict or CookieJar object to send with the
            :class:`Request`.
        :param files: (optional) Dictionary of ``'filename': file-like-objects``
            for multipart encoding upload.
        :param auth: (optional) Auth tuple or callable to enable
            Basic/Digest/Custom HTTP Auth.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param allow_redirects: (optional) Set to True by default.
        :type allow_redirects: bool
        :param proxies: (optional) Dictionary mapping protocol or protocol and
            hostname to the URL of the proxy.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use. Defaults to ``True``.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        :rtype: requests.Response
        R�   Rb   R;   R    R¡   R¢   R˜   R–   Rm   R—   RR   RV   (   R   R¥   R¨   t   merge_environment_settingsRb   R&   Rr   (   R=   R�   Rb   R˜   R¡   R;   Rm   R    R–   RR   RV   RU   R—   RQ   RS   RT   R¢   Rs   t   prept   settingst   send_kwargsR>   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR   Ï  s*    )	
c         K   s#   | j  d t ƒ |  j d | | � S(   så   Sends a GET request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        RV   R�   (   R…   RC   R   (   R=   Rb   t   kwargs(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR2     s    c         K   s#   | j  d t ƒ |  j d | | � S(   sé   Sends a OPTIONS request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        RV   t   OPTIONS(   R…   RC   R   (   R=   Rb   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   options!  s    c         K   s#   | j  d t ƒ |  j d | | � S(   sæ   Sends a HEAD request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        RV   RŒ   (   R…   RF   R   (   R=   Rb   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   head,  s    c         K   s   |  j  d | d | d | | �S(   s¬  Sends a POST request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param json: (optional) json to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        RŽ   R¡   R¢   (   R   (   R=   Rb   R¡   R¢   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   post7  s    
c         K   s   |  j  d | d | | �S(   sY  Sends a PUT request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        t   PUTR¡   (   R   (   R=   Rb   R¡   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   putC  s    	c         K   s   |  j  d | d | | �S(   s[  Sends a PATCH request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        t   PATCHR¡   (   R   (   R=   Rb   R¡   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   patchN  s    	c         K   s   |  j  d | | � S(   sè   Sends a DELETE request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        t   DELETE(   R   (   R=   Rb   R­   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   deleteY  s    c         K   s  | j  d |  j ƒ | j  d |  j ƒ | j  d |  j ƒ | j  d |  j ƒ t | t ƒ rj t d ƒ ‚ n  | j d t	 ƒ } | j
 d ƒ } | j } |  j d | j ƒ } t ƒ  } | j | | � } t ƒ  | }	 t d |	 ƒ | _ t d	 | | | � } | j r1x- | j D] }
 t |  j |
 j |
 j ƒ qWn  t |  j | | j ƒ |  j | | | � } | r{g  | D] }
 |
 ^ qin g  } | r¯| j d
 | ƒ | j ƒ  } | | _ n  | sôy( t |  j | | d t	 | �ƒ | _ Wqôt k
 rðqôXn  | s| j n  | S(   sI   Send a given PreparedRequest.

        :rtype: requests.Response
        RQ   RS   RT   RU   s#   You can only send PreparedRequests.RV   Rb   t   secondsR1   i    Rt   (   R…   RQ   RS   RT   RU   R%   R   t
   ValueErrorRi   RC   R2   R—   t   get_adapterRb   t   preferred_clockRr   R   t   elapsedR   RY   R	   Rm   R   R\   R}   t   insertt   nextt   _nextt   StopIterationRZ   (   R=   R   R­   RV   RQ   R—   t   adaptert   startt   rR¼   R>   t   genRY   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyRr   c  sB    			 %(
c   
      C   s  |  j  r« | d k	 r$ | j d ƒ n d } t | d | ƒ} x* | j ƒ  D] \ } }	 | j | |	 ƒ qI W| t k s� | d k r« t j j d ƒ p¢ t j j d ƒ } q« n  t	 | |  j
 ƒ } t	 | |  j ƒ } t	 | |  j ƒ } t	 | |  j ƒ } i | d 6| d 6| d 6| d 6S(	   s^   
        Check the environment and merge it with some settings.

        :rtype: dict
        Rƒ   t   REQUESTS_CA_BUNDLEt   CURL_CA_BUNDLERS   RU   RQ   RT   N(   R€   R$   R2   R   R'   R…   RC   t   ost   environR0   RU   RQ   RS   RT   (
   R=   Rb   RU   RQ   RS   RT   Rƒ   t   env_proxiesR,   R-   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR©   ¬  s    	!c         C   sM   x6 |  j  j ƒ  D]% \ } } | j ƒ  j | ƒ r | Sq Wt d | ƒ ‚ d S(   s~   
        Returns the appropriate connection adapter for the given URL.

        :rtype: requests.adapters.BaseAdapter
        s*   No connection adapters were found for '%s'N(   Rš   R'   t   lowerRa   R   (   R=   Rb   t   prefixRÁ   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyRº   É  s    c         C   s(   x! |  j  j ƒ  D] } | j ƒ  q Wd S(   s+   Closes all adapters and as such the sessionN(   Rš   t   valuesR`   (   R=   R-   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR`   ×  s    c         C   so   | |  j  | <g  |  j  D]$ } t | ƒ t | ƒ k  r | ^ q } x' | D] } |  j  j | ƒ |  j  | <qH Wd S(   sw   Registers a connection adapter to a prefix.

        Adapters are sorted in descending order by prefix length.
        N(   Rš   R^   Ri   (   R=   RË   RÁ   R,   t   keys_to_moveR/   (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR›   Ü  s    4c            s#   t  ‡  f d †  ˆ  j Dƒ ƒ } | S(   Nc         3   s'   |  ] } | t  ˆ  | d  ƒ f Vq d  S(   N(   t   getattrR$   (   t   .0t   attr(   R=   (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pys	   <genexpr>è  s    (   t   dictt	   __attrs__(   R=   t   state(    (   R=   sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   __getstate__ç  s    c         C   s1   x* | j  ƒ  D] \ } } t |  | | ƒ q Wd  S(   N(   R'   t   setattr(   R=   RÓ   RÐ   t   value(    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   __setstate__ë  s    N(   R“   R”   t   __doc__RÒ   Rœ   R�   RŸ   R¨   R$   RC   R   R2   R¯   R°   R±   R³   Rµ   R·   Rr   R©   Rº   R`   R›   RÔ   R×   (    (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyR•   Q  s2   		7			)D				
	I					c           C   s   t  ƒ  S(   sQ   
    Returns a :class:`Session` for context-management.

    :rtype: Session
    (   R•   (    (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   sessionð  s    (?   RØ   RÇ   t   platformt   timet   collectionsR    t   datetimeR   R–   R   t   compatR   R   R   R   R   Rm   R   R	   R
   R   t   modelsR   R   R   R—   R   R   t   _internal_utilsR   t   utilsR   R   t
   exceptionsR   R   R   R   t
   structuresR   Rš   R   R   R   R   R   R   R   R    t   status_codesR!   R"   t   systemt   perf_counterR»   t   AttributeErrort   clockR0   R5   t   objectR6   R•   RÙ   (    (    (    sA   /usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.pyt   <module>	   s<   (""4	ñÿ  