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_urllib2_localnet.cpython-312.pyc

�

'Μg[f��P�ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddl
mZddl
mZ	ddlZej&d��ej(j+e�Zej(j1edd	�Zej(j1edd
�ZGd�dej6j8�ZGd
�dej<�ZGd�d�Z Gd�dej6jB�Z"Gd�dej6jB�Z#Gd�de	jH�Z%ejLdd��Gd�de	jH��Z'd�Z(Gd�de	jH�Z)d�Z*e+dk(re	jX�yy#e$rdZY��bwxYw) �N)�support)�hashlib_helper)�threading_helper)�warnings_helperT)�module�certdatazkeycert.pemzkeycert2.pemc��eZdZdZd�Zd�Zy)�LoopbackHttpServerz^HTTP server w/ a few modifications that make it useful for
    loopback testing purposes.
    c��tjjj|||�|jjd�y)Ng�������?)�http�server�
HTTPServer�__init__�socket�
settimeout)�self�server_address�RequestHandlerClasss   �7/usr/local/lib/python3.12/test/test_urllib2_localnet.pyrzLoopbackHttpServer.__init__%s6�������'�'��(6�(;�	=�	
�����s�#�c�f�|jj�\}}|jd�||fS)zHTTPServer method, overridden.g$@)r�acceptr)r�request�client_addresss   r�get_requestzLoopbackHttpServer.get_request.s6��#'�+�+�"4�"4�"6����
	���4� ���(�(rN)�__name__�
__module__�__qualname__�__doc__rr�rrr
r
 s���$�
)rr
c�"�eZdZdZd�Zd�Zd�Zy)�LoopbackHttpServerThreadz2Stoppable thread that runs a loopback http server.c���tjj|�d|_tj�|_d|_td|�|_|jj|_
y)NFzHTTP/1.0)z	127.0.0.1r)�	threading�Threadr�_stop_server�Event�ready�protocol_versionr
�httpd�server_port�port�r�request_handlers  rrz!LoopbackHttpServerThread.__init__=sW�����!�!�$�'�!����_�_�&��
�+5��(�'�(8�(7�9��
��J�J�*�*��	rc�f�d|_|j�|jj�y)z.Stops the webserver if it's currently running.TN)r&�joinr*�server_close�rs r�stopzLoopbackHttpServerThread.stopFs%��!����	�	���
�
���!rc��|jj�|js(|jj	�|js�'yy�N)r(�setr&r*�handle_requestr2s r�runzLoopbackHttpServerThread.runNs4���
�
�����#�#��J�J�%�%�'��#�#rN)rrrrrr3r8r rrr"r":s��<�+�"�(rr"c�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�DigestAuthHandlerz-Handler for performing digest authentication.c�J�d|_g|_i|_d|_d|_y)Nrz
Test Realm�auth)�_request_num�_nonces�_users�_realm_name�_qopr2s rrzDigestAuthHandler.__init__Xs'�����������'�����	rc��||_yr5)rA)r�qops  r�set_qopzDigestAuthHandler.set_qop_s	����	rc�6�t|t�sJ�||_yr5)�
isinstance�dictr?)r�userss  r�	set_userszDigestAuthHandler.set_usersbs���%��&�&�&���rc��||_yr5)r@)r�realms  r�	set_realmzDigestAuthHandler.set_realmfs
�� ��rc���|xjdz
c_tjt|j�j	d��j�}|jj|�|S)N��ascii)r=�hashlib�md5�str�encode�	hexdigestr>�append)r�nonces  r�_generate_noncez!DigestAuthHandler._generate_nonceisW�����Q������C�� 1� 1�2�9�9�'�B�C�M�M�O�������E�"��rc�
�|jd�}||dzd}|jd�}i}|D]Q}|jd�\}}|j�}|ddk(r|ddk(r|dd}n|j�}|||<�S|S)N� rN�,�=r�"���)�find�split�strip)r�auth_str�first_space_index�parts�	auth_dict�part�name�values        r�_create_auth_dictz#DigestAuthHandler._create_auth_dictos���$�M�M�#�.���-�a�/�0�1�����s�#���	��D��*�*�S�/�K�D�%��:�:�<�D��Q�x�3��5��9��#3��a�������
��#�I�d�O���rc��i}|j|�||d<||d<||d<d|z}tj|jd��j	�}d|z}tj|jd��j	�}	||d<|	|d<d	|z}
tj|
jd��j	�}||d
k(S)N�password�method�uriz#%(username)s:%(realm)s:%(password)srOz%(method)s:%(uri)s�HA1�HA2z3%(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)s�response)�updaterPrQrSrT)rrdrjrkrl�
final_dict�HA1_strrm�HA2_strrn�response_strros            r�_validate_authz DigestAuthHandler._validate_auth�s����
����)�$�!)�
�:��%�
�8���
�5��7�*�D���k�k�'�.�.��1�2�<�<�>��&��3���k�k�'�.�.��1�2�<�<�>���
�5���
�5��4�6@�A���;�;�|�2�2�7�;�<�F�F�H���9�Z�0�0�0rc
��|jdd�|jdd�|jdd|j�d|j�d|j	��d	��|j�|jjd
�y)Ni�zProxy Authentication Required�Content-Type�	text/htmlzProxy-AuthenticatezDigest realm="z", qop="z	",nonce="z", sProxy Authentication Required.F)�
send_response�send_headerr@rArW�end_headers�wfile�writer-s  r�_return_auth_challengez(DigestAuthHandler._return_auth_challenge�s}���%�%�c�+J�K��#�#�N�K�@��#�#� ��
�
�t�y�y�$�*>�*>�*@�#B�	C�	�#�#�%����#�#�$E�F�rc�X�t|j�dk(ryd|jvr|j|�S|j	|jd�}|d|jvr|j|d}n|j|�S|jd�|jvr|j|�S|jj|d�d}|j|jfD]#}|j|||j|�s�"d}�%|s|j|�Sy)aPerforms digest authentication on the given HTTP request
        handler.  Returns True if authentication was successful, False
        otherwise.

        If no users have been set, then digest auth is effectively
        disabled and this method will always return True.
        rTzProxy-Authorization�usernamerVF)�lenr?�headersr~rh�getr>�remove�path�
