Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_wsgiref.cpython-310.pyc
o

�9j{|�@s�ddlmZddlmZddlmZmZddlmZddlm	Z	ddlm
Z
ddlmZddl
mZdd	lmZmZmZdd
lmZddlmZddlmZmZdd
lmZddlmZddlmZmZm Z ddl!m"Z"ddl#m$Z$ddl%Z%ddl&Z&ddl'Z'ddl(Z(ddl)Z)ddlZGdd�de�Z*Gdd�de�Z+dd�Z,dd�Z-e,dfdd�Z.dd�Z/Gd d!�d!e
�Z0Gd"d#�d#e
�Z1Gd$d%�d%e
�Z2Gd&d'�d'e�Z3Gd(d)�d)e3�Z4Gd*d+�d+e
�Z5e6d,kr�e�7�dSdS)-�)�mock)�support)�
socket_helper�control_characters_c0)�warnings_helper)�NoLogRequestHandler)�TestCase)�setup_testing_defaults)�Headers)�BaseHandler�BaseCGIHandler�
SimpleHandler)�util)�	validator)�
WSGIServer�WSGIRequestHandler)�make_server)�HTTPConnection)�StringIO�BytesIO�BufferedReader)�
BaseServer)�python_implementationNc@� eZdZdZdd�Zdd�ZdS)�
MockServerzNon-socket HTTP servercCst�|||�|��dS�N)r�__init__�server_bind)�self�server_address�RequestHandlerClass�r!�(/usr/lib/python3.10/test/test_wsgiref.pyrszMockServer.__init__cCs"|j\}}||_||_|��dSr)r�server_name�server_port�
setup_environ)r�host�portr!r!r"r"s
zMockServer.server_bindN)�__name__�
__module__�__qualname__�__doc__rrr!r!r!r"rsrc@r)�MockHandlerzNon-socket HTTP handlercCs|j|_|j\|_|_dSr)�request�
connection�rfile�wfile�rr!r!r"�setup+szMockHandler.setupcC�dSrr!r1r!r!r"�finish/�zMockHandler.finishN)r(r)r*r+r2r4r!r!r!r"r,)sr,cC�|dddg�dgS)N�200 OK��Content-Typez
text/plain��DatezMon, 05 Jun 2006 18:49:54 GMT�
Hello, world!r!��environ�start_responser!r!r"�	hello_app3�
�r@cCs2|dddg�d�|d|d|dg��d�gS)	Nr7r8r:�;�HTTP_X_TEST_HEADER�QUERY_STRING�	PATH_INFO�
iso-8859-1)�join�encoder=r!r!r"�
header_app;s���rIsGET / HTTP/1.0

cCshtdd|tt�}tt|��}t�}tj}t�}t_z
|�||fd�W|t_n|t_w|�	�|�	�fS)N��P)�	127.0.0.1i�")
rrr,rr�sys�stderrr�finish_request�getvalue)�app�data�server�inp�out�olderr�errr!r!r"�	run_amockFsrXcCs�|�}d}|D]}|||kst�|d7}qz||Wn	ty%Ynwtd|��zttfWn
ty;YdSw|�}t|�|urGt�|D]
}t|�|ksSt�qIzt|�Wn
tydYdSwtd|��)aUtility to compare a generic 2.1/2.2+ iterator with an iterable

    If running under Python 2.2+, this tests the iterator using iter()/next(),
    as well as __getitem__.  'make_it' must be a function returning a fresh
    iterator to be tested (since this may test the iterator twice).r�zToo many items from __getitem__zToo many items from .__next__()N)�AssertionError�
