Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_wsgiref.cpython-312.pyc

�

'ΜgKu���ddlmZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZdd	lmZdd
lmZddlmZmZddlmZdd
lmZddlmZmZmZddlm Z ddl!m"Z"ddl#Z#ddl$Z$ddl%Z%ddl&Z&ddl'Z'ddlZGd�de�Z(Gd�de�Z)d�Z*d�Z+e*dfd�Z,d�Z-Gd�de�Z.Gd�de�Z/Gd�d e�Z0Gd!�d"e�Z1Gd#�d$e1�Z2Gd%�d&e�Z3e4d'k(rejj�yy)(�)�mock)�support)�
socket_helper)�NoLogRequestHandler)�TestCase)�setup_testing_defaults)�Headers)�BaseHandler�BaseCGIHandler�
SimpleHandler)�util)�	validator)�
WSGIServer�WSGIRequestHandler)�make_server)�HTTPConnection)�StringIO�BytesIO�BufferedReader)�
BaseServer)�python_implementationNc��eZdZdZd�Zd�Zy)�
MockServerzNon-socket HTTP serverc�R�tj|||�|j�y�N)r�__init__�server_bind)�self�server_address�RequestHandlerClasss   �./usr/local/lib/python3.12/test/test_wsgiref.pyrzMockServer.__init__s!�����D�.�2E�F�����c�^�|j\}}||_||_|j�yr)r�server_name�server_port�
setup_environ)r�host�ports   r!rzMockServer.server_bind!s-���(�(�
��d����������r"N)�__name__�
__module__�__qualname__�__doc__rr�r"r!rrs�� ��r"rc��eZdZdZd�Zd�Zy)�MockHandlerzNon-socket HTTP handlerc�X�|j|_|j\|_|_yr)�request�
connection�rfile�wfile�rs r!�setupzMockHandler.setup*s���,�,���!%�����
�D�Jr"c��yrr-r5s r!�finishzMockHandler.finish.s��r"N)r)r*r+r,r6r8r-r"r!r/r/(s��!�1�
r"r/c��|dddg�dgS)N�200 OK��Content-Typez
text/plain��DatezMon, 05 Jun 2006 18:49:54 GMT�
Hello, world!r-��environ�start_responses  r!�	hello_apprC2s"���8�%�0���
��r"c�r�|dddg�dj|d|d|dg�jd�gS)	Nr:r;r=�;�HTTP_X_TEST_HEADER�QUERY_STRING�	PATH_INFO�
iso-8859-1)�join�encoder@s  r!�
header_apprL:sX���8�&�1���
�H�H��$�%�w�~�'>�����
��v�l���r"sGET / HTTP/1.0

c�V�tdd|tt�}tt	|��}t	�}t
j}t�x}t
_	|j||fd�|t
_|j�|j�fS#|t
_wxYw)N��P)�	127.0.0.1i�")
rrr/rr�sys�stderrr�finish_request�getvalue)�app�data�server�inp�out�olderr�errs       r!�	run_amockr\Es���
��R��j�+�
>�F�
����
'�C�
�)�C�
�Z�Z�F��z�!�C�#�*�����s�C�j�*<�=���
��<�<�>�3�<�<�>�)�)����
�s�B�
B(c��|�}t|�|urt�|D]}t|�|k(r�t�	t|�td|��#t$rYywxYw)z�Utility to compare a generic iterator with an iterable

    This tests the iterator using iter()/next().
    'make_it' must be a function returning a fresh
    iterator to be tested (since this may test the iterator twice).zToo many items from .__next__()N)�iter�AssertionError�next�
StopIteration)�make_it�match�it�items    r!�compare_generic_iterrfTsi��
��B���8�r�>������B�x�4�� � ��D��R���>��C�C���
��
�s�A�	A�Ac�P�eZdZd
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)�IntegrationTestsc���t�dztjj�dz}|j	|d|zdz|xrdxsdzdzjd��y)	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
rNz
Hello, world!rI)rrQ�version�split�assertEqualrK)rrY�
has_length�pyvers    r!�check_hellozIntegrationTests.check_helloks{��&�(�3�.����!�!�#�A�&�'������&�(-�.�06�6��
5�5�
;��	=�

��$�V�L�1�	
r"c�@�t�\}}|j|�yr)r\rp�rrYr[s   r!�test_plain_helloz!IntegrationTests.test_plain_helloxs���;���S�����r"c�t�d}tt|�\}}|j|j�dd�y)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/)r\rLrm�
splitlines)rr1rYr[s    r!�test_environzIntegrationTests.test_environ|s>��
%�	��Z��1���S�����N�N��R� �:�	
r"c�z�tdddzzdz��\}}|j|j�dd�y)NsGET �xis HTTP/1.0

�rVrs!HTTP/1.0 414 Request-URI Too Long)r\rmrvrrs   r!�test_request_lengthz$IntegrationTests.test_request_length�s>���'�T�E�\�":�=M�"M�N���S�������)�!�,�=�	?r"c�`�ttt��\}}|j|d��y)NF)rn)r\rrCrprrs   r!�test_validated_helloz%IntegrationTests.test_validated_hello�s(���Y�y�1�2���S�������/r"c��d�}tt|��\}}|j|jd��|j	|j�dd�y)Nc��|dd�dgS)Nr:r;z
Hello, world!r-r@s  r!�bad_appz>IntegrationTests.test_simple_validation_error.<locals>.bad_app�s���8�%B�C�#�$�$r"�;A server error occurred.  Please contact the administrator.���z^AssertionError: Headers (('Content-Type', 'text/plain')) must be of type list: <class 'tuple'>�r\r�
assertTrue�endswithrmrv�rr�rYr[s    r!�test_simple_validation_errorz-IntegrationTests.test_simple_validation_error�sZ��	%��Y�w�/�0���S�������J�
�	�	
����N�N��R� �
0�	
r"c�"�d�}gd�}|D]w\}}|j|��5t||��\}}|j|jd��|j	|j�d|�ddd��yy#1swY��xYw)Nc����fd�}|S)Nc���|�dg�dgS)N�r<ztext/plain; charset=utf-8r?r-)rArB�statuss  �r!r�zWIntegrationTests.test_status_validation_errors.<locals>.create_bad_app.<locals>.bad_app�s����v�(U�'V�W�(�)�)r"r-)r�r�s` r!�create_bad_appzFIntegrationTests.test_status_validation_errors.<locals>.create_bad_app�s���
*��Nr"))�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 code)r�r�r�)�subTestr\r�r�rmrv)rr��testsr��exc_messagerYr[s       r!�test_status_validation_errorsz.IntegrationTests.test_status_validation_errors�s���	�
��$)��F�K����V��,�$�^�F�%;�<���S�������R�!��� � ����!1�"�!5�{�C�-�,�$)�,�,�s�AB�B	c��d�}tt|��\}}|j|jd��|j	|j�dd�y)Nc�B�|dj�|ddg�dgS)N�
wsgi.inputr:r��data)�read��e�ss  r!r�z1IntegrationTests.test_wsgi_input.<locals>.bad_app�s(��
�l�O� � �"�
�h�F�G�H��9�r"r�r�r_r�r�s    r!�test_wsgi_inputz IntegrationTests.test_wsgi_input�sX��	��Y�w�/�0���S�������J�
�	�	
����N�N��R� �"2�	
r"c�J�d�}tt|��\}}|j|jd��tj
j
�djd�}t�jd�}|dz|z}|jd|zdz|�y)Nc��|dddg�dgS)Nr:r��r>zWed, 24 Dec 2008 13:29:32 GMTr�r-r�s  r!rUz3IntegrationTests.test_bytes_validation.<locals>.app�s!��
�h�=�9��
��9�r"z"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)
r\rr�r�rQrkrlrKrrm)rrUrYr[�ver�pyros       r!�test_bytes_validationz&IntegrationTests.test_bytes_validation�s���	��Y�s�^�,���S�������%?�@�A��k�k���!�!�$�+�+�G�4��#�%�,�,�W�5���T�	�C������+�,1�2�5���	r"c��d�}tt|�d��\}}|jdtjddddg|j��y)	Nc�B�|dddg�|djd�gS)Nr:r;r�rH�latin1�rKr�s  r!rUz-IntegrationTests.test_cp1252_url.<locals>.app�s1��
�h�.�9��
��k�N�)�)�(�3�4�4r"sGET /�%80 HTTP/1.0rzsHTTP/1.0 200 OKsContent-Type: text/plains#Date: Wed, 24 Dec 2008 13:29:32 GMTr"s/��)r\rrmr�ANYrv)rrUrYr[s    r!�test_cp1252_urlz IntegrationTests.test_cp1252_url�sV��	5���c�N�!9�;���S����"����+�6���

�
�N�N��		r"c�����	�
��tjtd��	d�}Gd�dtt�}ttjd||���|j�j�tj���fd�}tjtj|�}|jtjtj|�d�
tj�����	�
�fd�}tj|�	�}|j��j!�|j#�|j%�
tj&d
z
�y)N�pthread_killc�<�|dg�dtjzgS)Nr:�)r�
SOCK_MAX_SIZEr@s  r!rUz4IntegrationTests.test_interrupted_write.<locals>.app�s ���8�R�(��G�1�1�1�2�2r"c��eZdZy)�<IntegrationTests.test_interrupted_write.<locals>.WsgiHandlerN�r)r*r+r-r"r!�WsgiHandlerr�����r"r�r)�
handler_classc�&���j�yr)�set)�signum�frame�interrupteds  �r!�signal_handlerz?IntegrationTests.test_interrupted_write.<locals>.signal_handlers
����O�O�r"c�v��t�j�}|jdd�|j�5}|j	d�	��t
j��jtd���rn�4t|j	���ddd�|j�y#1swY�xYw)N�GETrj�d�)�timeout)rrr1�getresponser��signal�SIGUSR1�wait�float�len�close)�http�responser��main_threadr��receivedrWs  �����r!�
run_clientz;IntegrationTests.test_interrupted_write.<locals>.run_clients����!�6�#8�#8�9�D��L�L���$��!�!�#�x��
�
�c�"�� ��f�n�n�=�"�'�'��a��'�9���
�x�}�}��/��$�
�J�J�L�$�#�s�A B/�/B8)�targetr�)r�
get_attributer�rrrr�HOST�
addCleanup�server_close�	threading�Eventr��	get_ident�Thread�start�handle_requestrJrmr�)rrUr�r��originalr��
backgroundr�r�r�r�rWs       @@@@@r!�test_interrupted_writez'IntegrationTests.test_interrupted_write�s����,�,�V�^�D��	3�	�-�/A�	��]�/�/��C�{�S������+�+�,��o�o�'��	��=�=�����@������
�
�v�~�~�x�@����)�)�+��	�	�$�%�%�Z�8�
�����������������7�#8�#8�3�#>�?r"N)T)r)r*r+rprsrwr{r}r�r�r�r�r�r�r-r"r!rhrhis;��
��
�?�
0�

�D�*
��*�./@r"rhc�j�eZdZd�Zdd�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zy)�UtilityTestsc���||d�}tj|�|jtj|�|�|j|d|�|j|d|�|S)N��SCRIPT_NAMErHrHr�)r
rrm�shift_path_info)r�sn_in�pi_in�part�sn_out�pi_out�envs       r!�
checkShiftzUtilityTests.checkShift#sd��"�u�5���#�#�C�(�����-�-�c�2�4�8�����[�)�&�1�����]�+�F�3��
r"Nc�`�i}tj|�t|t�r|j	||t�n?t|t
�r|j	||t
�n|j
|||�||i}tj|�|j|||�yr)r
r�
isinstancer�assertIsInstancerrm�assertIs)r�key�value�altr�s     r!�checkDefaultzUtilityTests.checkDefault+s������#�#�C�(��e�X�&��!�!�#�c�(�H�5�
��g�
&��!�!�#�c�(�7�3����S��X�u�-��3�i���#�#�C�(��
�
�c�#�h��$r"c�X�tj|�|j|||�yr)r
rrm)rr�r��kws    r!�checkCrossDefaultzUtilityTests.checkCrossDefault;s$���#�#�B�'�����C���'r"c�x�tj|�|jtj|�|�yr)r
rrm�application_uri)r�urir�s   r!�checkAppURIzUtilityTests.checkAppURI?s+���#�#�B�'�����-�-�b�1�#�6r"c�z�tj|�|jtj||�|�yr)r
rrm�request_uri)rr��queryr�s    r!�checkReqURIzUtilityTests.checkReqURICs-���#�#�B�'�����)�)�"�U�3�C�8r"c�B�||fd�}t||�|�}|j|jj�|D]}�|j|jj�|j	�|j|jj�y)Nc�@�tjt|�|�Sr)r
�FileWrapperr)�text�sizes  r!rbz%UtilityTests.checkFW.<locals>.make_itIs���#�#�H�T�N�4�8�8r")rf�assertFalse�filelike�closedr�r�)rr�r�rcrbrdres       r!�checkFWzUtilityTests.checkFWGs}���4�	9�	�W�U�+�
�Y��������+�+�,��D���	
������+�+�,�
���
�������*�*�+r"c���|jddddd�|jddddd�|jddddd�|jddddd�|jdd	ddd�y)
NrNrjz/x�x�/az/x/yz/a/x�/yz/x/�r�r5s r!�testSimpleShiftszUtilityTests.testSimpleShiftsYsf������3��C��,�����4��d�B�/�����B��c�2�.�����V�S�&�$�7�����U�S�&�#�6r"c���|jddddd�|jddddd�|jdddd	d�|jdd
dd	d�|jdddd	d�|jdd
dd	d�|jddddd�|jddddd�|jddddd�|jddddd�|jddddd�y)Nz/a/bz/../yz..rrrNz//y�yz/a/b/yz//y/rjz/./yz/./y/z///./..//y/.//z/y/z///z/a/b/z/.//z/x//rz/a/b/xz/.rr5s r!�testNormalizedShiftsz!UtilityTests.testNormalizedShifts`s���������t�T�:�����G�T�2�t�4������s�H�b�9�������X�s�;�������X�r�:�������h��<����� 0�$��e�D������r�7�B�7�������G�R�8�������X�s�;������d�F�B�7r"c��ddddddddd	d
ddt�fd
t�fdfD]\}}|j||��y)N)�SERVER_NAMErP)�SERVER_PORT�80)�SERVER_PROTOCOL�HTTP/1.0)�	HTTP_HOSTrP)�REQUEST_METHODr�)r�rN)rHrj)�wsgi.version�r�r)�
wsgi.run_oncer)�wsgi.multithreadr)�wsgi.multiprocessrr��wsgi.errors)�wsgi.url_schemer�)rrr�)rr�r�s   r!�testDefaultszUtilityTests.testDefaultsms\��'�!�*�%�$���#� �#�$�
�7�9�%�
�H�J�'�&�
�J�C�� 
���c�%�(�!
r"c��|jddd��|jddd��|jddd��|jddd	��|jdd
d��|jdd
d��|jddd��y)Nrzfoo.bar�rr�https�on��HTTPS�1�yesr��foorr�443)r�r5s r!�testCrossDefaultszUtilityTests.testCrossDefaults�s������{�9���K����0��t��D����0��s��C����0��u��E����0��e��D����}�T���>����}�U���>r"c��|jtji�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�y)Nr�r"r%r rr$r#)rmr
�guess_schemer5s r!�testGuessSchemezUtilityTests.testGuessScheme�s�������*�*�2�.��7�����*�*�G�E�?�;�V�D�����*�*�G�D�>�:�G�D�����*�*�G�E�?�;�W�E�����*�*�G�C�=�9�7�Cr"c�6�|jd�|jdd��|jdd��|jddd	�
�|jdd�
�|jddd��|jdd��|jddd��y)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)rrzhttp://spam.example.com/zspam.example.comrrP)rrzhttps://127.0.0.1/r r!zhttp://127.0.0.1:8000/�8000)rr)r�r5s r!�testAppURIszUtilityTests.testAppURIs�s������,�-����0�g��F����2�
��K����8�-�6�	�	C����3�*�	�	,����,�!�/A�	�	C����-�T��:����1�v��	�	r"c��|jd�|jdd��|jdd��|jddd�	�|jd
dd�	�|jddd�	�|jd
dd�	�|jdddd��|jdddd��|jddddd��y)Nr,r-r.r/r0r1zhttp://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�rHrGz'http://127.0.0.1/spammity/spam?s%E4y=nizs%E4y=nir)r�r5s r!�testReqURIszUtilityTests.testReqURIs�s�����,�-����0�g��F����2�
��K����9�#�w�	�	8����;�#�z�	�	;����=�#�{�	�	<����J�#�/G�	�	I����@�#�w�H�	�	N����B�#�w�J�	�	P����9�1�#�w�H�	�	Nr"c�.�|jddddg�y)Nږxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz�x�xxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz�xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz)rr5s r!�testFileWrapperzUtilityTests.testFileWrapper�s�����X�s�X�h�$7�8r"c��dj�D][}||j�|j�|j�fD]&}|j	tj|���(�]dj�D][}||j�|j�|j�fD]&}|jtj|���(�]y)NzbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgradez4Accept Cache-Control Date Pragma Trailer Via Warning)rl�title�upper�lowerr�r
�
is_hop_by_hopr)r�hopr�s   r!�testHopByHopzUtilityTests.testHopByHop�s���
4�
�%�'��C��C�I�I�K�����c�i�i�k�A������ 2� 2�3� 7�8�B�	�
C�
�%�'��C��C�I�I�K�����c�i�i�k�A��� � ��!3�!3�C�!8�9�B�r"r)r�)r)r*r+r�r�r�r�r�rr	rrr'r*r4r6r<rCr-r"r!r�r�!sO���%� (�7�9�,�$7�8�)�&?�D��N�&9�
:r"r�c��eZdZd�Zd�Zd�Zy)�HeaderTestsc	��dg}|jtt��d�|jttg��d�|jtt|dd��d�|jt|dd�j�dg�|jt|dd�j	�dg�|jt|dd�j�|�|j
t|�j�|�t�}|d=d|d<|j|j|j|jfD]^}|j|d��|j|d��|j|d	��|j|d���`|j|dd�d
|d<|j|d	d
�|j|jd�d
g�|j|jdd�d
�|j|jdd�d�|j|jdd�d
�|j|jdd�d�|j|dd
�|j|dd�y)
N)rrrr�rrr%�bar�Foo�FOO�baz�whee�zoo)rmr�r	�keys�values�items�assertIsNot�__contains__�get�get_all�__getitem__r�r�
setdefault)r�test�h�ms    r!�testMappingInterfacez HeaderTests.testMappingInterface�s<���{������W�Y���+�����W�R�[�)�!�,�����W�T�!�W�-�.�q�1������a��)�.�.�0�3�%�8������a��)�0�0�2�S�E�:������a��)�/�/�1�4�8�������,�,�.��5��I��
�e�H���%���������	�	�1�=�=�@�A��O�O�A�e�H�%��O�O�A�e�H�%��O�O�A�e�H�%����Q�u�X�&�	A�	
����5��%�(���%������5��%�(�������5�)�5�'�2�������u�V�,�e�4�������u�V�,�f�5�������e�F�3�U�;�������e�F�3�V�<�����5��%�(�����5��&�)r"c�:�|jttd�y)Nr%)�assertRaises�	TypeErrorr	r5s r!�testRequireListzHeaderTests.testRequireList�s�����)�W�e�4r"c�z�t�}|jt|�d�|jddd��|j|dd�|jt|�d�|jddd�	�|j|j	d�dd
g�|jt|�d�y)Nz
r%rG�spam)rJzbar; baz="spam"zfoo: bar; baz="spam"

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

)r	rm�str�
add_headerrS�rrWs  r!�
testExtraszHeaderTests.testExtras�s����I������Q���'�	���U�5�V��,�����5��#4�5�����Q�� >�?�	���U�5���-�������5�)�
�
�.�	0�	
����Q��
�	
r"N)r)r*r+rYr]rdr-r"r!rErE�s��*�@5�
r"rEc�V�eZdZdZeejj��Zd�Z	y)�ErrorHandlerz/Simple handler subclass for testing BaseHandlerc	��t|�tj|t�t�t	�|dd��y)NT)�multithread�multiprocess)rrrrr)rr�s  r!rzErrorHandler.__init__s.���r�"�����'�)�W�Y��
�B��4�	
r"N)
r)r*r+r,�dict�osrArO�
os_environrr-r"r!rfrf�s#��9�
�b�j�j�&�&�(�)�J�
r"rfc��eZdZdZd�Zy)�TestHandlerzASimple handler subclass for testing BaseHandler, w/error passthruc���rr-r5s r!�handle_errorzTestHandler.handle_errors��
r"N)r)r*r+r,rpr-r"r!rnrn	s
��K�r"rnc�^�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�HandlerTestsi�c�@�dddddd�}tjtd|�5tdd	�
�}|j�ddd�dD]1}|j	td|z�|jd
|z��3i}t|�|j�D]\}}||vs�|||<�|jdd	ddj�|j�dddddtjd��|j|j|�y#1swY��xYw)Nz/my/homez/my/pathzfr_FR.UTF-8�test_script_name�test_server_name)�HOME�PATH�LANGr�rrl�Yz/override/home)�Xrv)rkrhri�run_once�file_wrapper�wsgi_zwsgi.rNrPrFr�T)rzrvr�rr�rrrrrrzwsgi.file_wrapper)r�	swap_attrrnr&rm�getattrrArrO�update�	get_stdin�
get_stderrr
r��assertDictEqual)rrl�handler�attr�expectedr�r�s       r!�testEnvironzHandlerTests.testEnvirons3����!�.�-�	
�
��
�
�{�L�*�
E�!�C�.>�?�G��!�!�#�F�%�D����W�W�g��n�=�$�_�_�W�t�^�<�
>�%����x�(�%�*�*�,�J�C���(�"� %���
�-�	����$��&�"�+�+�-�"�-�-�/�"�"�%� $�!%�!%�!1�!1�%
�	�(	
���W�_�_�h�7�QF�
E�s�D�Dc��tdddi�}|j�dD]}|j||j�� y)N)rr�r)rr&�assertInrA)rrWr�s   r!�testCGIEnvironzHandlerTests.testCGIEnvironJs9���4��T�"�-��	����A�C��M�M�#�q�y�y�)�Br"c���td��}|j�|j|jdd�t�}|j�|j|jdd�y)Nr r!rrr�)rnr&rmrArcs  r!�
testSchemezHandlerTests.testSchemePsY��
�D�
!��1�?�?�#4�������#4�5�g�>�
�-�����*�������#4�5�f�=r"c��t�}dD]"}|jtt||���$|jt|jd�y)N)�_flushr�r��add_cgi_varsrV)r
r[�NotImplementedErrorr�_write)rrW�names   r!�testAbstractMethodsz HandlerTests.testAbstractMethodsVsG���M��
�D�
���1�7�1�T�?�C�
�	
���-�q�x�x��@r"c��d�}d�}d�}d�}t�}|j|�|j|jj	�djd��t�}|j|�|j|jj	�djd��t�}|j|�|j|jj	�d�t�}|j|�|j|jj	�d	�y)
Nc�>�|dg�|djd�gS�Nr:rrIr�r�s  r!�trivial_app1z4HandlerTests.testContentLength.<locals>.trivial_app1as%��
�h�r�N��'�(�/�/��=�>�>r"c�H�|dg�|djd��gSr�r�r�s  r!�trivial_app2z4HandlerTests.testContentLength.<locals>.trivial_app2es(���A�h�r�N�1�.�/�6�6�|�D�E��Ir"c�8�|dg�djd�gS)Nr:uтестzutf-8r�r�s  r!�trivial_app3z4HandlerTests.testContentLength.<locals>.trivial_app3is��
�h�r�N�.�5�5�g�>�?�?r"c��|ddg�gS)Nr:)zContent-Length�12345r-r�s  r!�trivial_app4z4HandlerTests.testContentLength.<locals>.trivial_app4ms��
�h�3�4�5��Ir"z)Status: 200 OK
Content-Length: 4

httprIzStatus: 200 OK

https-Status: 200 OK
Content-Length: 8

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

)rn�runrm�stdoutrTrK)rr�r�r�r�rWs      r!�testContentLengthzHandlerTests.testContentLength^s	��	?�	�	@�	�

�M��	���l��������*�*�,���F�<�(�		*�
�M��	���l��������*�*�,���F�<�(�	*�

�M��	���l��������*�*�,�
0�	1�
�M��	���l��������*�*�,�
�	r"c�f�d�}d�}t�}|j|�|j|jj	�djd��|j|jj	�d�t�}|j|�|j|jj	�d|jt|j�fzjd�|jz�|jd|jj	��y)Nc��|dg�gS�Nr:r-r�s  r!�
non_error_appz8HandlerTests.testBasicErrorOutput.<locals>.non_error_app����
�h�r�N��Ir"c��td��)N� This should be caught by handler�r_r�s  r!�	error_appz4HandlerTests.testBasicErrorOutput.<locals>.error_app�s�� �!C�D�Dr"�%Status: 200 OK
Content-Length: 0

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

r_)rfr�rmr�rTrKrR�error_statusr��
error_bodyr�)rr�r�rWs    r!�testBasicErrorOutputz!HandlerTests.testBasicErrorOutput�s���	�	E�
�N��	���m��������*�*�,���F�<�(�	*�	
������*�*�,�R�0��N��	���i��������*�*�,���n�n�S����%6�7�8�:@���9M��l�l�	
�	�	
�
�
�&����(9�(9�(;�<r"c���d��fd�}t�}|j|�|j|jj	�djd��z�|j
d|jj	��y)N�Some output has been sentc�8��|dg���td��)Nr:r�r�)r�r��MSGs  �r!r�z4HandlerTests.testErrorAfterOutput.<locals>.error_app�s����A�h�r�N�3�� �!C�D�Dr"zStatus: 200 OK

rIr_)rfr�rmr�rTrKr�rR)rr�rWr�s   @r!�testErrorAfterOutputz!HandlerTests.testErrorAfterOutput�st���*��	E�
�N��	���i��������*�*�,���6�,�'��,�	.�	
�
�
�&����(9�(9�(;�<r"c
��d�}d}djd�}dD�]`}|xrd|zxsd}dD�]J}d	D�]A}t|�
�}d|_||_||_|j|�|j
||jj��t|�
�}d|_||_||_|j|�|d
k(r+|j
|jj�d���|jtj|||fzjd�|jj��|||fzjd�|jj�f���D��M��cy)Nc��|dg�gSr�r-r�s  r!r�z5HandlerTests.testHeaderFormats.<locals>.non_error_app�r�r"zfHTTP/%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�rI)z
FooBar/1.0NzServer: %s
rN)z1.0z1.1)�HTTP/0.9rzHTTP/1.1)rFTr�r")rKrn�
origin_server�http_version�server_softwarer�rmr�rTr��rerc)	rr��stdpat�shortpat�ssw�swrk�protorWs	         r!�testHeaderFormatszHandlerTests.testHeaderFormats�s`��	�

3�	�
@�
�&��
�	�&�C��/�)�C�/�5�2�B�'��?�E�#�E�:�A�&+�A�O�%,�A�N�(+�A�%��E�E�-�(��$�$�X�a�h�h�.?�.?�.A�B�#�E�:�A�&*�A�O�%,�A�N�(+�A�%��E�E�-�(��j�(��(�(����):�):�)<�S�A�����H�H�f�g�b�\�&9�%A�%A�,�%O� !��� 1� 1� 3�5�$�g�b�\�1�9�9�,�G� !��� 1� 1� 3�5��#@�(�&r"c��d�}t�}|j|�|jd|jj	��y)Nc��|ddg�dgS)Nr:r�r�r-r�s  r!rUz'HandlerTests.testBytesData.<locals>.app�s��
�h�=��
��9�r"sRStatus: 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4

data)rnr�rmr�rT)rrUrWs   r!�
testBytesDatazHandlerTests.testBytesData�s@��	�
�M��	���c�
�����

�H�H����	!r"c����ddi�d���fd�}t�}|j|�|j�dd�y)N�close_calledFr�c�R��|dg���G�fd�dt�}|�S)Nr:c���eZdZd�Z�fd�Zy)�HHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterablec3�*K�	d��td���w)Nsblahr�r�r5s r!�__iter__zQHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.__iter__�s�����%�
�,�-O�P�P�s�c���d�d<y)NTr�r-)r�side_effectss �r!r�zNHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.close�s
���37�L��0r"N)r)r*r+r�r�)r�s�r!�CrashyIterabler��s���Q�8r"r�)�object)r�r�r�r�r�s   ��r!r�z0HandlerTests.testCloseOnError.<locals>.error_app�s*����A�h�r�N�3��
8��
8�"�#�#r"T)rfr�rm)rr�rWr�r�s   @@r!�testCloseOnErrorzHandlerTests.testCloseOnError�sA���&��.��*��		$�
�N��	���i������n�5�t�<r"c�4��t��G�fd�d�}ddi}tt�|�tj|�}d}|jt|�5|jt�ddd�|jd��y#1swY�xYw)Nc���eZdZ�fd�Zd�Zy)�4HandlerTests.testPartialWrite.<locals>.PartialWriterc�F��|dd}�j|�t|�S)N�)�extendr�)r�b�partial�writtens   �r!�writez:HandlerTests.testPartialWrite.<locals>.PartialWriter.write
s$����B�Q�%�����w�'��7�|�#r"c��yrr-r5s r!�flushz:HandlerTests.testPartialWrite.<locals>.PartialWriter.flushs��r"N)r)r*r+r�r�)r�s�r!�
PartialWriterr�	s
���
$�

r"r�rrzshould 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rrQrR�assertWarnsRegex�DeprecationWarningr�rCrm)rr�rArW�msgr�s     @r!�testPartialWritezHandlerTests.testPartialWrites�����+��	�	�%�j�1���'�)�]�_�c�j�j�'�J��,��
�
"�
"�#5�s�
;�
�E�E�)��<�����
�
	�<�
;�s�B�Bc�R��ddi}tttfD]��|j���5G�fd�d�}t	�}tt
�|�||�}|jt�|j|j��ddd���y#1swY��xYw)Nrr��	exceptionc���eZdZ�fd�Zy)�EHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriterc�����rr-)rr�r�s  �r!r�zKHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriter.write(s���'�r"N�r)r*r+r�r�s�r!�AbortingWriterr�'s���(r"r�)�ConnectionAbortedError�BrokenPipeError�ConnectionResetErrorr�rrrr�rCrrT)rrAr�rRrWr�s     @r!� testClientConnectionTerminationsz-HandlerTests.testClientConnectionTerminationss����$�j�1��"�� �
�I�
���	��2�(�(�"���!�'�)�^�-=�v�w�O�����i� �� � ����!2�3�3�2�
�
3�2�s�A&B�B&	c����Gd�dt��G�fd�d�}t�}ddi}tt�|�||�}|j	t
�|j
d|j��|j|j�|j|j�|j|j�|j|j�y)Nc��eZdZy)�KHandlerTests.testDontResetInternalStateOnException.<locals>.CustomExceptionNr�r-r"r!�CustomExceptionr�2r�r"r�c���eZdZ�fd�Zy)�JHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWriterc�����rr-)rr�r�s  �r!r�zPHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWriter.write:s	���%�%r"Nr�)r�s�r!r�r�9s���
&r"r�rr)
�
ValueErrorrrrr�rCr�rT�assertIsNotNone�result�headersr�rA)rr�rRrArWr�s     @r!�%testDontResetInternalStateOnExceptionz2HandlerTests.testDontResetInternalStateOnException1s����	�j�	�	&�	&����$�j�1���'�)�^�%5�v�w�G��	���i���
�
�'����):�;�	
���Q�X�X�&����Q�Y�Y�'����Q�X�X�&����Q�Y�Y�'r"N)r)r*r+�maxDiffr�r�r�r�r�r�r�r�r�r�r�r�r�r-r"r!rrrrsL���G�48�l*�>�A�0�d=�8=�)�V!� =�$�24�$(r"rr�__main__)6�unittestrrVr�test.supportr�test.test_httpserversrr�wsgiref.utilr�wsgiref.headersr	�wsgiref.handlersr
rr�wsgirefr
�wsgiref.validater�wsgiref.simple_serverrrr�http.clientr�iorrr�socketserverr�platformrrkr�r�rQr�rr/rCrLr\rfrhr�rErfrnrrr)�mainr-r"r!�<module>r
s�����&�5��/�#�G�G��&�@�-�&�0�0�#�*�	�	�
�
������
�$�
����"7�*�D�*u@�x�u@�p`:�8�`:�D5
�(�5
�n

�>�

��,��x(�8�x(�v	�z���H�M�M�O�r"

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists