Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/__pycache__/test_urllib2_localnet.cpython-312.opt-2.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��eZdZ	d�Zd�Zy)�LoopbackHttpServerc��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�h�	|jj�\}}|jd�||fS)Ng$@)r�acceptr)r�request�client_addresss   r�get_requestzLoopbackHttpServer.get_request.s7��,�"&�+�+�"4�"4�"6����
	���4� ���(�(rN)�__name__�
__module__�__qualname__rr�rrr
r
 s���$�
)rr
c� �eZdZ	d�Zd�Zd�Zy)�LoopbackHttpServerThreadc���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�h�	d|_|j�|jj�y)NT)r%�joinr)�server_close�rs r�stopzLoopbackHttpServerThread.stopFs&��<� ����	�	���
�
���!rc��|jj�|js(|jj	�|js�'yy�N)r'�setr%r)�handle_requestr1s r�runzLoopbackHttpServerThread.runNs4���
�
�����#�#��J�J�%�%�'��#�#rN)rrrrr2r7rrrr!r!:s��<�+�"�(rr!c�D�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�DigestAuthHandlerc�J�d|_g|_i|_d|_d|_y)Nrz
Test Realm�auth)�_request_num�_nonces�_users�_realm_name�_qopr1s rrzDigestAuthHandler.__init__Xs'�����������'�����	rc��||_yr4)r@)r�qops  r�set_qopzDigestAuthHandler.set_qop_s	����	rc��||_yr4)r>)r�userss  r�	set_userszDigestAuthHandler.set_usersbs	����rc��||_yr4)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� rK�,�=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)srLz%(method)s:%(uri)s�HA1�HA2z3%(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)s�response)�updaterMrNrPrQ)rrargrhri�
final_dict�HA1_strrj�HA2_strrk�response_strrls            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?r@rT�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�Z�	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)NrTzProxy-Authorization�usernamerSF)�lenr>�headersr{re�getr=�remove�path�
short_pathrr�command)rr-rarg�auth_validatedr�s      rr6z DigestAuthHandler.handle_request�s1��	��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)rrrrrCrFrIrTrerrr{r6rrrr9r9Us2��7����!���"1�$
�*rr9c��eZdZ	dZdZdZe�de��Zejejd��jd�Zd�Zd�Z
d�Zd	�Zd
�Zy)�BasicAuthHandler�testUser�testPass�Test�:rLc�^�tjjj|g|��i|��yr4)rr
�BaseHTTPRequestHandlerr)r�args�kwargss   rrzBasicAuthHandler.__init__�s$�����*�*�3�3�D�J�4�J�6�Jrc��yr4r�r�formatr�s   r�log_messagezBasicAuthHandler.log_message�s��rc�j�|jd�|jdd�|j�y)N���Content-typeru)rvrwrxr1s r�do_HEADzBasicAuthHandler.do_HEAD�s,�����3�������5����rc��|jd�|jdd|jz�|jdd�|j�y)Ni�zWWW-AuthenticatezBasic realm="%s"r�ru)rvrw�REALMrxr1s 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)rr�r�ryrz�ENCODED_AUTHrvrxr1s r�do_GETzBasicAuthHandler.do_GET�s����|�|�����4������J�J���7�8�
�\�\�
�
���%�(0�4�3D�3D�(D�E����s�#������J�J���[�)�
���rN)rrr�USER�PASSWDr��USER_PASSWD�base64�	b64encoderP�decoder�rr�r�r�r�rrrr�r��s`��6��D�
�F��E�!�6�*�K�#�6�#�#�K�$6�$6�w�$?�@�G�G��P�L�K�
��
�rr�c� �eZdZ	d�Zd�Zd�Zy)�FakeProxyHandlerc�l�||_tjjj|g|��i|��yr4)�digest_auth_handlerrr
r�r)rr�r�r�s    rrzFakeProxyHandler.__init__s.��$7�� ����*�*�3�3�D�J�4�J�6�Jrc��yr4rr�s   rr�zFakeProxyHandler.log_messages��	
rc��tjj|jd�\}}}}}}||_|j
j
|�r�|jdd�|jdd�|j�|jjtd|jzd��|jjd�yy)	Nrr��OKrtruzYou've reached %s!<BR>rLsFOur apologies, but our server is down due to a sudden zombie invasion.)
�urllib�parse�urlparser�r�r�r6rvrwrxryrz�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)rrrrr�r�rrrr�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|��Sr4)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|_yr4�r
r2r1s rr�zBasicAuthTests.stop_server,�����������rc�*��tt|��yr4)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
�yr4)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�rN)�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|�yr4��os�environ�clearrm��old_environs r�restore_environz-ProxyAuthTests.setUp.<locals>.restore_environN�$���J�J�����J�J���k�*rr��NO_PROXY�no_proxyc�6��t�jg|��i|��Sr4)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��copyr9r�rFr�r�rIr�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|_yr4r�r1s 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�rCr�r�r�r�r��openr1s 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�rCr�r�r�r�r�r�r�r1s 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�rCr�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�rCr�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�r�rrr�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�#yyr4)�	send_headryrz)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��requestsrR)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_receivedrrRr��poprvrwr+rx)r�
response_coderr�headerrd�FakeHTTPRequestHandler�	responsess      ��rr
z;GetRequestHandler.<locals>.FakeHTTPRequestHandler.send_head�s����6:�l�l�"�3��M�M� � ����+�+4�=�=��+;�(�M�7�D����}�-�#*����� � ���&����1C�)C�D�$+��� � ���>�� � �"������rc��yr4r)rr�s  rr�z=GetRequestHandler.<locals>.FakeHTTPRequestHandler.log_message�s��rN)rrr�server_versionrrr+r�rr
r�)rrs��rrr
�s,���$��������	#�	,�
	�	rr)rr
r�)rrs`@r�GetRequestHandlerr �s"���#����!C�!C�#�L"�!rc���eZdZ	�fd�Zdd�Zd�Zdd�Zdd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�TestUrlopenc�*��tt|��|jtj
j�d�}|j|tjj��dtjd<dtjd<y)Nc�~�tjj�tjj|�yr4r�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�	readlinesrR�readliner�closer/)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|_yr4r�r1s 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+)rrr�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_serversr5r r+)rrr�r5r�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�r2r�r+�assertEqualr)r�expected_responserr�r-s     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�chunkedr>)r2r�r+rA)rrB�
chunked_startrlr�r-s      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)r2r�r+r�r�r�rrr+rAr)rrBr�r/r-s     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�/bizarrer@�rrBr�r-s    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)NrKr�rLsget=with_feelingrMr@rNs    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��contextr6)r;�ssl�create_default_context�CERT_localhostr�r+rA)rr�rWr-s    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�rUrSr6)
r;rZr�check_warnings�DeprecationWarningr�r+rAr�r�r�r�CERT_fakehostname)rr�r-�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�rUT)�	cadefault)r;rZrr_r`r�r�r�rr�r+)rr�rbs   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�
��|�yr4r)�ssl_sock�server_name�initial_context�sni_names   �r�cb_sniz*TestUrlopen.test_https_sni.<locals>.cb_sniZs���"�Hr)rWr^rSzhttps://localhost:%srV�	localhost)rXr9�HAS_SNI�
SSLContext�PROTOCOL_TLS_SERVER�set_servername_callbackr;rZrYr�r+rA)rrmrWr�rls    @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)Nr>�Rangezbytes=20-39�r)r2r�r�Requestr+r�rAr�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)Nr>z
X-SoMe-hEader�foobarrvz
X-Some-Header)
r2r�rrwr+r��assertInr�keys�assertNotInrxs   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)r2r�rr�r+r�r8r)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)r2r�rr�r+r��assertIsInstance�email�message�MessagerA�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�)r2r�rr�r+r�rA)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)NrKr�r�)r2r�rr�r+rA)rrBr�r-�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 rK)	r/r2r�rr�r+�	enumeraterAr~)r�linesrBr�r-�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)r2r�rr�rwr+rAr-r�rP�
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�Drr4)rrrr�r�r�r2r;rCrGrIrOrQr[rcrfrsrzr�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|���yr4)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�rM�testr�test.supportrrrrX�ImportError�requires_working_socketr��dirname�__file__�herer/rZrar
rr
r$r!r9r�r�r��TestCaser��requires_hashdigestr�r r"r�r�mainrrr�<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