IndexError�iter�
StopIteration�	NameError�next)�make_it�match�it�n�itemr!r!r"�compare_generic_iterTs4
�
��
rec@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�IntegrationTestsTcCsFt�dtj��d}|�|d|d|rdpdd�d��dS)	N�/rz(HTTP/1.0 200 OK
Server: WSGIServer/0.2 zA
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
zContent-Length: 13
rJz
Hello, world!rF)rrM�version�split�assertEqualrH)rrU�
has_length�pyverr!r!r"�check_hello{s���
���zIntegrationTests.check_hellocCst�\}}|�|�dSr)rXrm�rrUrWr!r!r"�test_plain_hello�s
z!IntegrationTests.test_plain_hellocCs*d}tt|�\}}|�|��dd�dS)NsmGET /p%61th/?query=test HTTP/1.0
X-Test-Header: Python test 
X-Test-Header: Python test 2
Content-Length: 0

���s+Python test,Python test 2;query=test;/path/)rXrIrj�
splitlines)rr-rUrWr!r!r"�test_environ�s�
�zIntegrationTests.test_environcCs2tddddd�\}}|�|��dd�dS)NsGET �xis HTTP/1.0

�rRrs!HTTP/1.0 414 Request-URI Too Long)rXrjrqrnr!r!r"�test_request_length�s�z$IntegrationTests.test_request_lengthcCs"ttt��\}}|j|dd�dS)NF)rk)rXrr@rmrnr!r!r"�test_validated_hello�sz%IntegrationTests.test_validated_hellocC�@dd�}tt|��\}}|�|�d��|�|��dd�dS)NcSs|dd�dgS)Nr7r8z
Hello, world!r!r=r!r!r"�bad_app�s
z>IntegrationTests.test_simple_validation_error.<locals>.bad_app�;A server error occurred.  Please contact the administrator.���z^AssertionError: Headers (('Content-Type', 'text/plain')) must be of type list: <class 'tuple'>�rXr�
assertTrue�endswithrjrq�rrxrUrWr!r!r"�test_simple_validation_error�s�
�z-IntegrationTests.test_simple_validation_errorc	Cs�dd�}gd�}|D]4\}}|j|d��"t||��\}}|�|�d��|�|��d|�Wd�n1s9wYq
dS)Ncs�fdd�}|S)Ncs|�dg�dgS)N�r9ztext/plain; charset=utf-8r<r!r=��statusr!r"rx�szWIntegrationTests.test_status_validation_errors.<locals>.create_bad_app.<locals>.bad_appr!)r�rxr!r�r"�create_bad_app�szFIntegrationTests.test_status_validation_errors.<locals>.create_bad_app))�200z4AssertionError: Status must be at least 4 characters)z20X OKz8AssertionError: Status message must begin w/3-digit code)�200OKz;AssertionError: Status message must have a space after coder�ryrz)�subTestrXr|r}rjrq)rr��testsr��exc_messagerUrWr!r!r"�test_status_validation_errors�s����z.IntegrationTests.test_status_validation_errorscCrw)NcSs|d��|ddg�dgS)N�
wsgi.inputr7r��data)�read��e�sr!r!r"rx�sz1IntegrationTests.test_wsgi_input.<locals>.bad_appryrzrZr{r~r!r!r"�test_wsgi_input�s��z IntegrationTests.test_wsgi_inputcCsldd�}tt|��\}}|�|�d��tj��d�d�}t��d�}|d|}|�	d|d|�dS)	NcSr6)Nr7r��r;zWed, 24 Dec 2008 13:29:32 GMTr�r!r�r!r!r"rQ�rAz3IntegrationTests.test_bytes_validation.<locals>.appz"GET / HTTP/1.0" 200 4
r�ascii�/s(HTTP/1.0 200 OK
Server: WSGIServer/0.2 sV
Content-Type: text/plain; charset=utf-8
Date: Wed, 24 Dec 2008 13:29:32 GMT

data)
rXrr|r}rMrhrirHrrj)rrQrUrW�ver�pyrlr!r!r"�test_bytes_validation�s���z&IntegrationTests.test_bytes_validationcCs>dd�}tt|�dd�\}}|�dtjdddd	g|���dS)
NcSs|dddg�|d�d�gS)Nr7r8r�rE�latin1�rHr�r!r!r"rQ�s
�z-IntegrationTests.test_cp1252_url.<locals>.appsGET /�%80 HTTP/1.0rtsHTTP/1.0 200 OKsContent-Type: text/plains#Date: Wed, 24 Dec 2008 13:29:32 GMT�s/��)rXrrjr�ANYrq)rrQrUrWr!r!r"�test_cp1252_url�s	
���z IntegrationTests.test_cp1252_urlcs�t�td��dd�}Gdd�dtt�}ttjd||d��|��j	�t
����fdd	�}t�tj|�}|�tjtj|�d�t
�
�������fd
d�}t
j|d�}|�����|��|��tjd
�dS)N�pthread_killcSs|dg�dtjgS)Nr7�)r�
SOCK_MAX_SIZEr=r!r!r"rQ�
z4IntegrationTests.test_interrupted_write.<locals>.appc@�eZdZdS)z<IntegrationTests.test_interrupted_write.<locals>.WsgiHandlerN�r(r)r*r!r!r!r"�WsgiHandler	�r�r)�
handler_classcs���dSr)�set)�signum�frame)�interruptedr!r"�signal_handler�z?IntegrationTests.test_interrupted_write.<locals>.signal_handlercs�t�j�}|�dd�|���$}|�d�	��tj��jtd�d�r%nqt	|����Wd�n1s6wY|�
�dS)N�GETrg�dTrY)�timeout)rrr-�getresponser��signal�SIGUSR1�wait�float�len�close)�http�response�r��main_threadr��receivedrSr!r"�
run_clients


��
z;IntegrationTests.test_interrupted_write.<locals>.run_client)�targetr�)r�
get_attributer�rrrr�HOST�
addCleanup�server_close�	threading�Eventr��	get_ident�Thread�start�handle_requestrGrjr�)rrQr�r��originalr��
backgroundr!r�r"�test_interrupted_write�s"z'IntegrationTests.test_interrupted_writeN)T)r(r)r*rmrorrrurvrr�r�r�r�r�r!r!r!r"rfys



rfc@s�eZdZdd�Zd$dd�Zdd�Zdd	�Zd%dd�Zej	e
d
�dd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)&�UtilityTestscCsJ||d�}t�|�|�t�|�|�|�|d|�|�|d|�|S)N��SCRIPT_NAMErErEr�)rr	rj�shift_path_info)r�sn_in�pi_in�part�sn_out�pi_out�envr!r!r"�
checkShift3s

zUtilityTests.checkShiftNcCs|i}t�|�t|t�r|�||t�nt|t�r#|�||t�n|�|||�||i}t�|�|�|||�dSr)rr	�
isinstancer�assertIsInstancerrj�assertIs)r�key�value�altr�r!r!r"�checkDefault;s



zUtilityTests.checkDefaultcKst�|�|�|||�dSr)rr	rj)rr�r��kwr!r!r"�checkCrossDefaultKs
zUtilityTests.checkCrossDefaultcKs t�|�|�t�|�|�dSr)rr	rj�application_uri)r�urir�r!r!r"�checkAppURIOs
zUtilityTests.checkAppURIrYcKs"t�|�|�t�||�|�dSr)rr	rj�request_uri)rr��queryr�r!r!r"�checkReqURISs
zUtilityTests.checkReqURI)�categorycCs^||fdd�}t||�|�}|�|jj�|D]}q|�|jj�|��|�|jj�dS)NcSst�t|�|�Sr)r�FileWrapperr)�text�sizer!r!r"r`Zsz%UtilityTests.checkFW.<locals>.make_it)re�assertFalse�filelike�closedr�r|)rr�r�rar`rbrdr!r!r"�checkFWWs
zUtilityTests.checkFWcCsRt�td�d�}|�td��|�|dd�Wd�dS1s"wYdS)N�foobar�zUse iterator protocol insteadrY�foo)rr�r�assertWarnsRegex�DeprecationWarningrj)r�wrapperr!r!r"�$test_filewrapper_getitem_deprecationjs�"�z1UtilityTests.test_filewrapper_getitem_deprecationcCs^|�ddddd�|�ddddd�|�ddddd�|�ddddd�|�dd	ddd�dS)
NrJrgz/x�x�/az/x/yz/a/x�/yz/x/�r�r1r!r!r"�testSimpleShiftsqs
zUtilityTests.testSimpleShiftscCs�|�ddddd�|�ddddd�|�dddd	d�|�dd
dd	d�|�dddd	d�|�dd
dd	d�|�ddddd�|�ddddd�|�ddddd�|�ddddd�|�ddddd�dS)Nz/a/bz/../yz..r�r�rJz//y�yz/a/b/yz//y/rgz/./yz/./y/z///./..//y/.//z/y/z///z/a/b/z/.//z/x//r�z/a/b/xz/.r�r1r!r!r"�testNormalizedShiftsxsz!UtilityTests.testNormalizedShiftscCsFddddddddd	d
ddt�fd
t�fdfD]
\}}|�||�qdS)N)�SERVER_NAMErL)�SERVER_PORT�80)�SERVER_PROTOCOL�HTTP/1.0)�	HTTP_HOSTrL)�REQUEST_METHODr�)r�rJ)rErg)�wsgi.version�rYr)�
wsgi.run_oncer)�wsgi.multithreadr)�wsgi.multiprocessrr��wsgi.errors)�wsgi.url_schemer�)rrr�)rr�r�r!r!r"�testDefaults�s"��zUtilityTests.testDefaultscCst|jdddd�|jdddd�|jdddd�|jddd	d�|jdd
dd�|jdd
dd�|jdddd�dS)Nr�zfoo.bar�r�r�https�on��HTTPS�1�yesr�r�r�r��443)r�r1r!r!r"�testCrossDefaults�szUtilityTests.testCrossDefaultscCsn|�t�i�d�|�t�ddi�d�|�t�ddi�d�|�t�ddi�d�|�t�ddi�d�dS)Nr�rr�r
r	rr
)rjr�guess_schemer1r!r!r"�testGuessScheme�s
zUtilityTests.testGuessSchemecCsv|�d�|jddd�|jddd�|jddd	d
�|jddd
�|jdddd�|jddd�|jdddd�dS)N�http://127.0.0.1/�http://127.0.0.1/spam�/spam�r��http://127.0.0.1/sp%E4m�/spämzhttp://spam.example.com:2071/zspam.example.com:2071�2071)r�r�zhttp://spam.example.com/zspam.example.comrrL)r�r�zhttps://127.0.0.1/r
rzhttp://127.0.0.1:8000/�8000)r�r�)r�r1r!r!r"�testAppURIs�s 
���
�zUtilityTests.testAppURIscCs�|�d�|jddd�|jddd�|jdddd	�|jd
ddd	�|jdddd	�|jd
ddd	�|jddddd�|jddddd�|jdddddd�dS)Nrrrrrrzhttp://127.0.0.1/spammity/spamz	/spammityr�z http://127.0.0.1/spammity/sp%E4mz"http://127.0.0.1/spammity/spam;hamz	/spam;hamz/http://127.0.0.1/spammity/spam;cookie=1234,5678z/spam;cookie=1234,5678z%http://127.0.0.1/spammity/spam?say=nizsay=ni)r�rErDz'http://127.0.0.1/spammity/spam?s%E4y=nizs%E4y=nir)r�r1r!r!r"�testReqURIs�s0
������
�zUtilityTests.testReqURIscCs|�ddddg�dS)Nږxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz�x�xxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz�xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz)r�r1r!r!r"�testFileWrapper�szUtilityTests.testFileWrappercCs|d��D]}||��|��|��fD]
}|�t�|��qqd��D]}||��|��|��fD]
}|�t�|��q0q"dS)NzbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgradez4Accept Cache-Control Date Pragma Trailer Via Warning)ri�title�upper�lowerr|r�
is_hop_by_hopr�)r�hopr�r!r!r"�testHopByHop�s�����zUtilityTests.testHopByHopr)rY)r(r)r*r�r�r�r�r�r�ignore_warningsr�r�r�r�r�rrrrrr!r'r!r!r!r"r�1s$




	r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�HeaderTestscCs�dg}|�tt��d�|�ttg��d�|�tt|dd���d�|�t|dd����dg�|�t|dd����dg�|�t|dd����|�|�t|���|�t�}|d=d|d<|j|j|j	|j
fD]}|�|d��|�|d��|�|d	��|�|d��qn|�|dd�d
|d<|�|d	d
�|�|�	d�d
g�|�|�dd�d
�|�|�dd�d�|�|�
dd�d
�|�|�
dd�d�|�|dd
�|�|dd�dS)
N)r�r�rrYr�r�r��bar�Foo�FOO�baz�whee�zoo)rjr�r
�keys�values�items�assertIsNot�__contains__�get�get_all�__getitem__r|r��
setdefault)r�test�h�mr!r!r"�testMappingInterface�s4z HeaderTests.testMappingInterfacecCs|�ttd�dS)Nr�)�assertRaises�	TypeErrorr
r1r!r!r"�testRequireList�szHeaderTests.testRequireListcCs�t�}|�t|�d�|jdddd�|�|dd�|�t|�d�|jdddd	�|�|�d�dd
g�|�t|�d�dS)Nz
r�r*�spam)r-zbar; baz="spam"zfoo: bar; baz="spam"

r+)�cheesezbar; cheesez*foo: bar; baz="spam"
Foo: bar; cheese

)r
rj�str�
add_headerr6�rr:r!r!r"�
testExtrass�
�zHeaderTests.testExtrasc	Cst�D]z}|�|��kt�}|�t|jd|��d�|jt|jd|��ddd�|dkrFd|��|d<|�dd|���|�dd|���n(|�t|jdd|���|jt|jdd|��dd�|jt|jddd|��d�Wd�n1sxwYqdS)Nr��val�param)rG�	)rr�r
r=�
ValueError�__setitem__rCr8)r�c0�headersr!r!r"�testRaisesControlCharacterss 
����z'HeaderTests.testRaisesControlCharactersN)r(r)r*r<r?rErMr!r!r!r"r)�s
 r)c@s&eZdZdZeej���Zdd�Z	dS)�ErrorHandlerz/Simple handler subclass for testing BaseHandlerc	Ks*t|�tj|t�t�t�|ddd�dS)NT)�multithread�multiprocess)r	rrrr)rr�r!r!r"r*s

�zErrorHandler.__init__N)
r(r)r*r+�dict�osr>r2�
os_environrr!r!r!r"rN"srNc@seZdZdZdd�ZdS)�TestHandlerzASimple handler subclass for testing BaseHandler, w/error passthrucCs�rr!r1r!r!r"�handle_error4szTestHandler.handle_errorN)r(r)r*r+rUr!r!r!r"rT1srTc@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�HandlerTestsi�cCs�dddddd�}t�td|��tdd	d
�}|��Wd�n1s$wYdD]}|�t|d|�|jd
|�q+i}t|�|��D]\}}||vrT|||<qH|�	dd	dd|�
�|��dddddtj
d��|�|j|�dS)Nz/my/homez/my/pathzfr_FR.UTF-8�test_script_name�test_server_name)�HOME�PATH�LANGr�r�rS�Yz/override/home)�XrY)rhrOrP�run_once�file_wrapper�wsgi_zwsgi.rJrLrFr�T)r]rYr�r�r�rrrrrrzwsgi.file_wrapper)r�	swap_attrrTr%rj�getattrr>r	r2�update�	get_stdin�
get_stderrrr��assertDictEqual)rrS�handler�attr�expectedr�r�r!r!r"�testEnviron<sF�
����zHandlerTests.testEnvironcCs2tdddi�}|��dD]	}|�||j�q
dS)N)rr�r)rr%�assertInr>)rr:r�r!r!r"�testCGIEnvironrs
�zHandlerTests.testCGIEnvironcCsHtdd�}|��|�|jdd�t�}|��|�|jdd�dS)Nr
rrr	r�)rTr%rjr>rDr!r!r"�
testSchemexszHandlerTests.testSchemecCs6t�}dD]}|�tt||��q|�t|jd�dS)N)�_flushrdre�add_cgi_varsr9)rr=�NotImplementedErrorrb�_write)rr:�namer!r!r"�testAbstractMethods~sz HandlerTests.testAbstractMethodscCs�dd�}dd�}dd�}dd�}t�}|�|�|�|j��d	�d
��t�}|�|�|�|j��d�d
��t�}|�|�|�|j��d�t�}|�|�|�|j��d
�dS)NcSs|dg�|d�d�gS�Nr7rrFr�r�r!r!r"�trivial_app1�s
z4HandlerTests.testContentLength.<locals>.trivial_app1cSs|dg�|d�d��gSrtr�r�r!r!r"�trivial_app2�sz4HandlerTests.testContentLength.<locals>.trivial_app2cSs|dg�d�d�gS)Nr7uтестzutf-8r�r�r!r!r"�trivial_app3�r�z4HandlerTests.testContentLength.<locals>.trivial_app3cSs|ddg�gS)Nr7)zContent-Length�12345r!r�r!r!r"�trivial_app4�sz4HandlerTests.testContentLength.<locals>.trivial_app4z)Status: 200 OK
Content-Length: 4