short_pathru�command)rr.rdrj�auth_validatedr�s      rr7z DigestAuthHandler.handle_request�s,���t�{�{��q� �� ��(?�(?�?��.�.��?�?��.�.��'�'�(=�>��I���$����3��;�;�	�*�(=�?���2�2�?�C�C��=�=��)�T�\�\�9��2�2�?�C�C����#�#�I�g�$6�7�"�N�)�-�-��/I�/I�J���&�&�y�'/�'6�'>�'>�'+�-�&*�N�K�"��2�2�?�C�C�rN)
rrrrrrDrIrLrWrhrur~r7r rrr:r:Us2��7����!���"1�$
�*rr:c��eZdZdZdZdZdZe�de��Zejejd��jd�Zd�Z
d�Zd	�Zd
�Zd�Zy)
�BasicAuthHandlerz,Handler for performing basic authentication.�testUser�testPass�Test�:rOc�^�tjjj|g|��i|��yr5)rr
�BaseHTTPRequestHandlerr)r�args�kwargss   rrzBasicAuthHandler.__init__�s$�����*�*�3�3�D�J�4�J�6�Jrc��yr5r �r�formatr�s   r�log_messagezBasicAuthHandler.log_message�s��rc�j�|jd�|jdd�|j�y)N���Content-typerx)ryrzr{r2s r�do_HEADzBasicAuthHandler.do_HEAD�s,�����3�������5����rc��|jd�|jdd|jz�|jdd�|j�y)Ni�zWWW-AuthenticatezBasic realm="%s"r�rx)ryrz�REALMr{r2s r�do_AUTHHEADzBasicAuthHandler.do_AUTHHEAD�sG�����3�����+�-A�D�J�J�-N�O������5����rc��|jjdd�s,|j�|jj	d�y|jjdd�d|j
zk(r=|j
d�|j�|jj	d�y|j�y)N�
Authorization�sNo Auth header receivedzBasic r�sIt works)r�r�r�r|r}�ENCODED_AUTHryr{r2s r�do_GETzBasicAuthHandler.do_GET�s����|�|�����4������J�J���7�8�
�\�\�
�
���%�(0�4�3D�3D�(D�E����s�#������J�J���[�)�
���rN)rrrr�USER�PASSWDr��USER_PASSWD�base64�	b64encoderS�decoder�rr�r�r�r�r rrr�r��s`��6��D�
�F��E�!�6�*�K�#�6�#�#�K�$6�$6�w�$?�@�G�G��P�L�K�
��
�rr�c�"�eZdZdZd�Zd�Zd�Zy)�FakeProxyHandlerz�This is a 'fake proxy' that makes it look like the entire
    internet has gone down due to a sudden zombie invasion.  It main
    utility is in providing us with authentication support for
    testing.
    c�l�||_tjjj|g|��i|��yr5)�digest_auth_handlerrr
r�r)rr�r�r�s    rrzFakeProxyHandler.__init__s.��$7�� ����*�*�3�3�D�J�4�J�6�Jrc��yr5r r�s   rr�zFakeProxyHandler.log_messages��	
rc��tjj|jd�\}}}}}}||_|j
j
|�r�|jdd�|jdd�|j�|jjtd|jzd��|jjd�yy)	Nrr��OKrwrxzYou've reached %s!<BR>rOsFOur apologies, but our server is down due to a sudden zombie invasion.)
�urllib�parse�urlparser�r�r�r7ryrzr{r|r}�bytes)r�scm�netlocr��params�query�fragments       rr�zFakeProxyHandler.do_GETs���7=�|�|�7L�7L��I�I�v�8�4��f�d�F�E�8�����#�#�2�2�4�8����s�D�)����^�[�9������J�J���U�#;�d�i�i�#G�#*�,�
-��J�J���:�
;�
9rN)rrrrrr�r�r rrr�r��s���K�
�
;rr�c�J��eZdZdZdZdZdZ�fd�Zd�Z�fd�Z	d�Z
d	�Z�xZS)
�BasicAuthTestsr�r��	Incorrectr�c�>��tt|��d�}t|�|_|j|j�d|jjz|_|jj�|jjj�y)Nc��t|i|��Sr5)r�)r�r�s  r�#http_server_with_basic_auth_handlerzABasicAuthTests.setUp.<locals>.http_server_with_basic_auth_handler$s��#�T�4�V�4�4rzhttp://127.0.0.1:%s)�superr��setUpr"r
�
addCleanup�stop_serverr,�
server_url�startr(�wait)rr��	__class__s  �rr�zBasicAuthTests.setUp!sp���
�n�d�)�+�	5�.�/R�S�������(�(�)�/�$�+�+�2B�2B�B���������������� rc�F�|jj�d|_yr5�r
r3r2s rr�zBasicAuthTests.stop_server,�����������rc�*��tt|��yr5)r�r��tearDown)rr�s �rr�zBasicAuthTests.tearDown0s���
�n�d�,�.rc�$�tjj�}|j|j|j
|j|j�tjjtjj|��	|jtjj|j
��y#tjj$r!|jd|j
z�YywxYw)Nz!Basic auth failed for the url: %s)r�r�HTTPBasicAuthHandler�add_passwordr�r�r�r��install_opener�build_opener�
assertTrue�urlopen�error�	HTTPError�fail�r�ahs  r�test_basic_auth_successz&BasicAuthTests.test_basic_auth_success3s���
�^�^�
0�
0�
2��
����
�
�D�O�O�T�Y�Y����L����%�%�f�n�n�&A�&A�"�&E�F�	M��O�O�F�N�N�2�2�4�?�?�C�D���|�|�%�%�	M��I�I�9�D�O�O�K�L�	M�s�8C�;D�Dc���tjj�}|j|j|j
|j|j�tjjtjj|��|jtjjtjj|j
�yr5)r�rr�r�r�r�r��INCORRECT_PASSWDr�r��assertRaisesr�r�r�r�s  r�test_basic_auth_httperrorz(BasicAuthTests.test_basic_auth_httperror<s���
�^�^�
0�
0�
2��
����
�
�D�O�O�T�Y�Y��@U�@U�V����%�%�f�n�n�&A�&A�"�&E�F����&�,�,�0�0�&�.�.�2H�2H�$�/�/�Zr)
rrrr�r�r�r�r�r�r�r�r��
__classcell__�r�s@rr�r�s3����D�
�F�"���E�	!��/�M�[rr�rQ)�opensslc�L��eZdZdZdZdZdZ�fd�Zd�Zd�Z	d�Z
d	�Zd
�Z�xZ
S)�ProxyAuthTestszhttp://localhost�tester�test123�	TestRealmc����tt���d�}�j|tj
j
��dtj
d<dtj
d<t��_�jj�j�ji��jj�j��fd�}t|��_�j�j ��jj#��jj$j'�d�jj(z}t*j,j/d|i�}t*j,j1��_t*j,j5|�j2��_y)Nc�~�tjj�tjj|�yr5��os�environ�clearrp��old_environs r�restore_environz-ProxyAuthTests.setUp.<locals>.restore_environN�$���J�J�����J�J���k�*rr��NO_PROXY�no_proxyc�6��t�jg|��i|��Sr5)r�r�)r�r�rs  �r�create_fake_proxy_handlerz7ProxyAuthTests.setUp.<locals>.create_fake_proxy_handlerYs���#�D�$<�$<�N�t�N�v�N�Nrzhttp://127.0.0.1:%dr)r�r�r�r�r�r��copyr:r�rIr�r�rLr�r"r
r�r�r(r�r,r�r�ProxyHandler�ProxyDigestAuthHandler�proxy_digest_handlerr��opener)rr�r��	proxy_url�handlerr�s`    �rr�zProxyAuthTests.setUpKs@���
�n�d�)�+�	+�	
���������):�;�!#��
�
�:��!#��
�
�:��#4�#6�� �� � �*�*�D�I�I�t�{�{�+C�D�� � �*�*�4�:�:�6�	O�/�/H�I�������(�(�)�������������� �)�D�K�K�,<�,<�<�	��.�.�-�-�v�	�.B�C��$*�N�N�$I�$I�$K��!��n�n�1�1��T�.�.�0��rc�F�|jj�d|_yr5r�r2s rr�zProxyAuthTests.stop_serverfr�rc�^�|jj|j|j|j|j
dz�|jjd�|jtjj|jj|j�y)N�badr<)r�r�r��URLr�r�r�rDr�r�r�r�r��openr2s r�-test_proxy_with_bad_password_raises_httperrorz<ProxyAuthTests.test_proxy_with_bad_password_raises_httperrorjsw���!�!�.�.�t�z�z�4�8�8�/3�y�y�$�+�+�e�:K�	M�� � �(�(��0����&�,�,�0�0��+�+�*�*��(�(�	$rc���|jjd�|jtjj
|jj|j�y�Nr<)	r�rDr�r�r�r�r�r�r�r2s r�,test_proxy_with_no_password_raises_httperrorz;ProxyAuthTests.test_proxy_with_no_password_raises_httperrorrsD��� � �(�(��0����&�,�,�0�0��+�+�*�*��(�(�	$rc�~�|jj|j|j|j|j
�|jjd�|jj|j�5}|j�r	|j�r�ddd�y#1swYyxYwr)r�r�r�r�r�r�r�rDr�r��read�r�results  r�test_proxy_qop_auth_worksz(ProxyAuthTests.test_proxy_qop_auth_worksxs���!�!�.�.�t�z�z�4�8�8�/3�y�y�$�+�+�	G�� � �(�(��0�
�[�[�
�
�d�h�h�
'�6��+�+�-���+�+�-�(�
'�
'�s�"B3�3B<c���|jj|j|j|j|j
�|jjd�	|jj|j�}|5|j�r	|j�r�ddd�y#1swYyxYw#tjj$rYywxYw)Nzauth-int)r�r�r�r�r�r�r�rDr�r�rr�r��URLErrorrs  r�0test_proxy_qop_auth_int_works_or_throws_urlerrorz?ProxyAuthTests.test_proxy_qop_auth_int_works_or_throws_urlerror�s����!�!�.�.�t�z�z�4�8�8�/3�y�y�$�+�+�	G�� � �(�(��4�
	��[�[�%�%�d�h�h�/�F���k�k�m���k�k�m�����
�|�|�$�$�	�
�		�s�#%C�
"B6�6B?�C"�!C")rrrr�r�r�r�r�r�r�rrr
r�r�s@rr�r�Cs5���
�C��D�
�F��E�0�6�$�$��rr�c�V���G��fd�dtjj���S)Nc�<��eZdZdZgZgZdZd�Zd�Z��fd�Z	d�Z
y)�1GetRequestHandler.<locals>.FakeHTTPRequestHandlerz	TestHTTP/�Pc�p�|j�}|r$|jj|�}||d}|r�#yyr5)�	send_headr|r})r�body�dones   rr�z8GetRequestHandler.<locals>.FakeHTTPRequestHandler.do_GET�s5���>�>�#�D���z�z�'�'��-���D�E�{��rc��|jd}|jjt|��}|j	�|j
j
|�y)NzContent-Length)r��rfiler�intr��requestsrU)r�content_length�	post_datas   r�do_POSTz9GetRequestHandler.<locals>.FakeHTTPRequestHandler.do_POST�sC��!�\�\�*:�;�N��
�
����N�(;�<�I��K�K�M��M�M� � ��+rc���|j�_|jj|j��jd�\}}}|j
|�|D]&\}}|j||d|jiz��(|r$|jdd�|j�|S|j�y)Nrr,r�z
text/plain)
r��headers_receivedrrUr��popryrzr,r{)r�
response_coder�r�headerrg�FakeHTTPRequestHandler�	responsess      ��rrz;GetRequestHandler.<locals>.FakeHTTPRequestHandler.send_head�s����6:�l�l�"�3��M�M� � ����+�+4�=�=��+;�(�M�7�D����}�-�#*����� � ���&����1C�)C�D�$+��� � ���>�� � �"������rc��yr5r )rr�s  rr�z=GetRequestHandler.<locals>.FakeHTTPRequestHandler.log_message�s��rN)rrr�server_versionrrr,r�rrr�)rr s��rrr
�s,���$��������	#�	,�
	�	rr)rr
