BYPASS SHELL BY ./RAZORGANZ
Server: nginx/1.20.1
System: Linux iZdzfnv9mwfppeZ 5.10.134-19.2.al8.x86_64 #1 SMP Wed Oct 29 22:47:09 CST 2025 x86_64
User: apache (48)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib64/python3.6/site-packages/tornado/__pycache__/simple_httpclient.cpython-36.opt-1.pyc
3

	��f�k�@s�ddlmZddlmZddlmZmZmZmZm	Z	m
Z
ddlmZddlm
Z
mZddlmZddlmZmZddlmZmZmZmZdd	lmZdd
lmZddlZddlZddlZddl Z ddl!Z!ddl"Z"ddl#Z#ddl$Z$ddl%Z%ddl&m'Z'ddl(Z)dd
l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddl*Z*e*j3�rLddl*m4Z4m5Z5m6Z6Gdd�de�Z7Gdd�de�Z8Gdd�de�Z9Gdd�dej:�Z;e<dk�r�ej=e9�e�dS)�)�_unicode)�gen)�HTTPResponse�	HTTPError�AsyncHTTPClient�main�
_RequestProxy�HTTPRequest)�httputil)�HTTP1Connection�HTTP1ConnectionParameters)�IOLoop)�StreamClosedError�IOStream)�Resolver�OverrideResolver�_client_ssl_defaults�is_valid_ip)�gen_log)�	TCPClientN)�BytesIO)�Dict�Any�Callable�Optional�Type�Union)�
TracebackType)�Deque�Tuple�Listcs6eZdZdZedd��fdd�Zed�dd�Z�ZS)	�HTTPTimeoutErrorz�Error raised by SimpleAsyncHTTPClient on timeout.

    For historical reasons, this is a subclass of `.HTTPClientError`
    which simulates a response code of 599.

    .. versionadded:: 5.1
    N)�message�returncstt|�jd|d�dS)NiW)r")�superr!�__init__)�selfr")�	__class__��)/usr/lib64/python3.6/simple_httpclient.pyr%5szHTTPTimeoutError.__init__)r#cCs
|jpdS)N�Timeout)r")r&r(r(r)�__str__8szHTTPTimeoutError.__str__)�__name__�
__module__�__qualname__�__doc__�strr%r+�
__classcell__r(r()r'r)r!,sr!cs6eZdZdZedd��fdd�Zed�dd�Z�ZS)	�HTTPStreamClosedErroraZError raised by SimpleAsyncHTTPClient when the underlying stream is closed.

    When a more specific exception is available (such as `ConnectionResetError`),
    it may be raised instead of this one.

    For historical reasons, this is a subclass of `.HTTPClientError`
    which simulates a response code of 599.

    .. versionadded:: 5.1
    N)r"r#cstt|�jd|d�dS)NiW)r")r$r2r%)r&r")r'r(r)r%HszHTTPStreamClosedError.__init__)r#cCs
|jpdS)Nz
Stream closed)r")r&r(r(r)r+KszHTTPStreamClosedError.__str__)r,r-r.r/r0r%r+r1r(r()r'r)r2<s
r2c
s�eZdZdZdeeeefeeeeefeedd��fdd�
Z	dd��fd	d
�Z
eee
gdfdd�dd
�Zdd�dd�Zed�dd�Zeegdfee
gdfdd�dd�Zedd�dd�Zedd�dd�Zdeedd�dd�Z�ZS)�SimpleAsyncHTTPClientaiNon-blocking HTTP client with no external dependencies.

    This class implements an HTTP 1.1 client on top of Tornado's IOStreams.
    Some features found in the curl-based AsyncHTTPClient are not yet
    supported.  In particular, proxies are not supported, connections
    are not reused, and callers cannot select the network interface to be
    used.
    �
N�@)�max_clients�hostname_mapping�max_buffer_size�resolver�defaults�max_header_size�
max_body_sizer#cs�tt|�j|d�||_tj�|_i|_i|_||_	||_
||_|rR||_d|_
nt�|_d|_
|dk	rxt|j|d�|_t|jd�|_dS)aCreates a AsyncHTTPClient.

        Only a single AsyncHTTPClient instance exists per IOLoop
        in order to provide limitations on the number of pending connections.
        ``force_instance=True`` may be used to suppress this behavior.

        Note that because of this implicit reuse, unless ``force_instance``
        is used, only the first call to the constructor actually uses
        its arguments. It is recommended to use the ``configure`` method
        instead of the constructor to ensure that arguments take effect.

        ``max_clients`` is the number of concurrent requests that can be
        in progress; when this limit is reached additional requests will be
        queued. Note that time spent waiting in this queue still counts
        against the ``request_timeout``.

        ``hostname_mapping`` is a dictionary mapping hostnames to IP addresses.
        It can be used to make local DNS changes when modifying system-wide
        settings like ``/etc/hosts`` is not possible or desirable (e.g. in
        unittests).

        ``max_buffer_size`` (default 100MB) is the number of bytes
        that can be read into memory at once. ``max_body_size``
        (defaults to ``max_buffer_size``) is the largest response body
        that the client will accept.  Without a
        ``streaming_callback``, the smaller of these two limits
        applies; with a ``streaming_callback`` only ``max_body_size``
        does.

        .. versionchanged:: 4.2
           Added the ``max_body_size`` argument.
        )r:FTN)r9�mapping)r9)r$r3�
initializer6�collections�deque�queue�active�waitingr8r;r<r9�own_resolverrrr�
tcp_client)r&r6r7r8r9r:r;r<)r'r(r)r>Ys"*
z SimpleAsyncHTTPClient.initialize)r#cs,tt|�j�|jr|jj�|jj�dS)N)r$r3�closerDr9rE)r&)r'r(r)rF�s
zSimpleAsyncHTTPClient.close)�request�callbackr#cCs�t�}|jj|||f�t|j�|jksX|jj|jj�t	|j
|j�tj
|j|d��}nd}|||f|j|<|j�|jr�tjdt|j�t|j�f�dS)Nzin request queuezImax_clients limit reached, request queued. %d active, %d queued requests.)�objectrA�append�lenrBr6�io_loop�add_timeout�time�min�connect_timeout�request_timeout�	functools�partial�_on_timeoutrC�_process_queuer�debug)r&rGrH�key�timeout_handler(r(r)�
fetch_impl�sz SimpleAsyncHTTPClient.fetch_implcCspxj|jrjt|j�|jkrj|jj�\}}}||jkr4q|j|�||f|j|<tj|j	|�}|j
|||�qWdS)N)rArKrBr6�popleftrC�_remove_timeoutrRrS�_release_fetch�_handle_request)r&rWrGrH�release_callbackr(r(r)rU�s

z$SimpleAsyncHTTPClient._process_queuecCstS)N)�_HTTPConnection)r&r(r(r)�_connection_class�sz'SimpleAsyncHTTPClient._connection_class)rGr^�final_callbackr#c	Cs&|j�|||||j|j|j|j�dS)N)r`r8rEr;r<)r&rGr^rar(r(r)r]�sz%SimpleAsyncHTTPClient._handle_request)rWr#cCs|j|=|j�dS)N)rBrU)r&rWr(r(r)r\�sz$SimpleAsyncHTTPClient._release_fetchcCs:||jkr6|j|\}}}|dk	r.|jj|�|j|=dS)N)rCrL�remove_timeout)r&rWrGrHrXr(r(r)r[�s

z%SimpleAsyncHTTPClient._remove_timeout)rW�infor#cCsn|j|\}}}|jj|||f�|r0dj|�nd}t|dt|�|jj�|jd�}|jj	||�|j|=dS)z�Timeout callback of request.

        Construct a timeout HTTPResponse when a timeout occurs.

        :arg object key: A simple object to mark the request.
        :info string key: More detailed timeout information.
        zTimeout {0}r*iW)�error�request_timeN)