httprFzStatus: 200 OK

https-Status: 200 OK
Content-Length: 8

тестs)Status: 200 OK
Content-Length: 12345

)rT�runrj�stdoutrPrH)rrurvrwryr:r!r!r"�testContentLength�s4
�
�
�
�zHandlerTests.testContentLengthcCs�dd�}dd�}t�}|�|�|�|j��d�d��|�|j��d�t�}|�|�|�|j��d|jt|j	�f�d�|j	�|�
d	|j���dS)
NcS�|dg�gS�Nr7r!r�r!r!r"�
non_error_app��
z8HandlerTests.testBasicErrorOutput.<locals>.non_error_appcSstd��)N� This should be caught by handler�rZr�r!r!r"�	error_app�sz4HandlerTests.testBasicErrorOutput.<locals>.error_app�%Status: 200 OK
Content-Length: 0

rFrJz<Status: %s
Content-Type: text/plain
Content-Length: %d

rZ)rNrzrjr{rPrHrN�error_statusr��
error_bodyrk)rrr�r:r!r!r"�testBasicErrorOutput�s(
�
���z!HandlerTests.testBasicErrorOutputcsRd��fdd�}t�}|�|�|�|j��d�d���|�d|j���dS)N�Some output has been sentcs|dg���td��)Nr7r�r�r���MSGr!r"r��sz4HandlerTests.testErrorAfterOutput.<locals>.error_appzStatus: 200 OK

rFrZ)rNrzrjr{rPrHrkrN�rr�r:r!r�r"�testErrorAfterOutput�s
��z!HandlerTests.testErrorAfterOutputc	
Csdd�}d}d�d�}dD]q}|rd|pd}d	D]d}d
D]_}t|d�}d|_||_||_|�|�|�||j���t|d�}d
|_||_||_|�|�|dkr\|�|j��d�q|�	t
�|||f�d�|j���|||f�d�|j��f�qqq
dS)NcSr}r~r!r�r!r!r"r�r�z5HandlerTests.testHeaderFormats.<locals>.non_error_appzfHTTP/%s 200 OK\r\nDate: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n%sContent-Length: 0\r\n\r\nr�rF)z
FooBar/1.0NzServer: %s
rJ)z1.0z1.1)�HTTP/0.9r�zHTTP/1.1)r�FTr�r�)rHrT�
origin_server�http_version�server_softwarerzrjr{rPr|�rera)	rr�stdpat�shortpat�ssw�swrh�protor:r!r!r"�testHeaderFormats�sD��



������zHandlerTests.testHeaderFormatscCs.dd�}t�}|�|�|�d|j���dS)NcSs|ddg�dgS)Nr7r�r�r!r�r!r!r"rQ
s�z'HandlerTests.testBytesData.<locals>.appsRStatus: 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4

