Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/client.cpython-37.pyc

B

��vP��@s�ddlZddlZddlZyddlZWn ek
rDddlmZYnXddlmZddl	Z	ddl
mZddlmZddgZ
Gdd�d�Ze�ZejfZeed�r�eejf7ZdS)	�N)�	url_quote)�exc)�PY3�send_request_app�SendRequestc@sHeZdZdZejejfdd�Zdd�ZdZ	e
�d�Zdd	�Z
d
d�ZdS)
rax
    Sends the request, as described by the environ, over actual HTTP.
    All controls about how it is sent are contained in the request
    environ itself.

    This connects to the server given in SERVER_NAME:SERVER_PORT, and
    sends the Host header in HTTP_HOST -- they do not have to match.
    You can send requests to servers despite what DNS says.

    Set ``environ['webob.client.timeout'] = 10`` to set the timeout on
    the request (to, for example, 10 seconds).

    Does not add X-Forwarded-For or other standard headers

    If you use ``send_request_app`` then simple ``httplib``
    connections will be used.
    cCs||_||_dS)N)�HTTPConnection�HTTPSConnection)�selfrr�r
�=/opt/alt/python37/lib/python3.7/site-packages/webob/client.py�__init__#szSendRequest.__init__c
Cs|d}|dkr|j}n|dkr(|j}ntd|��d|kr�|�d�}|sRtd��d|krl|�dd	�\}}n|dkrzd
}nd}||d<||d<i}d
|kr�|�|�r�|d
|d<|d|f|�}i}	x>|��D]2\}
}|
�d�r�|
dd��dd��	�}
||	|
<q�Wt
|�dd��t
|�dd��}|�d��r@|d|d7}yt|�dd��}
Wntk
�rnd}
YnX|
�r�|d�|
�}nd}|
|	d<|�d��r�|d|	d<|�d ��s�d |}y |�
|d!|||	�|��}Wn�tjk
�rt��}|||�Stjtjfk
�r�}z�t|tj��r<|jdd"k�sZt|tj��rv|jdd#k�rvt�d$|d�}|||�S|jdtk�r�t�d%�}|||�S�Wdd}~XYnX|�|j�}d&|j|jf}|||�|�d'�}|dk	�r�|�t|��}n|��}|��|gS)(Nzwsgi.url_scheme�http�httpszUnknown scheme: %rZSERVER_NAMEZ	HTTP_HOSTz2environ contains neither SERVER_NAME nor HTTP_HOST�:�Z80Z443ZSERVER_PORTzwebob.client.timeout�timeoutz%(SERVER_NAME)s:%(SERVER_PORT)sZHTTP_��_�-ZSCRIPT_NAME�Z	PATH_INFOZQUERY_STRING�?ZCONTENT_LENGTH�0rz
wsgi.inputzContent-LengthZCONTENT_TYPEzContent-Type�/ZREQUEST_METHOD����z/Name or service not known (bad domain name: %s)zConnection refusedz%s %szcontent-length)rr�
ValueError�get�split�_timeout_supported�items�
startswith�replace�titler�int�read�requestZgetresponse�socketrrZHTTPGatewayTimeout�error�gaierror�
isinstance�argsZHTTPBadGateway�
_e_refused�
parse_headers�msg�status�reason�	getheader�close)r	�environZstart_response�scheme�	ConnClass�host�port�kwZconn�headers�key�value�pathZcontent_length�body�resZresp�e�headers_outr.�lengthr
r
r�__call__(s�













zSendRequest.__call__)ztransfer-encodingz\r?\n\s*c	Cs�g}tr|j}n|j}x�|D]�}|s&q|d��rn|sBtd|��|��\}}|d|��}|�||f�qt|t	�r�|\}}n0y|�
dd�\}}Wntd|f��YnX|��}d|ks�d|kr�|j�d|�}|�
�|jkr|�||f�qW|S)	zJ
        Turn a Message object into a list of WSGI-style headers.
        rz%First header starts with a space (%r)z, rrzInvalid header: %r�
z
)r�_headersr8�isspacer�pop�strip�appendr)�tupler�MULTILINE_RE�sub�lower�filtered_headers)	r	�messager?r8Zfull_headerZlast_header�
last_valuer:�headerr
r
rr,�s6



zSendRequest.parse_headerscCs"tjdkr|tjtjfkrdSdS)N)��FT)�sys�version_info�httplibrr)r	r4r
r
rr�szSendRequest._timeout_supportedN)�__name__�
__module__�__qualname__�__doc__rTrrrrArL�re�compilerIr,rr
r
r
rrsW
&�ENODATA)�errnorRrYrT�ImportErrorZhttp.clientZclientZwebob.compatrr&�webobrr�__all__rrZECONNREFUSEDr+�hasattrr[r
r
r
r�<module>s""