https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/httppeer.cpython-310.pyc
o

�]Lb�R�@s(ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZm	Z	mZmZmZmZddlmZejZejZejZdd	�ZGd
d�de�Zdd
�Zdd�Zdd�ZGdd�de
j�Z dd�Z!Gdd�dej"�Z#Gdd�de	j$j%�Z&dd�Z'dej(fdd�Z)d dd�Z*dS)!�)�absolute_importN�)�_)�getattr)�bundle2�error�httpconnection�pycompat�statichttprepo�url�util�wireprotov1peer)�urlutilc
Cszt�|�d}|t|d�td�}g}d}t�dt|�|�D]}|d7}|�|t|�t�||||��f�q |S)acEncode a string value into multiple HTTP headers.

    ``value`` will be encoded into 1 or more HTTP headers with the names
    ``header-<N>`` where ``<N>`` is an integer starting at 1. Each header
    name + value will be at most ``limit`` bytes long.

    Returns an iterable of 2-tuples consisting of header names and
    values as native strings.
    z-%s�000s: 
rr)r	�strurl�len�xrange�append�str)�value�header�limit�fmt�valuelen�result�n�i�r�4/usr/lib/python3/dist-packages/mercurial/httppeer.py�encodevalueinheaders$s*rc@s8eZdZdd�Zedd��Zd
dd�Zejfdd	�Z	dS)�
_multifilecGs6|D]}t�|d�stdt|�|��q||_d|_dS)N�lengthsO_multifile only supports file objects that have a length but this one does not:r)r�safehasattr�
ValueError�type�	_fileobjs�_index)�self�fileobjs�frrr�__init__Bs��
z_multifile.__init__cCstdd�|jD��S)Ncss�|]}|jVqdS�N)�length��.0r)rrr�	<genexpr>Ps�z$_multifile.length.<locals>.<genexpr>)�sumr%�r'rrrr,Nsz_multifile.lengthNcCs�|dkrd�dd�|jD��Sg}|rF|jt|j�krF|�|j|j�|��t|d�}||kr8|jd7_||8}|rF|jt|j�ksd�|�S)Nr�css�|]}|��VqdSr+)�readr-rrrr/Ts�z"_multifile.read.<locals>.<genexpr>���r)�joinr%r&rrr3)r'�amt�parts�gotrrrr3Rs�
z_multifile.readcCsB|tjkr	td��|dkrtd��|jD]}|�d�qd|_dS)NsP_multifile does not support anything other than os.SEEK_SET for whence on seek()rsQ_multifile only supports seeking to start, but that could be fixed if you need it)�os�SEEK_SET�NotImplementedErrorr%�seekr&)r'�offset�whencer)rrrr<^s
��

z_multifile.seekr+)
�__name__�
__module__�__qualname__r*�propertyr,r3r9r:r<rrrrr As

r cCs�|dkrd|d<|�dd�}|�di�}|�d|�d|fg}	d}
|duo)d	|v}|rc|rct�t|����}|s<|}n t|t�rMt�	|�}
t
|�|
_|
}t�	|�}t
|�|_t||�}t
|�|d
<n=|r�|dkskJ�|d�}|r{t
|�d
d�d�}
|
dkr�t�t|����}t|d|
�D]\}}|||<q�n|	t|���7}	dt�|	�}d||f}d}t�|d�r�|j}n|dur�t
|�}|dur�d|vr�d|d<t�}t�}|dur�|d�}|r�|�d�t|�d
��}|�d�d|vr�|�d�d|v�r|d��rdd�tj�tj�D�}|�dd
�|��|�r4td�t|��d|
�p&d �}|D]	\}}|||<�q*g}|D]}|���d!��rG|�|��q8|�rUd"�t|��|d#<|t�|�||�}|du�rr|�d$|�|�d%d&|�|||fS)'aWMake an HTTP request to run a command for a version 1 client.

    ``caps`` is a set of known server capabilities. The value may be
    None if capabilities are not yet known.

    ``capablefn`` is a function to evaluate a capability.

    ``cmd``, ``args``, and ``data`` define the command, its arguments, and
    raw data to pass to it.
    spushkeyr2sdataNsheadersssending %s command
scmdr�httppostargsz
X-HgArgs-Post�capabilitiess
httpheader�,rsX-HgArgs?%ss%s%sr!�Content-Type�application/mercurial-0.1s
httpmediatypes0.1spartial-pulls0.2txs0.2scompressioncSsg|]}|��j�qSr)�wireprotosupport�name)r.�errr�
<listcomp>�s��z(makev1commandrequest.<locals>.<listcomp>scomp=%s� s	X-HgProto�zx-hg�,�Varyssending %d bytes
zContent-Lengthz%d)�pop�debug�urlreq�	urlencode�sorted�items�
isinstance�bytes�io�BytesIOrr,r �int�splitrrr"�set�add�compengines�supportedwireengines�
CLIENTROLEr5�lower�
startswithrr	r�add_unredirected_header)�ui�requestbuilder�caps�	capablefn�repobaseurl�cmd�args�data�headers�q�
headersize�
postargsok�strargsr�argsio�
httpheader�encoded_argsrr�qs�cu�size�protoparams�
mediatypes�mt�comps�protoheaders�varyheaders�reqrrr�makev1commandrequestns�







�
�


��
�

r~cCs tjr|jS|��sdS|��S)z3Get request data, if any. If no data, returns None.N)r	�ispy3rk�has_data�get_data)r}rrr�_reqdata�s
r�c
Cs&|j}|jr�|�dd�r�d}||dt�|���t�|���f�d}t|���D]*\}}t�|�}t�|�}|�	d�rJ|durCd}|t
|�7}q*||d||f�q*|dura||d	|�t|�}|durt|d
d�}	|	durwt
|�}	||d|	�t
��}
d}zcz|�|�}Wn;tjy�}z
|jdkr�t�td
����d}~wtjy�}z|�dt�|����|��td|��d}~wwW|jr�|�dd�r�|r�|jnd}
||dt
��|
|
f�n#|j�r
|�dd��r|r�|jnd}
||dt
��|
|
f�wwwt�|�|S)zDSend a prepared HTTP request.

    Returns the response object.
    sdevelsdebug.peer-requestsdevel-peer-request: %s
s%s %sNsX-hgarg-rs  %s %ss+  %d bytes of commands arguments in headersr,s  %d bytes of datai�sauthorization failedshttp error requesting %s
r4s  finished in %.4f seconds (%d))rQ�	debugflag�
configboolr	�bytesurl�
get_method�get_full_urlrT�header_itemsrbrr�rr�timer�open�urlerr�	httperror�coder�Abortr�httplib�
HTTPExceptionr�hidepassword�	traceback�IOError�urlmod�wrapresponse)rd�openerr}�dbg�line�
hgargssizerrrkr,�start�res�instr�rrr�sendrequest�s�����


���
���
���
���������
	r�cseZdZ�fdd�Z�ZS)�RedirectedRepoErrorcstt|��|�||_dSr+)�superr�r*�respurl)r'�msgr���	__class__rrr*<s
zRedirectedRepoError.__init__)r?r@rAr*�
__classcell__rrr�rr�;sr�c	Cs�d}t�|���}|�|�r|dt|��}d}nd}|�d�|�d�kr4d}|js4|�td�|�zt�|�	dd��}	Wnt
yRt�|j�dd��}	Ynwt
�|�}
|	�d�rdt�|����|	�d�s�|�d	t
�|��td
�|
|	pzd|�d�f}|r�|r�t||��t�|��z|	�d
d�d}tdd�|�d�D��}
Wnty�t�td�|
|	f��w|
dkr�|r�tjd�|�}n-|
dkr�t�dt�|d��d}t�||�}tj�|�}|�|�}nt�td�|
|f��||	|fS)NFT�/sreal URL is %s
zcontent-type�sapplication/hg-error�application/mercurial-srequested URL: '%s'
sI'%s' does not appear to be an hg repository:
---%%<--- (%s)
%s
---%%<---
sno content-typerM�-rcSsg|]}t|��qSr)rZ)r.rrrrrKlsz*parsev1commandresponse.<locals>.<listcomp>�.s+'%s' sent a broken Content-Type header (%s))rrszlib)r��Brs'%s' uses newer protocol %s) r	r��geturl�endswithr�rstrip�quiet�warnr�	getheader�AttributeErrorrl�getrr�rbr�OutOfBandErrorr3rQr��	RepoErrorr[�tupler#rr^�decompressorreader�struct�unpack�readexactly�forwiretype)rd�baseurl�requrlrt�resp�compressible�
redirectedr��	qsdropped�proto�safeurlr��subtype�version_info�elen�ename�enginerrr�parsev1commandresponseAsb
�


��

����
r�c@s~eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS) �httppeercCs:||_||_||_||_|duod|v|_||_||_dS)NrC)rd�_path�_url�_caps�limitedarguments�
_urlopener�_requestbuilder)r'rd�pathrr�rerfrrrr*�s
zhttppeer.__init__cCs,|jjD]}|��t|ddd���qdS)N�	close_allcS�dSr+rrrrr�<lambda>�sz"httppeer.__del__.<locals>.<lambda>)r��handlers�closer)r'�hrrr�__del__�s�zhttppeer.__del__cC�|jSr+)r�r1rrrr��zhttppeer.urlcCr�r+rr1rrr�local��zhttppeer.localcCs|Sr+rr1rrr�peer�r�z
httppeer.peercCsdS)NTrr1rrr�canpush�r�zhttppeer.canpushcCsTz|jj|jj|jj}}}Wn
tyYdSw|j�td�|||f�dS)NsE(sent %d HTTP requests and %d bytes; received %d bytes in responses)
)r��
requestscount�sentbytescount�receivedbytescountr�rd�noter)r'�reqs�sent�recvrrrr��s�����zhttppeer.closecCr�r+)r�r1rrr�capabilities�r�zhttppeer.capabilitiesFc	Ks`t�|�}t|j|j|j|j|j||�\}}}t|j|j	|�}t
|j|j||||�\|_}}|Sr+)r	�byteskwargsr~rdr�r��capabler�r�r�r�)	r'ri�
_compressiblerjr}rurtr��ctrrr�_callstream�s

�
�zhttppeer._callstreamcKs0|j|fi|��}z	|��W|��S|��wr+)r�r3r�)r'rirj�fprrr�_call�szhttppeer._callc

KsR|�d�}z|�d�}Wntydg}Ynw|D]}|tjvr&|}nqt�|j|d|�}t�|j|d�}ddi}	zbz-|j	|f||	d�|��}
|
�dd	�}t
|�d
kr^t�t
d�|
��|WW|��t�|�Stjys�tjy�}z|jdtjtjfvr�t�t
d
�|jd	��t�|jd	��d}~ww|��t�|�w)NsunbundlerEr2�rbrFrG�rkrl�
rr�sunexpected response:rspush failed: %s)r�r[r�r�bundletypes�writebundlerdr�httpsendfiler�rr�
ResponseErrorrr�r9�unlinkr�r��socketrj�errno�
ECONNRESET�EPIPEr�)
r'ri�cgrj�types�xr$�tempnamer�rl�r�vals�errrrr�	_callpush�s@

�
����zhttppeer._callpushc
	Ksd}zstjddd�\}}t�|d��}|�d�}|r&|�|�|�d�}|sWd�n1s0wYt�|j|d��#}ddi}	|j	|f||	d	�|��Wd�W|dur_t�
|�SS1scwYW|durtt�
|�dSdS|dur�t�
|�ww)
Ns
hg-bundle-s.hg)�prefix�suffix�wbir�rFrGr�)r	�mkstempr9�fdopenr3�writerr�rdr�r�)
r'rir�rj�filename�fd�fh�d�fp_rlrrr�_calltwowaystreams0


��������zhttppeer._calltwowaystreamcKs|j|fddi|��S)Nr�T)r�)r'rirjrrr�_callcompressableszhttppeer._callcompressablecCs|�r+r)r'�	exceptionrrr�_abortr�zhttppeer._abortN)F)r?r@rAr*r�rr�r�r�r�r�r�r�rr
rrrrrrr��s	
(r�c@seZdZdZddd�ZdS)�queuedcommandfuturez@Wraps result() on command futures to trigger submission on call.NcCs,|��rtjj�||�S|j��|�|�Sr+)�doner	�futures�Futurer�
_peerexecutor�sendcommands)r'�timeoutrrrr s

zqueuedcommandfuture.resultr+)r?r@rA�__doc__rrrrrrsrcCsd}dd�}i}t|||||d|�\}}}	t|||�}
zt||||	|
dd�\}}}
Wn3ty]}
z't|||||
jd|�\}}}	t|||�}
t||||	|
dd�\}}}
WYd}
~
nd}
~
wwz
|
��}W|
��n|
��w|�d�szt�	d|��dt
|���i}||fS)	NcSs
t�d��)Nsshould not be called)r�ProgrammingError)r�rrrr�0s
z!performhandshake.<locals>.capablerDF)r�r�sunexpected content-type: %s�v1capabilities)r~r�r�r�r�r3r�rbrrr\r[)rdrr�rerfr�rjr}r�rtr�r�r�rJ�rawdata�inforrr�performhandshake+s8
��
����	

rc	Cs�t�|�}|js|jrt�td�|jp|j��|��\}}|�d|�|p,t	�
||�}t||||�\}}t||||||d�S)a-Construct an appropriate HTTP peer instance.

    ``opener`` is an ``url.opener`` that should be used to establish
    connections, perform HTTP requests.

    ``requestbuilder`` is the type used for constructing HTTP requests.
    It exists as an argument so extensions can override the default.
    sunsupported URL component: "%s"s	using %s
r)
rr�query�fragmentrr�r�authinforQr�r�rr�)	rdr�r�re�urr r�rrrr�makepeer`s
	��r"cCs�|r	t�td���z|�d�rtjst�td���t||�}|WStjyQ}z$zt�	|d||�}|�
td��|WWYd}~StjyL|�wd}~ww)Ns!cannot create new http repositoryshttps:s1Python support for SSL and HTTPS is not installedsstatic-s(falling back to static-http)
)rr�rrbr��	has_httpsr"r�r
�instancer�)rdr��create�intents�
createoptsr��
httpexceptionr�rrrr$|s&�
���r$)NN)+�
__future__rr�rXr9r�r��i18nrr	rr�rrrr
rr�rr
�utilsrr�r�rRr�objectr r~r�r�r�r�r��wirepeerr�rrrr�requestr"r$rrrr�<module>s4(
-|	HG5

https://t.me/RX1948 - 2025