data)rTrzrjr{rP)rrQr:r!r!r"�
testBytesDatas
�zHandlerTests.testBytesDatacs>ddi�d���fdd�}t�}|�|�|��dd�dS)N�close_calledFr�cs(|dg���G�fdd�dt�}|�S)Nr7cs eZdZdd�Z�fdd�ZdS)zHHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterablecss�	dVtd��)NTsblahr�r�r1r!r!r"�__iter__"s�zQHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.__iter__csd�d<dS)NTr�r!r1��side_effectsr!r"r�&r�zNHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.closeN)r(r)r*r�r�r!r�r!r"�CrashyIterable!sr�)�object)r�r�r��r�r�r!r"r�sz0HandlerTests.testCloseOnError.<locals>.error_appT)rNrzrjr�r!r�r"�testCloseOnErrors
zHandlerTests.testCloseOnErrorcs~t��G�fdd�d�}ddi}tt�|�tj|�}d}|�t|��
|�t�Wd�n1s2wY|�	d��dS)Ncs eZdZ�fdd�Zdd�ZdS)z4HandlerTests.testPartialWrite.<locals>.PartialWritercs|dd�}��|�t|�S)N�)�extendr�)r�b�partial��writtenr!r"�write2s
z:HandlerTests.testPartialWrite.<locals>.PartialWriter.writecSr3rr!r1r!r!r"�flush7r5z:HandlerTests.testPartialWrite.<locals>.PartialWriter.flushN)r(r)r*r�r�r!r�r!r"�
PartialWriter1sr�r�r�zshould not do partial writesssHTTP/1.0 200 OK
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
Content-Length: 13

Hello, world!)
�	bytearrayr
rrMrNr�r�rzr@rj)rr�r>r:�msgr!r�r"�testPartialWrite.s	��zHandlerTests.testPartialWritec	s�ddi}tttfD]9�|j�d��)G�fdd�d�}t�}tt�|�||�}|�t�|�	|�
��Wd�n1s=wYq	dS)Nr�r���	exceptionc�eZdZ�fdd�ZdS)zEHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriterc���rr!�rr�r�r!r"r�Pr5zKHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriter.writeN�r(r)r*r�r!r�r!r"�AbortingWriterO�r�)�ConnectionAbortedError�BrokenPipeError�ConnectionResetErrorr�rr
rrzr@r�rP)rr>r�rNr:r!r�r"� testClientConnectionTerminationsGs�
���z-HandlerTests.testClientConnectionTerminationscs�Gdd�dt��G�fdd�d�}t�}ddi}tt�|�||�}|�t�|�d|���|�|j	�|�|j
�|�|j�|�|j�dS)Nc@r�)zKHandlerTests.testDontResetInternalStateOnException.<locals>.CustomExceptionNr�r!r!r!r"�CustomExceptionZr�r�cr�)zJHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWritercr�rr!r��r�r!r"r�br5zPHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWriter.writeNr�r!r�r!r"r�ar�r�r�r�)
rIrr
rrzr@rkrP�assertIsNotNone�resultrLr�r>)rr�rNr>r:r!r�r"�%testDontResetInternalStateOnExceptionYs
z2HandlerTests.testDontResetInternalStateOnExceptionN)r(r)r*�maxDiffrjrlrmrsr|r�r�r�r�r�r�r�r�r!r!r!r"rV8s62
+rV�__main__)8�unittestrr9r�test.supportrrr�test.test_httpserversrr�wsgiref.utilr	�wsgiref.headersr
�wsgiref.handlersrrr
�wsgirefr�wsgiref.validater�wsgiref.simple_serverrrr�http.clientr�iorrr�socketserverr�platformrrRr�r�rMr�rr,r@rIrXrerfr�r)rNrTrVr(�mainr!r!r!r"�<module>sT
%9+G=�

Youez - 2016 - github.com/yon3zu
LinuXploit