HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/cockpit/channels/__pycache__/http_channel.cpython-39.pyc
a

�/�h��@snddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZe�e�ZGdd�de�ZdS)�N�)�AsyncChannel�ChannelError)�
JsonObject�get_dict�get_int�
get_object�get_str�typecheckedc@s�eZdZdZeejjee	d�dd��Z
ee	ejjd�dd��Zeejjdd	d
�dd��Z
eejjeed
eejjd�dd��Ze	d	d�dd�Zd	S)�HttpChannelzhttp-stream2)�response�binary�returncs0ddh�|s��ddh��fdd�|��D�S)NZ
ConnectionzTransfer-EncodingzContent-LengthZRangecsi|]\}}|�vr||�qS�r)�.0�key�value��remover�A/usr/lib/python3.9/site-packages/cockpit/channels/http_channel.py�
<dictcomp>)�z+HttpChannel.get_headers.<locals>.<dictcomp>)�updateZ
getheaders)rr
rrr�get_headers szHttpChannel.get_headers)�optionsrcCs*t|dd�}t|dd�}t|dd�}t|dd�}|durL|durLtddd��|durh|durhtdd	d��|dur�|dur�tdd
d��|du�rt|dd�}|dur�t|dd�}|dur�tj|d
�}q�tjt|d�d�}nt��}d|v�r|d�sd|_tjj|_	t
jj|||d�St
jj
||d�SdS)N�addressZ	localhostZtls�unix�port�protocol-errorz#TLS on Unix socket is not supported��messagez&no "port" or "unix" option for channelz-cannot specify both "port" and "unix" options�	authority�data)Zcadata�file)ZcafileZvalidateF)r�context)r)r	rrr�sslZcreate_default_contextZcheck_hostnameZ
VerifyModeZ	CERT_NONEZverify_mode�http�clientZHTTPSConnection�HTTPConnection)rZopt_addressZopt_tls�opt_unixZopt_portr!r"r$rrr�
create_client+s.

zHttpChannel.create_clientz
str | NoneN)�
connectionr)rcCs,|r t�tj�|_|j�|�n|��dS)N)�socketZAF_UNIXZsock�connect)r+r)rrrr-NszHttpChannel.connectzdict[str, str])r+�method�path�headers�bodyrcCs|j|||pi|d�|��S)N)r0r1)�requestZgetresponse)r+r.r/r0r1rrrr2YszHttpChannel.requestc
�sVt�d|�t|d�}t|d�}t|ddd�d�}d|vrFtdd	d
��|�|�}|��d}|��IdH}|durtq~||7}q\z"|�|j	|t|dd��IdHWnrt
jy�}ztd
t|�d
�|�WYd}~nDd}~0t
tf�y}ztdt|�d
�|�WYd}~n
d}~00z&|�|j||||�p,i|�IdH}	Wn@tjjt
f�yz}ztdt|�d
�|�WYd}~n
d}~00|jd|	j|	j|j|	|jd�d�zj|�|	j|j�IdH}
|
�s��q�|�|
�IdH�q�t�d�|	��}
|
dk�s�J�|�|j�IdHWn@tjjt
f�yH}ztdt|�d
�|�WYd}~n
d}~00|��dS)Nzopen %sr.r/r0cSsdd�|��D�S)NcSsi|]\}}|t|t��qSr)r
�str)r�k�vrrrrfrz5HttpChannel.run.<locals>.<lambda>.<locals>.<dictcomp>)�items)�drrr�<lambda>frz!HttpChannel.run.<locals>.<lambda>r+rz4connection sharing is not implemented on this bridgerrrzunknown-hostkeyz	not-foundZ
terminatedr)r
)Zcommand�status�reasonr0zreading response done)�logger�debugr	rrr*Zready�readZ	in_threadr-r%ZSSLCertVerificationErrorr3�OSError�IOErrorr2r&r'Z
HTTPExceptionZsend_controlr9r:rZ	is_binary�read1Z
BLOCK_SIZE�write�closeZdone)�selfrr.r/r0r+r1r"�excr�blockrrr�runasP



"&(&(�
(zHttpChannel.run)�__name__�
__module__�__qualname__Zpayload�staticmethodr&r'ZHTTPResponse�boolrrr(r*r-r3�bytesr2rFrrrrrs
"
�r)Zhttp.clientr&Zloggingr,r%ZchannelrrZjsonutilrrrrr	r
Z	getLoggerrGr;rrrrr�<module>s