rCrA�remove�formatrr!rLrN�
start_time�add_callback)r&rWrcrGrHrX�
error_messageZtimeout_responser(r(r)rT�sz!SimpleAsyncHTTPClient._on_timeout)r4Nr5NNNN)N)r,r-r.r/�intrr0rrr>rFr	rrrYrU�typer`r]rIr\r[rTr1r(r()r'r)r3Os* =

r3c
@sjeZdZedddddddg�Zeeeegdfee	gdfe
ee
e
dd	�	d
d�Zdd�d
d�Z
eedeeefejfd�dd�Zd4edd�dd�Zdd�dd�Zeed�dd�Zedd�dd�Zdd�dd�Ze	dd�d d!�Zd"eeeeed#�d$d%�Z dd�d&d'�Z!ee"j#e"j$fe"j%dd(�d)d*�Z&ed�d+d,�Z'dd�d-d.�Z(dd�d/d0�Z)e*dd1�d2d3�Z+dS)5r_�GETZHEAD�POST�PUTZDELETE�PATCHZOPTIONSN)	�clientrGr^rar8rEr;r<r#c		Cs�tj�|_|jj�|_tj�|_||_||_||_||_	||_
||_||_||_
d|_d|_g|_d|_d|_d|_tj�jtj|j��dd��dS)NcSs|j�S)N)�result)�fr(r(r)�<lambda>sz*_HTTPConnection.__init__.<locals>.<lambda>)r
ZcurrentrLrNrh�start_wall_timerqrGr^rar8rEr;r<�code�headers�chunksZ
_decompressor�_timeout�	_sockaddrZ
add_futurerZconvert_yielded�run)	r&rqrGr^rar8rEr;r<r(r(r)r%s&

z_HTTPConnection.__init__)r#c�s��y�tjjt|jj��|_|jjd-kr6td|jj��|jj	}d|krV|j
d�\}}}tj|�\}}|dkr�|jjdkr|dnd}t
jd|�r�|dd.�}||_|jjd	kr�tj}ntj}|j|jj�}d}|jj�r�t|jj�r�|jj}ntd
|jjf��t|jj|jj�}	|	�r�|jj|j|	tj|jd��|_ |j!j"|||||j#|d�IdH}
|j$dk�rl|
j%�dS|
|_&|j&j'|j(�|j)�|j$dk�r�dS|jj�r�|jj|j|jjtj|jd
��|_ |jj*|j+k�r�|jj,�r�t-d|jj*��x*d/D]"}t.|j|d��r�t/d|���q�Wd|jj0k�r8d|jj0d<d|jj0k�r�d|jj	k�rp|jj	j
d�d0|jj0d<n|jj	|jj0d<d1\}}
|jj1dk	�r�|jj1|jj2}}
n$|jj3dk	�r�|jj3}|jj4�p�d}
|dk	�r|jj5d2k�r�td|jj5��dtt6j7tj8||
���|jj0d<|jj9�r0|jj9|jj0d<|jj,�s�|jj*d3k}|jj:dk	�p^|jj;dk	}|�rn|�s||�r�|�r�td!|�r�d"nd|jj*f��|jj<�r�d#|jj0d$<|jj:dk	�r�t=t>|jj:��|jj0d%<|jj*dk�r�d&|jj0k�r�d'|jj0d&<|jj?�rd(|jj0d)<|jj@�p d*|jjA�r6d+|jjAnd}|jB|
�|_CtjD|jj*|d�}|jCjE||jj0�|jj<�r�|jCjF|�IdHn|jGd,�IdHWn(tHk
�r�|jItJjK���s��YnXdS)4N�http�httpszUnsupported url scheme: %s�@i��Pz^\[.*\]$�Fz?Unrecognized IPv4 or IPv6 address for network_interface, got %rzwhile connecting)�af�ssl_optionsr8�	source_ipzduring requestzunknown method %s�
proxy_host�
proxy_port�proxy_username�proxy_password�proxy_auth_modez%s not supportedZ
ConnectionrF�Host��basiczunsupported auth_mode %szBasic Z
Authorizationz
User-AgentrnrprozLBody must %sbe None for method %s (unless allow_nonstandard_methods is true)znot z100-continueZExpectzContent-LengthzContent-Typez!application/x-www-form-urlencodedZgzipzAccept-Encoding�/�?T)r|r}���)r�r�r�r�r�r�)NN)Nr�)rnrpro)L�urllib�parseZurlsplitrrG�urlZparsed�scheme�
ValueError�netloc�
rpartitionr
Zsplit_host_and_port�re�matchZparsed_hostnameZ
allow_ipv6�socketZAF_INETZ	AF_UNSPEC�_get_ssl_optionsZnetwork_interfacerrOrPrQrLrMrhrRrSrTryrEZconnectr8rarF�streamZset_close_callback�on_connection_closer[�method�_SUPPORTED_METHODSZallow_nonstandard_methods�KeyError�getattr�NotImplementedErrorrw�username�passwordZ
auth_usernameZ
auth_passwordZ	auth_mode�base64Z	b64encodeZencode_username_passwordZ
user_agent�body�
body_producer�expect_100_continuer0rK�decompress_response�pathZquery�_create_connection�
connection�RequestStartLineZ
write_headers�
read_response�_write_body�	Exception�_handle_exception�sys�exc_info)r&r�Zuserpass�_�hostZportr�r�r�Ztimeoutr�rWr�r�Z
body_expectedZbody_presentZreq_pathZ
start_liner(r(r)r{!s�








z_HTTPConnection.run)r�r#cCs�|dkr�|jjdk	r|jjS|jjrL|jjdkrL|jjdkrL|jjdkrLtStjtj	j
|jjd�}|jjsxd|_tj|_
|jjdk	r�|j|jj|jj�ttd�r�|jtjO_|SdS)Nr})ZcafileF�OP_NO_COMPRESSION)rGr�Z
validate_certZca_certsZclient_certZ
client_keyr�sslZcreate_default_contextZPurposeZSERVER_AUTHZcheck_hostnameZ	CERT_NONEZverify_modeZload_cert_chain�hasattrZoptionsr�)r&r�Zssl_ctxr(r(r)r��s(
z _HTTPConnection._get_ssl_options)rcr#cCs8d|_|rdj|�nd}|jdk	r4|jtt|�d�dS)z�Timeout callback of _HTTPConnection instance.

        Raise a `HTTPTimeoutError` when a timeout occurs.

        :info string key: More detailed timeout information.
        NzTimeout {0}r*)ryrgrar�r!)r&rcrjr(r(r)rT�s

z_HTTPConnection._on_timeoutcCs"|jdk	r|jj|j�d|_dS)N)ryrLrb)r&r(r(r)r[�s
z_HTTPConnection._remove_timeout)r�r#c	Cs6|jd�t|dtd|j|jt|jj�d�|j�}|S)NT)Z
no_keep_aliver;r<Z
decompress)	Zset_nodelayrrr;r<�boolrGr�rz)r&r�r�r(r(r)r��s
z"_HTTPConnection._create_connection)�
start_readr#c�s�|jjdk	r|jj|jj�n.|jjdk	rL|jj|jj�}|dk	rL|IdH|jj�|r�y|jj|�IdHWn$tk
r�|jt	j
��s��YnXdS)N)rGr�r��writer��finishr�rr�r�r�)r&r��futr(r(r)r��s

z_HTTPConnection._write_bodycCs |jdk	r|j}d|_|�dS)N)r^)r&r^r(r(r)�_releases
z_HTTPConnection._release)�responser#cCs0|j�|jdk	r,|j}d|_|jj||�dS)N)r�rarLri)r&r�rar(r(r)�
_run_callbacks

z_HTTPConnection._run_callbackzOptional[Type[BaseException]])�typ�value�tbr#cCs�|jrr|j�t|t�r2|jdkr,td�}n|j}|jt|jd||j	j
�|j|jd��t
|d�rn|jj�dSt|t�SdS)Nz
Stream closediW)rdrerhr�T)rar[�
isinstancerZ
real_errorr2r�rrGrLrNrhrur�r�rF)r&r�r�r�r(r(r)r�s"




z!_HTTPConnection._handle_exceptioncCsR|jdk	rNd}|jjr|jj�yt|��Wn"tk
rL|jtj��YnXdS)NzConnection closed)rar�rdr2r�r�r�)r&r"r(r(r)r�<s
z#_HTTPConnection.on_connection_close)�
first_linerwr#c�s�|jjr&|jdkr&|jd�IdHdS|j|_|j|_||_|j�rHdS|jjdk	r�|jjd|�x*|jj�D]\}}|jjd||f�qpW|jjd�dS)N�dFz
%s %s %s
z%s: %s
z
)	rGr�rvr��reasonrw�_should_follow_redirectZheader_callbackZget_all)r&r�rw�k�vr(r(r)�headers_receivedFsz _HTTPConnection.headers_receivedcCs<|jjr8|jd	ko6|jjdko6|jdk	o6|jjd�dk	SdS)
N�-�.�/�3�4r�LocationF)r�r�r�r�r�)rGZfollow_redirectsrv�
max_redirectsrw�get)r&r(r(r)r�]s

z'_HTTPConnection._should_follow_redirectcsndj|j�}|j�t|jd|j�}|j��rtj|jj�}tjj	|jj
|jd�|_
|jjd|_|jd=|j
dkr�|jjd	kr�d
|_d|_x0dD](}y|jj|=Wq�tk
r�Yq�Xq�W||_|j�d|_|j�|jj|dd�}|j�fdd��|j�dS|jj�rt�}nt|�}t||j
t|dd�|j|jj�|j|j||jj
d�}|j|�|j�dS)N��original_requestr�r�r��-�.�/rnrm�Content-Length�Content-Type�Content-Encoding�Transfer-EncodingF)Zraise_errorcs�|j��S)N)rr)rs)rar(r)rt�sz(_HTTPConnection.finish.<locals>.<lambda>r�)r�rwrerh�bufferZ
effective_url)r�r�r�)r�r�r�r�) �joinrxr[r�rGr��copyr�r�Zurljoinr�rwr�rvr�r�r�r�rar�rqZfetchZadd_done_callback�_on_end_request�streaming_callbackrrrLrNrhrur�)r&�datar�Znew_request�hr�r�r�r()rar)r�hsV




z_HTTPConnection.finishcCs|jj�dS)N)r�rF)r&r(r(r)r��sz_HTTPConnection._on_end_request)�chunkr#cCs6|j�rdS|jjdk	r&|jj|�n|jj|�dS)N)r�rGr�rxrJ)r&r�r(r(r)�
data_received�s
z_HTTPConnection.data_received)N),r,r-r.�setr�rr3r	rrrkrr%r{r0rrrr�Z
SSLContextr�rTr[rrr�r�r�r�r��
BaseExceptionrr�r�r
ZResponseStartLiner�ZHTTPHeadersr�r�r�r��bytesr�r(r(r(r)r_�sB
"	=r_�__main__)>Ztornado.escaperZtornadorZtornado.httpclientrrrrrr	r
Ztornado.http1connectionrrZtornado.ioloopr
Ztornado.iostreamrrZtornado.netutilrrrrZtornado.logrZtornado.tcpclientrr�r?r�rRr�r�r�r�rN�iorZurllib.parser�Ztypingrrrrrr�typesrZ
TYPE_CHECKINGrrr r!r2r3ZHTTPMessageDelegater_r,Z	configurer(r(r(r)�<module>sH  -: