HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/supervisor/tests/__pycache__/test_http_client.cpython-36.pyc
3

�k�`�5�@sxddlZddlZddlZddlmZddlmZGdd�dej�ZGdd�dej�ZGdd	�d	e	�Z
Gd
d�de	�ZdS)�N)�as_bytes)�StringIOc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�
ListenerTestscCsddlm}|S)Nr)�Listener)�supervisor.http_clientr)�selfr�r�&/usr/lib/python3.6/test_http_client.py�_getTargetClass	szListenerTests._getTargetClasscCs
|j��S)N)r
)rrrr	�_makeOne
szListenerTests._makeOnecCs |j�}|j|jdd�d�dS)N)r�assertEqual�status)r�instrrr	�test_statusszListenerTests.test_statuscCsP|j�}z:tj}t�}|t_|j|jdd�d�|j|j�d�Wd|t_XdS)N�url�errorz
url error
)r�sys�stderrrrr�getvalue)rrZ
old_stderrrrrr	�
test_errorszListenerTests.test_errorcCs"|j�}|j|jddd�d�dS)N)rr�response_header)rrrrr	�test_response_headersz"ListenerTests.test_response_headercCs|j�}|j|jd�d�dS)N)rr�done)rrrrr	�	test_done#szListenerTests.test_donecCsH|j�}z2tj}t�}|t_|jdd�|j|j�d�Wd|t_XdS)Nr�data)rr�stdoutr�feedrr)rrZ
old_stdoutrrrr	�	test_feed'szListenerTests.test_feedcCs|j�}|j|jd�d�dS)N)rr�close)rrrrr	�
test_close2szListenerTests.test_closeN)�__name__�
__module__�__qualname__r
rrrrrrrrrrr	rsrc@s6eZdZdd�ZdMdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dS)N�HTTPHandlerTestscCsddlm}|S)Nr)�HTTPHandler)rr$)rr$rrr	r
7sz HTTPHandlerTests._getTargetClassN�cCs(|dkr|j�}i}|j�||||d�S)N)�map)�
_makeListenerr
)r�listener�username�passwordZ
socket_maprrr	r;szHTTPHandlerTests._makeOnecCs
t�}|S)N)�
DummyListener)rr(rrr	r'FszHTTPHandlerTests._makeListenercCs"|j�}d|_|jt|jd�dS)N�abc)rr�assertRaises�AssertionError�get)rrrrr	�test_get_url_not_NoneJsz&HTTPHandlerTests.test_get_url_not_NonecCs|j�}|jt|jdd�dS)Nznothttp://localhostz/abc)rr-�NotImplementedErrorr/)rrrrr	�test_get_bad_schemeOsz$HTTPHandlerTests.test_get_bad_schemecsn|j�}g�g��fdd�|_�fdd�|_|jdd�|j|jd�|j�tjtjfg�|j�dg�dS)	Ncs
�j|�S)N)�append)�arg)�socketsrr	�<lambda>\sz;HTTPHandlerTests.test_get_implied_port_80.<locals>.<lambda>cs
�j|�S)N)r3)�tup)�connectsrr	r6]szhttp://localhostz/abc/def�P�	localhost)r:r9)	r�
create_socket�connectr/r�port�socket�AF_INET�SOCK_STREAM)rrr)r8r5r	�test_get_implied_port_80Xsz)HTTPHandlerTests.test_get_implied_port_80csn|j�}g�g��fdd�|_�fdd�|_|jdd�|j|jd�|j�tjtjfg�|j�dg�dS)	Ncs
�j|�S)N)r3)r4)r5rr	r6gsz9HTTPHandlerTests.test_get_explicit_port.<locals>.<lambda>cs
�j|�S)N)r3)r7)r8rr	r6hszhttp://localhost:8080z/abc/def�r:)r:rB)	rr;r<r/rr=r>r?r@)rrr)r8r5r	�test_get_explicit_portcsz'HTTPHandlerTests.test_get_explicit_portcs`|j�}g�g��fdd�|_�fdd�|_|jdd�|j�tjtjfg�|j�dg�dS)Ncs
�j|�S)N)r3)r4)r5rr	r6rszGHTTPHandlerTests.test_get_explicit_unix_domain_socket.<locals>.<lambda>cs
�j|�S)N)r3)r7)r8rr	r6ssz
unix:///a/b/cr%z/a/b/c)rr;r<r/rr>ZAF_UNIXr@)rrr)r8r5r	�$test_get_explicit_unix_domain_socketnsz5HTTPHandlerTests.test_get_explicit_unix_domain_socketcsv|j�}g��fdd�|_t�|_|j�|j|jjd�|j|jd�|j�dg�|j	|jj�|j|j
d�dS)Ncs
�jd�S)NT)r3r)�delsrr	r6{sz-HTTPHandlerTests.test_close.<locals>.<lambda>rTZCLOSED)rZdel_channel�DummySocketr>rrr(�closed�	connected�
assertTruer)rrr)rEr	rxszHTTPHandlerTests.test_closecsFddlm}|j�}g��fdd�|_|jdd�|j�d|g�dS)Nr)�CRLFcs
�j|�S)N)r3)�val)�pushesrr	r6�sz.HTTPHandlerTests.test_header.<locals>.<lambda>�namerKz	name: val)rrJr�push�headerr)rrJrr)rLr	�test_header�szHTTPHandlerTests.test_headercCs"|j�}d|_|j|j�d�dS)NT)r�
error_handledr�handle_error)rrrrr	�!test_handle_error_already_handled�sz2HTTPHandlerTests.test_handle_error_already_handledcsn|j�}g��fdd�|_d|_|j|j�d�|j|jjd�|j|jjd�|j�dg�|j|j	�dS)Ncs
�jd�S)NT)r3r)rGrr	r6�sz4HTTPHandlerTests.test_handle_error.<locals>.<lambda>�fooz"Cannot connect, error: None (None)T)
rrrrrRr(�	error_url�	error_msgrIrQ)rrr)rGr	�test_handle_error�sz"HTTPHandlerTests.test_handle_errorcsb|j�}g��fdd�|_d|_d|_|j�|j|j�|j�ddddddd	dd
dddg�dS)Ncs�jt|��S)N)r3r)rK)�pushedrr	r6�szBHTTPHandlerTests.test_handle_connect_no_password.<locals>.<lambda>�/r:sGET / HTTP/1.1s
sHost: localhostsAccept-Encoding: chunkedsAccept: */*s"User-agent: Supervisor HTTP Client)rrN�path�host�handle_connectrIrHr)rrr)rXr	�test_handle_connect_no_password�s*z0HTTPHandlerTests.test_handle_connect_no_passwordcsr|j�}g��fdd�|_d|_d|_d|_d|_|j�|j|j�|j	�ddd	dd
dddddd
dddg�dS)Ncs�jt|��S)N)r3r)rK)rXrr	r6�szDHTTPHandlerTests.test_handle_connect_with_password.<locals>.<lambda>rYr:r*r)sGET / HTTP/1.1s
sHost: localhostsAccept-Encoding: chunkedsAccept: */*s"User-agent: Supervisor HTTP Clients-Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=)
rrNrZr[r*r)r\rIrHr)rrr)rXr	�!test_handle_connect_with_password�s2z2HTTPHandlerTests.test_handle_connect_with_passwordcCs(|j�}|jd�|j|jjdg�dS)Nr)rrrr(�fed_data)rrrrr	r�s
zHTTPHandlerTests.test_feedcCsD|j�}|j|_d|_|jd�|j|jjdg�|j|jd�dS)Nr,rT�abcfoo�)r�body�part�buffer�collect_incoming_datarr(r_)rrrrr	�'test_collect_incoming_data_part_is_body�s
z8HTTPHandlerTests.test_collect_incoming_data_part_is_bodycCs@|j�}d|_d|_|jd�|j|jjg�|j|jd�dS)Nr,rTr`)rrcrdrerr(r_)rrrrr	�+test_collect_incoming_data_part_is_not_body�s
z<HTTPHandlerTests.test_collect_incoming_data_part_is_not_bodycsH|j�}g��fdd�|_d|_|j�|j�dg�|j|jd�dS)Ncs
�jd�S)NT)r3r)�partedrr	r6�sz8HTTPHandlerTests.test_found_terminator.<locals>.<lambda>Tra)rrcrdZfound_terminatorr)rrr)rhr	�test_found_terminator�sz&HTTPHandlerTests.test_found_terminatorcCs(|j�}d|_|j�|j|jd�dS)Nra)rrd�ignorer)rrrrr	�test_ignore�szHTTPHandlerTests.test_ignorecCs |j�}d|_|jt|j�dS)NsNOTHTTP/1.0 200 OK)rrdr-�
ValueError�status_line)rrrrr	�$test_status_line_not_startswith_http�sz5HTTPHandlerTests.test_status_line_not_startswith_httpcCsT|j�}d|_|j�\}}}|j|d�|j|d�|j|d�|j|j|j�dS)NsHTTP/1.0 200 OKsHTTP/1.0��sOK)rrdrmrrc�headers)rr�versionr
�reasonrrr	�test_status_line_200�sz%HTTPHandlerTests.test_status_line_200cs�|j�}d|_g��fdd�|_|j�\}}}|j|d�|j|d�|j|d�|j|j|j�|j|jjd�|j�dg�dS)	NsHTTP/1.0 201 OKcs
�jd�S)NT)r3r)rGrr	r6	sz;HTTPHandlerTests.test_status_line_not_200.<locals>.<lambda>sHTTP/1.0��sOKzCannot read, status code 201T)	rrdrrmrrcrjr(rV)rrrqr
rrr)rGr	�test_status_line_not_200sz)HTTPHandlerTests.test_status_line_not_200csV|j�}d|_d|_d|_g��fdd�|_|j�|j|j|j�|j�dg�dS)Nrasnot chunked�cs
�j|�S)N)r3)�L)�termsrr	r6szEHTTPHandlerTests.test_headers_empty_line_nonchunked.<locals>.<lambda>)	rrd�encoding�length�set_terminatorrprrcrb)rrr)rxr	�"test_headers_empty_line_nonchunkedsz3HTTPHandlerTests.test_headers_empty_line_nonchunkedcCs0|j�}d|_d|_|j�|j|j|j�dS)Nraschunked)rrdryrprrc�chunked_size)rrrrr	�test_headers_empty_line_chunked s
z0HTTPHandlerTests.test_headers_empty_line_chunkedcCs"|j�}d|_|j|j�d�dS)N�:)rrdrrp)rrrrr	�+test_headers_nonempty_line_no_name_no_value'sz<HTTPHandlerTests.test_headers_nonempty_line_no_name_no_valuecsH|j�}d|_g��fdd�|_|j�|j|jd�|j�dg�dS)NsTransfer-Encoding: chunkedcs�j||f�S)N)r3)�n�v)�	responsesrr	r60szOHTTPHandlerTests.test_headers_nonempty_line_transfer_encoding.<locals>.<lambda>�chunked�transfer-encoding)r�r�)rrdrrprry)rrr)r�r	�,test_headers_nonempty_line_transfer_encoding,sz=HTTPHandlerTests.test_headers_nonempty_line_transfer_encodingcsH|j�}d|_g��fdd�|_|j�|j|jd�|j�dg�dS)NsContent-Length: 3cs�j||f�S)N)r3)r�r�)r�rr	r69szLHTTPHandlerTests.test_headers_nonempty_line_content_length.<locals>.<lambda>rv�content-length�3)r�r�)rrdrrprrz)rrr)r�r	�)test_headers_nonempty_line_content_length5sz:HTTPHandlerTests.test_headers_nonempty_line_content_lengthcs:|j�}d|_g��fdd�|_|j�|j�dg�dS)NsX-Test: abccs�j||f�S)N)r3)r�r�)r�rr	r6BszGHTTPHandlerTests.test_headers_nonempty_line_arbitrary.<locals>.<lambda>�x-test�abc)r�r�)rrdrrpr)rrr)r�r	�$test_headers_nonempty_line_arbitrary>sz5HTTPHandlerTests.test_headers_nonempty_line_arbitrarycCs8|j�}|jdd�|j|jjd�|j|jjd�dS)N�a�b)rrrr(�response_header_name�response_header_value)rrrrr	rFsz%HTTPHandlerTests.test_response_headercsB|j�}g��fdd�|_|j�|j�dg�|j|jj�dS)Ncs
�jd�S)NT)r3r)rGrr	r6Osz,HTTPHandlerTests.test_body.<locals>.<lambda>T)rrrbrrIr(r)rrr)rGr	�	test_bodyLszHTTPHandlerTests.test_bodycCs"|j�}|j�|j|jj�dS)N)rrrIr()rrrrr	rTszHTTPHandlerTests.test_donecCs6|j�}d|_d|_|j|j�d�|j|jd�dS)Nra�)rrdrzrr})rrrrr	�test_chunked_size_empty_lineYs
z-HTTPHandlerTests.test_chunked_size_empty_linecCsF|j�}d|_d|_|j|j�d�|j|jd�|j|j|j�dS)N�0r�)rrdrzrr}rc�trailer)rrrrr	�test_chunked_size_zero_size`sz,HTTPHandlerTests.test_chunked_size_zero_sizecsf|j�}d|_d|_g��fdd�|_|j|j�d�|j|j|j�|j|jd�|j�dg�dS)Ns10r�cs
�j|�S)N)r3)Zsz)rxrr	r6mszAHTTPHandlerTests.test_chunked_size_nonzero_size.<locals>.<lambda>��)rrdrzr{rr}rc�chunked_body)rrr)rxr	�test_chunked_size_nonzero_sizehsz/HTTPHandlerTests.test_chunked_size_nonzero_sizecsvddlm}|j�}d|_g�g��fdd�|_�fdd�|_|j�|j�|g�|j�dg�|j|j|j	�dS)Nr)rJsbuffercs
�j|�S)N)r3)r�)rxrr	r6ysz4HTTPHandlerTests.test_chunked_body.<locals>.<lambda>cs
�j|�S)N)r3)r�)�linesrr	r6zs)
rrJrrdr{rr�rrcr})rrJrr)r�rxr	�test_chunked_bodyssz"HTTPHandlerTests.test_chunked_bodycCs"|j�}d|_|j|j�d�dS)Nra)rrdrr�)rrrrr	�test_trailer_line_not_crlf�sz+HTTPHandlerTests.test_trailer_line_not_crlfcsnddlm}|j�}||_g�g��fdd�|_�fdd�|_|j|j�d�|j�dg�|j�dg�dS)Nr)rJcs
�jd�S)NT)r3r)�donesrr	r6�sz9HTTPHandlerTests.test_trailer_line_crlf.<locals>.<lambda>cs
�jd�S)NT)r3r)�closesrr	r6�sT)rrJrrdrrrr�)rrJrr)r�r�r	�test_trailer_line_crlf�sz'HTTPHandlerTests.test_trailer_line_crlf)Nr%N)(r r!r"r
rr'r0r2rArCrDrrPrSrWr]r^rrfrgrirkrnrsrur|r~r�r�r�r�rr�rr�r�r�r�r�r�rrrr	r#6sJ
	
				
r#c@sTeZdZdZdZdZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�ZdS)r+NFcCs
g|_dS)N)r_)rrrr	�__init__�szDummyListener.__init__cCs
||_dS)N)rG)rrrrr	r�szDummyListener.closecCs||_||_dS)N)rUrV)rr�msgrrr	r�szDummyListener.errorcCs|jj|�dS)N)r_r3)rrrrrr	r�szDummyListener.feedcCs||_||_dS)N)Z
status_urlZ
status_int)rr�intrrr	r
�szDummyListener.statuscCs||_||_dS)N)r�r�)rrrM�valuerrr	r�szDummyListener.response_headercCs
d|_dS)NT)r)rrrrr	r�szDummyListener.done)
r r!r"rGrUrVrr�rrrr
rrrrr	r+�sr+c@seZdZdZdd�ZdS)rFFcCs
d|_dS)NT)rG)rrrr	r�szDummySocket.closeN)r r!r"rGrrrrr	rF�srF)r>rZunittestZsupervisor.compatrrZTestCaserr#�objectr+rFrrrr	�<module>s.]