σ
φΐ\c           @@  sy  d  Z  d d l m Z d d l Z d d l m Z d d l Z d d l Z d d l m	 Z	 d d l
 m Z y d d l m Z Wn! e k
 r‘ d d l m Z n Xy d d l m Z Wn? e k
 rχ y d d l m Z Wqψ e k
 rσ d Z qψ Xn Xy d d	 l m Z Wn? e k
 rMy d d	 l m Z WqNe k
 rId Z qNXn Xy d d l Z Wn e k
 rqn Xy e j d
 g  Wn{ e j e j f k
 rγe e d e  se rΠe j j j e  n  e j d  qn! e j k
 re j d  n Xe r9d d l m Z m  Z  m! Z! d d l" m# Z# n  d g Z$ d   Z% e d    Z& d   Z' d   Z( d   Z) d S(   sΙ   
    sphinx.util.requests
    ~~~~~~~~~~~~~~~~~~~~

    Simple requests package loader

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i    (   t   absolute_importN(   t   contextmanager(   t   string_types(   t   urlsplit(   t   SSLError(   t   InsecureRequestWarning(   t   InsecurePlatformWarnings   requests[security]t   HAS_SNIs0  Some links may return broken results due to being unable to check the Server Name Indication (SNI) in the returned SSL cert against the hostname in the url requested. Recommended to install "requests[security]" as a dependency or upgrade to a python version with SNI support (Python 3 and Python 2.7.9+).sΞ   Some links may return broken results due to being unable to check the Server Name Indication (SNI) in the returned SSL cert against the hostname in the url requested. Recommended to install requests-2.4.1+.(   t   Anyt	   Generatort   Union(   t   Configs
   User-AgentsD   Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0c         C@  sJ   t  |  t  r t St |  d g   } | rB t  | d t  rB t St Sd S(   s   Check an exception is SSLError.t   argsi    N(   t
   isinstanceR   t   Truet   getattrt   False(   t   excR   (    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyt   is_ssl_errorW   s    c          k@  sH   t  j   6 |  j d  r9 t r9 t  j d d t n  d  VWd  QXd  S(   Nt   verifyt   ignoret   category(   t   warningst   catch_warningst   getR   t   filterwarnings(   t   kwargs(    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyt   ignore_insecure_warningd   s    c         C@  s   | j  s t St | d d  } | s) t St | t t f  rB | St |   d } d | k rt | j	 d  d } n  | j
 | t  Sd S(   s§   Get additional CA cert for a specific URL.

    This also returns ``False`` if verification is disabled.
    And returns ``True`` if additional CA cert not found.
    t   tls_cacertsi   t   @N(   t
   tls_verifyR   R   t   NoneR   R   R   t   tupleR   t   splitR   (   t   urlt   configt   certst   hostname(    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyt   _get_tls_cacertn   s    	c         K@  sq   | j  d t t   | j d d  } | rJ | j  d t |  |   n  t |    t j |  |  SWd QXd S(   sp   Sends a GET request like requests.get().

    This sets up User-Agent header and TLS verification automatically.t   headersR#   R   N(	   t
   setdefaultt   dictt   useragent_headert   popR   R&   R   t   requestsR   (   R"   R   R#   (    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyR      s    c         K@  sq   | j  d t t   | j d d  } | rJ | j  d t |  |   n  t |    t j |  |  SWd QXd S(   sr   Sends a HEAD request like requests.head().

    This sets up User-Agent header and TLS verification automatically.R'   R#   R   N(	   R(   R)   R*   R+   R   R&   R   R,   R   (   R"   R   R#   (    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyt   head   s    (   s
   User-AgentsD   Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0(*   t   __doc__t
   __future__R    R   t
   contextlibR   t   pkg_resourcesR,   t   sixR   t   six.moves.urllib.parseR   t$   requests.packages.urllib3.exceptionsR   t   ImportErrort   urllib3.exceptionsR   R   R   t   sslt   requiret   DistributionNotFoundt   VersionConflictR   R   t   packagest   urllib3t   disable_warningst   warnt   UnknownExtrat   typingR   R	   R
   t   sphinx.configR   R*   R   R   R&   R   R-   (    (    (    s3   lib/python2.7/site-packages/sphinx/util/requests.pyt   <module>
   sf    		
		