r�)r rs`@r�GetRequestHandlerr#�s"���#����!C�!C�#�L"�!rc���eZdZdZ�fd�Zdd�Zd�Zdd�Zdd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�TestUrlopenaNTests urllib.request.urlopen using the network.

    These tests are not exhaustive.  Assuming that testing using files does a
    good job overall of some of the basic interface features.  There are no
    tests exercising the optional 'data' and 'proxies' arguments.  No tests
    for transparent redirection have been written.
    c�*��tt|��|jtj
j�d�}|j|tjj��dtjd<dtjd<y)Nc�~�tjj�tjj|�yr5r�r�s rr�z*TestUrlopen.setUp.<locals>.restore_environ�r�r�*r�r�)
r�r%r�r�r�r�
urlcleanupr�r�r�)rr�r�s  �rr�zTestUrlopen.setUp�sd���
�k�4�&�(�	
������1�1�2�	+�	
���������):�;�!$��
�
�:��!$��
�
�:�rc��g}tjj||fi|��}	|j|j	d��|j|j
��|j|jd��|j|j��|j�dj|�S#|j�wxYw)Nr�ir)
r�rr��extend�	readlinesrU�readliner�closer0)r�url�datar��l�fs      rr�zTestUrlopen.urlopen�s������N�N�"�"�3��7��7��	�
�H�H�Q�[�[��%�&�
�H�H�Q�Z�Z�\�"�
�H�H�Q�V�V�D�\�"�
�H�H�Q�V�V�X��
�G�G�I��x�x��{���
�G�G�I�s�A>C�Cc�F�|jj�d|_yr5r�r2s rr�zTestUrlopen.stop_server�r�rc�8�|�dgdfg}t|�}t|�|_|j|j�|jj�|jjj�|jj}||_|S)Nr�s
we don't care)	r#r"r
r�r�r�r(r�r,)rr r�r,s    r�start_serverzTestUrlopen.start_server�s������r�#3�4�5�I�#�I�.��.�w�7�������(�(�)�������������� ��{�{��������rc���ttjd�s|jd�ddlm}|�dgdfg}t
|�}||fd|i|��}|j|_|S)N�HTTPSHandlerzssl support requiredr)�make_https_serverr��
we care a bit�
handler_class)�hasattrr�r�skipTest�test.ssl_serversr8r#r,)rr r�r8r�r
s      r�start_https_serverzTestUrlopen.start_https_server�sd���v�~�~�~�6��M�M�0�1�6����r�#3�4�5�I�#�I�.��"�4�I�w�I�&�I���{�{����rc���d}ddgdfdg|fg}|j|�}|jd|jz�}|j||�|j|jddg�y)	NsWe got here...i.)�Locationz(http://localhost:%(port)s/somewhere_elser�r��http://localhost:%s/�/z/somewhere_else�r5r�r,�assertEqualr)r�expected_responser r�r0s     r�test_redirectionzTestUrlopen.test_redirection�s���-��
�K�L�
�
�
�"�'�(�
�	��#�#�I�.���|�|�2�W�\�\�A�B������0�1�����)�)�C�1B�+C�Drc��d}d}ddg|fg}|j|�}|jd|jz�}|j||�y)Nshello worldsa
hello worl
1
d
0
r�)zTransfer-Encoding�chunkedrA)r5r�r,rD)rrE�
chunked_startror�r0s      r�test_chunkedzTestUrlopen.test_chunked	s`��*��!�	��;�<�m�L�M���#�#�H�-���|�|�2�W�\�\�A�B������0�1rc��d}|jdg|fg�}	|jd|jz�|jd�|j|�|j|jdg�y#tj
j$r*}|j�}|j�Yd}~�rd}~wwxYw)NsBad bad bad...i�zhttp://localhost:%s/weeblez404 should raise URLErrorz/weeble)r5r�r,r�r�r�r	rr.rDr)rrEr�r2r0s     r�test_404zTestUrlopen.test_404s���-���#�#�c�2�/@�%A�$B�C��	3��L�L�5����D�E�

�I�I�1�2�����0�1�����)�)�I�;�7���|�|�$�$�	��6�6�8�D�
�G�G�I�I��	�s�A8�8B?� B:�:B?c���d}|jdg|fg�}|jd|jz�}|j||�|j|jdg�y)N�
pycon 2008...r��http://localhost:%s/bizarre�/bizarrerC�rrEr�r0s    r�test_200zTestUrlopen.test_200&sd��,���#�#�c�2�/@�%A�$B�C���|�|�9�G�L�L�H�I������0�1�����)�)�J�<�8rc���d}|jdg|fg�}|jd|jzd�}|j||�|j|jddg�y)NrNr�rOsget=with_feelingrPrCrQs    r�test_200_with_parametersz$TestUrlopen.test_200_with_parameters-sm��,���#�#�c�2�/@�%A�$B�C���|�|�9�G�L�L�H�0�2������0�1�����)�)�J�8K�+L�Mrc��|j�}tjt��}|j	d|j
z|��}|j
|d�y)N��cafile�https://localhost:%s/bizarre��contextr9)r>�ssl�create_default_context�CERT_localhostr�r,rD)rr�rZr0s    r�
test_httpszTestUrlopen.test_https5sN���)�)�+���,�,�N�C���|�|�:�W�\�\�I�SZ�|�[������/�0rc��|jt��}tjdtf�5|jd|jzt��}|j|d�|jtjj�5}|jd|jzt��ddd�|jt��}|jtjj�5}|jd|jzt��ddd�ddd�y#1swY�~xYw#1swY�xYw#1swYyxYw)N��certfiler�rXrVr9)
r>r]r�check_warnings�DeprecationWarningr�r,rDr�r�r�r	�CERT_fakehostname)rr�r0�cms    r�test_https_with_cafilez"TestUrlopen.test_https_with_cafile;s���)�)�>�)�B��
�
+�
+�R�1C�,D�
E��<�<� >���� M�'5� �7�D����T�#3�4��"�"�6�<�<�#8�#8�9�R����;�g�l�l�J�$5��7�:��-�-�7H�-�I�G��"�"�6�<�<�#8�#8�9�R����;�g�l�l�J�$5��7�:�F�
E�:�9��
:�9��F�
E�s=�A E�%D4�7AE�>%E�#E�4D=	�9E�E		�E�Ec�L�|jt��}tjdtf�5|jtjj�5}|jd|jzd��ddd�ddd�y#1swY�xYw#1swYyxYw)Nr`r�rXT)�	cadefault)r>r]rrbrcr�r�r�r	r�r,)rr�res   r�test_https_with_cadefaultz%TestUrlopen.test_https_with_cadefaultLs����)�)�>�)�B��
�
+�
+�R�1C�,D�
E��"�"�6�<�<�#8�#8�9�R����;�g�l�l�J�'+��-�:�F�
E�9�9��F�
E�s#�*B�!B�=B�B	�B�B#c���t�|jd�tjs|jd�d��fd�}tjtj�}|j|�|j
|t��}tjt��}|jd|jz|��|j�d�y)	Nzssl module requiredzSNI support required in OpenSSLc�
��|�yr5r )�ssl_sock�server_name�initial_context�sni_names   �r�cb_sniz*TestUrlopen.test_https_sni.<locals>.cb_sniZs���"�Hr)rZrarVzhttps://localhost:%srY�	localhost)r[r<�HAS_SNI�
SSLContext�PROTOCOL_TLS_SERVER�set_servername_callbackr>r]r\r�r,rD)rrprZr�ros    @r�test_https_snizTestUrlopen.test_https_sniTs�����;��M�M�/�0��{�{��M�M�;�<���	#��.�.��!8�!8�9���'�'��/��)�)�'�N�)�S���,�,�N�C�����+�g�l�l�:�G��L�����;�/rc�,�|j�}tjjd|jzddi��}tjj|�5	ddd�|j
|jdd�y#1swY�)xYw)NrA�Rangezbytes=20-39�r�)r5r�r�Requestr,r�rDr�rr��reqs   r�test_sending_headersz TestUrlopen.test_sending_headersds|���#�#�%���n�n�$�$�%;�g�l�l�%J�.5�}�-E�%�G��
�^�^�
#�
#�C�
(��)�����1�1�'�:�M�J�)�
(�s� B
�
Bc��|j�}tjjd|jzddi��}tjj|�5	ddd�|j
d|jj��|jd|jj��y#1swY�^xYw)NrAz
X-SoMe-hEader�foobarryz
X-Some-Header)
r5r�rrzr,r��assertInr�keys�assertNotInr{s   r�test_sending_headers_camelz&TestUrlopen.test_sending_headers_camells����#�#�%���n�n�$�$�%;�g�l�l�%J�.=�x�-H�%�J��
�^�^�
#�
#�C�
(��)��
�
�o�w�'?�'?�'D�'D�'F�G�����'�*B�*B�*G�*G�*I�J�)�
(�s� B?�?Cc�2�|j�}tjjd|jz�5}dD]!}|jt
||�d|z��#|j|j�d�ddd�y#1swYyxYw)N�http://localhost:%s)rr.�info�geturlz3object returned from urlopen lacks the %s attributezcalling 'read' failed)r5r�rr�r,r�r;r)rr��open_url�attrs    r�
test_basiczTestUrlopen.test_basicus����#�#�%��
�^�^�
#�
#�$9�G�L�L�$H�
I�X�;�������$� 7�:>�@D�:E�F�<�
�O�O�H�M�M�O�-D�E�	J�
I�
I�s�AB
�
Bc�`�|j�}tjjd|jz�}|5|j�}ddd�|j
tjjd�|j|j�d�y#1swY�UxYw)Nr�zEobject returned by 'info' is not an instance of email.message.Message�plain)r5r�rr�r,r��assertIsInstance�email�message�MessagerD�get_content_subtype)rr�r��info_objs    r�	test_infozTestUrlopen.test_info}s����#�#�%���>�>�)�)�!�G�L�L�0�2��
��}�}��H�����h��
�
�(=�(=�B�	C�	
����5�5�7��A��X�s�B$�$B-c��|j�}tjjd|jz�}|5|j�}ddd�|j
d|jz�y#1swY�)xYw)Nr�)r5r�rr�r,r�rD)rr�r�r/s    r�test_geturlzTestUrlopen.test_geturl�sd���#�#�%���>�>�)�)�*?�'�,�,�*N�O��
��/�/�#�C������3�g�l�l�B�C��X�s�A8�8Bc��d}|jdg|fg�}tjjd|jz�}|D]}|j||��y)NrNr�r�)r5r�rr�r,rD)rrEr�r0�lines     r�test_iterationzTestUrlopen.test_iteration�s\��,���#�#�c�2�/@�%A�$B�C���~�~�%�%�&;�g�l�l�&J�K���D����T�#4�5�rc
��dddddzdzg}dj|�}|jdg|fg�}tjj	d	|j
z�}t
|�D]9\}}|j|||d
|�dt||��dt|�����;|jd
zt|��y)NsWe
sgot
shere
s	verylong i �
rr�r�zFetched line number z1 doesn't match expected:
    Expected length was z, got rN)	r0r5r�rr�r,�	enumeraterDr�)r�linesrEr�r0�indexr�s       r�test_line_iterationzTestUrlopen.test_line_iteration�s����(�I�|�d�/B�U�/J�K���H�H�U�O���#�#�c�2�/@�%A�$B�C���~�~�%�%�&;�g�l�l�&J�K��$�T�?�K�E�4����T�5��<�$�S��u��%6��D�	�C�
D�+�
	
������C��J�/rc�z�|jdgdfdgdfg�}tjj�}tjj	d|j
z�}|j
d|j�|j|djd��|j
d|j�|j
d|jd��|j|djd��|j
d	|j�|j
d
|jd��y)Nr�sanyr��1zus-ascii�1zContent-length�
1234567890s
1234567890�10)r5r�rr�rzr,rDr0r�rS�
get_header)rr�r�rs    r�test_issue16464zTestUrlopen.test_issue16464�s���#�#�
�"�f��
�"�f��%
������,�,�.���.�.�(�(�)>����)M�N������w�|�|�,����G�S�Z�Z�
�3�4�����w�|�|�,�����g�0�0�1A�B�C����G�\�0�0��<�=��������5�����w�1�1�2B�C�Drr5)rrrrr�r�r�r5r>rFrJrLrRrTr^rfrirvr}r�r�r�r�r�r�r�r�r�s@rr%r%�s~����%����	�E�2�
8�9�N�1�7�"-�0� K�K�F�	B�D�6�
0�Err%c�t�tj�}tjtjg|���yr5)r�threading_setup�unittest�addModuleCleanup�threading_cleanup)�thread_infos r�setUpModuler��s*��"�2�2�4�K����.�@�@�O�;�Or�__main__)-r�r�r��urllib.parser��urllib.request�http.serverrr$r�rP�testr�test.supportrrrr[�ImportError�requires_working_socketr��dirname�__file__�herer0r]rdr
rr
r%r"r:r�r�r��TestCaser��requires_hashdigestr�r#r%r�r�mainr rr�<module>r�s���
�	���������'�)�(��� ����t�,�	�w�w���x� �������d�J�
�>���G�G�L�L��z�>�B��
)����/�/�)�4(�y�/�/�(�6v�v�r&�t�{�{�9�9�&�X;�t�{�{�9�9�;�B%[�X�&�&�%[�P$��#�#�E�4�8�J�X�&�&�J�9�J�Z("�VxE�(�#�#�xE�tP�
�z���H�M�M�O���S��
�C��s�F�F%�$F%

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