Your IP : 3.144.227.73
B
��Y� � @ sj d Z ddlmZ ddlZddlZddlZddlmZ ddlm Z m
Z
ddlmZ dej
dddfdd �ZdS )
z�
raven.utils.http
~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
� )�absolute_importN)�defaults)�urllib2�httplib)�match_hostnameFc
s� G ��fdd�dt j�� G � fdd�dtj�}|r:|g}n0ytjt�� d�g}W n tk
rh g }Y nX tj|� }tj dk r�t
�� } t
�|� z|�
| |�S t
�| � X |�
| ||�S )Nc s( e Zd ZejZdd� Z� �fdd�ZdS )z%urlopen.<locals>.ValidHTTPSConnectionc _ s t jj| f|�|� d S )N)r �HTTPConnection�__init__)�self�args�kwargs� r �A/opt/alt/python37/lib/python3.7/site-packages/raven/utils/http.pyr s z.urlopen.<locals>.ValidHTTPSConnection.__init__c sd t j| j| jf| jd�}| jr,|| _| �� tj |�tj
d�| _� d k r`t| j�� | j
p\| j� d S )N)�address�timeout)�ca_certsZ cert_reqs)�socket�create_connection�host�portr Z_tunnel_host�sockZ_tunnel�sslZwrap_socketZ
CERT_REQUIREDr Zgetpeercert�assert_hostname)r r )r r r r
�connect s
z-urlopen.<locals>.ValidHTTPSConnection.connectN)�__name__�
__module__�__qualname__r Z
HTTPS_PORTZdefault_portr r r )r r r r
�ValidHTTPSConnection s r c s e Zd Z� fdd�ZdS )z"urlopen.<locals>.ValidHTTPSHandlerc s | � � |�S )N)Zdo_open)r �req)r r r
�
https_open- s z-urlopen.<locals>.ValidHTTPSHandler.https_openN)r r r r r )r r r
�ValidHTTPSHandler, s r )�context)� � )r r r ZHTTPSHandlerr Z_create_unverified_context�AttributeErrorZbuild_opener�sys�version_infor �getdefaulttimeout�setdefaulttimeout�open)
�url�datar r Z
verify_sslr r �handlers�openerZdefault_timeoutr )r r r r
�urlopen s"