403Webshell
Server IP : 54.37.205.81  /  Your IP : 216.73.216.76
Web Server : nginx/1.22.1
System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64
User : debian ( 1000)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/tornado/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/tornado/test/__pycache__/httpclient_test.cpython-311.pyc
�

��b�����ddlZddlZddlmZddlZddlZddlZddlZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZmZddlmZddlmZmZmZmZmZddlmZddlmZdd	l m!Z!dd
l"m#Z#m$Z$ddlm%Z%ddl&m'Z'm(Z(m)Z)m*Z*dd
l+m,Z,ddl-m.Z.m/Z/m0Z0ddl1m2Z2m3Z3Gd�de/��Z4Gd�de/��Z5Gd�de/��Z6Gd�de/��Z7Gd�de/��Z8Gd�de/��Z9Gd�de/��Z:Gd�de/��Z;Gd �d!e/��Z<Gd"�d#e/��Z=Gd$�d%e/��Z>Gd&�d'e/��Z?Gd(�d)e/��Z@Gd*�d+e/��ZAGd,�d-e/��ZBGd.�d/e/��ZCGd0�d1e'��ZDGd2�d3ejE��ZFGd4�d5ejE��ZGGd6�d7ejE��ZHGd8�d9ejE��ZIGd:�d;ejE��ZJGd<�d=ejE��ZKdS)>�N)�closing)�BytesIO)�utf8�
native_str�
to_unicode)�gen)�HTTPRequest�HTTPResponse�
_RequestProxy�	HTTPError�
HTTPClient)�
HTTPServer)�IOLoop)�IOStream)�gen_log�app_log)�netutil)�AsyncHTTPTestCase�bind_unused_port�gen_test�	ExpectLog)�skipOnTravis)�Application�RequestHandler�url)�format_timestamp�HTTPHeadersc��eZdZd�ZdS)�HelloWorldHandlerc��|�dd��}|�dd��|�d|z��dS)N�name�world�Content-Type�
text/plainz	Hello %s!)�get_argument�
set_header�finish)�selfr!s  �>/usr/lib/python3/dist-packages/tornado/test/httpclient_test.py�getzHelloWorldHandler.get%sH��� � ���1�1�������5�5�5����K�$�&�'�'�'�'�'�N��__name__�
__module__�__qualname__r*�r+r)rr$s#������(�(�(�(�(r+rc��eZdZd�ZdS)�PostHandlerc��|�d|�d���d|�d������dS)NzPost arg1: �arg1z, arg2: �arg2)r'r%�r(s r)�postzPostHandler.post,sT������� � ��(�(�(�(�$�*;�*;�F�*C�*C�*C�
E�	
�	
�	
�	
�	
r+N�r-r.r/r7r0r+r)r2r2+�#������
�
�
�
�
r+r2c��eZdZd�ZdS)�
PutHandlerc�n�|�d��|�|jj��dS)Nz
Put body: ��write�request�bodyr6s r)�putzPutHandler.put4s1���
�
�<� � � ��
�
�4�<�$�%�%�%�%�%r+N)r-r.r/rAr0r+r)r;r;3�#������&�&�&�&�&r+r;c��eZdZd�ZdS)�RedirectHandlerc	���|�d��|�|�d��t|�dd�������dS)Nzredirects can have bodies toor�status�302)rF)r>�redirectr%�intr6s r)�preparezRedirectHandler.prepare:se���
�
�2�3�3�3��
�
����e�$�$�S��1B�1B�8�U�1S�1S�-T�-T�	�	
�	
�	
�	
�	
r+N�r-r.r/rJr0r+r)rDrD9r9r+rDc��eZdZd�ZdS)�RedirectWithoutLocationHandlerc�X�|�d��|���dS)N�-)�
set_statusr'r6s r)rJz&RedirectWithoutLocationHandler.prepareBs%������������
�
�
�
�
r+NrKr0r+r)rMrMAs#����������r+rMc�.�eZdZejd���ZdS)�ChunkHandlerc#�K�|�d��|���tjd��V�|�d��dS)N�asdf�{�G�z�?�qwer)r>�flushr�sleepr6s r)r*zChunkHandler.getIsQ�����
�
�6�����
�
�����i��o�o�����
�
�6�����r+N)r-r.r/r�	coroutiner*r0r+r)rRrRHs/�������]����]���r+rRc��eZdZd�ZdS)�AuthHandlerc�P�|�|jjd��dS)N�
Authorization)r'r?�headersr6s r)r*zAuthHandler.getSs$�����D�L�(��9�:�:�:�:�:r+Nr,r0r+r)r[r[Rs#������;�;�;�;�;r+r[c��eZdZd�ZdS)�CountdownHandlerc��t|��}|dkr.|�|�d|dz
����dS|�d��dS)Nr�	countdown��Zero)rIrH�reverse_urlr>)r(�counts  r)r*zCountdownHandler.getXsZ���E�
�
���1�9�9��M�M�$�*�*�;���	�B�B�C�C�C�C�C��J�J�v�����r+Nr,r0r+r)r`r`Ws#����������r+r`c��eZdZd�ZdS)�EchoPostHandlerc�D�|�|jj��dS�Nr=r6s r)r7zEchoPostHandler.postas���
�
�4�<�$�%�%�%�%�%r+Nr8r0r+r)rhrh`s#������&�&�&�&�&r+rhc��eZdZd�ZdS)�UserAgentHandlerc�l�|�|jj�dd����dS)N�
User-AgentzUser agent not set)r>r?r^r*r6s r)r*zUserAgentHandler.getfs0���
�
�4�<�'�+�+�L�:N�O�O�P�P�P�P�Pr+Nr,r0r+r)rlrles(������Q�Q�Q�Q�Qr+rlc��eZdZd�Zd�ZdS)�ContentLength304Handlerc�\�|�d��|�dd��dS)N�0�Content-Length�*)rPr&r6s r)r*zContentLength304Handler.getks/������������(�"�-�-�-�-�-r+c��dSrjr0r6s r)�_clear_representation_headersz5ContentLength304Handler._clear_representation_headersos	��	
�r+N)r-r.r/r*rvr0r+r)rprpjs2������.�.�.�
�
�
�
�
r+rpc��eZdZd�ZdS)�PatchHandlerc�D�|�|jj��dS)z=Return the request payload - so we can check it is being keptNr=r6s r)�patchzPatchHandler.patchvs���
�
�4�<�$�%�%�%�%�%r+N)r-r.r/rzr0r+r)rxrxurBr+rxc�H�eZdZejdzZd�ZexZxZxZxZ	xZ
xZxZZ
dS)�AllMethodsHandler)�OTHERc�`�|jj�J�|�|jj��dSrj)r?�methodr>r6s r)rzAllMethodsHandler.method~s0���|�"�.�.�.��
�
�4�<�&�'�'�'�'�'r+N)r-r.r/r�SUPPORTED_METHODSrr*�headr7rA�delete�optionsrz�otherr0r+r)r|r|{sW������&�8�:�E��(�(�(�BH�G�C�G�$�G��G��G�f�G�w�G����r+r|c��eZdZd�ZdS)�SetHeaderHandlerc��t|�d��|jjd��D]\}}|�||���dS)N�k�v)�zip�
get_argumentsr?�	argumentsr&)r(r�r�s   r)r*zSetHeaderHandler.get�sZ����*�*�3�/�/���1G��1L�M�M�	"�	"�D�A�q��O�O�A�q�!�!�!�!�	"�	"r+Nr,r0r+r)r�r��s#������"�"�"�"�"r+r�c��eZdZdd�ZdS)�InvalidGzipHandler�returnNc�F�|�dd��|�dd��d�d�td��D����dd�}tj|���d	�
��dz}|�|��dS)Nr#r$�Content-Encoding�gzip�c3�@K�|]}d�|��V��dS)zHello World {}
N)�format)�.0�is  r)�	<genexpr>z)InvalidGzipHandler.get.<locals>.<genexpr>�s1����I�I��)�0�0��3�3�I�I�I�I�I�Ir+i(#i;F�)�
compresslevel�)r&�join�ranger��compress�encoder>)r(�textr@s   r)r*zInvalidGzipHandler.get�s��������5�5�5����*�F�3�3�3��w�w�I�I�U�4�[�[�I�I�I�I�I�'�6�'�R���}�T�[�[�]�]�!�<�<�<�v�E���
�
�4�����r+)r�Nr,r0r+r)r�r��s(������	�	�	�	�	�	r+r�c��eZdZd�ZdS)�HeaderEncodingHandlerc�v�|�|jjd�d����dS)N�Foo�	ISO8859-1)r'r?r^r�r6s r)r*zHeaderEncodingHandler.get�s2�����D�L�(��/�6�6�{�C�C�D�D�D�D�Dr+Nr,r0r+r)r�r��s(������E�E�E�E�Er+r�c��eZdZd�Zd�Zed���Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed���Zd�Zd�Zed���Zd�Zed���Z ed���Z!ed���Z"ed���Z#ed ���Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*ed'���Z+d(S))�HTTPClientCommonTestCasec��ttdt��tdt��tdt��tdt
��tdt��tdt��tdt��tdtd	�
��tdt��tdt��td
t��tdt��tdt��tdt��tdt ��tdt"��gd���S)N�/hello�/postz/putz	/redirect�/redirect_without_location�/chunk�/authz/countdown/([0-9]+)rb)r!�	/echopost�/user_agent�/304_with_content_length�/all_methods�/patchz/set_header�
/invalid_gzip�/header-encodingT)r�)rrrr2r;rDrMrRr[r`rhrlrpr|rxr�r�r�r6s r)�get_appz HTTPClientCommonTestCase.get_app�s����H�/�0�0��G�[�)�)��F�J�'�'��K��1�1��0�2P�Q�Q��H�l�+�+��G�[�)�)��)�+;�+�N�N�N��K��1�1��M�#3�4�4��.�0G�H�H��N�$5�6�6��H�l�+�+��M�#3�4�4��O�%7�8�8��&�(=�>�>�!
�$�'
�
�
�	
r+c��d}|�dd|���}|�|jd��|�|j|��dS)Nssome patch datar��PATCH�rr@����fetch�assertEqual�coder@)r(r@�responses   r)�test_patch_receives_payloadz4HTTPClientCommonTestCase.test_patch_receives_payload�sT��!���:�:�h�w�T�:�B�B��������,�,�,�������-�-�-�-�-r+c��|�d��}|�|jd��|�|jdd��|�|jd��|j�J�|�t
|j��d��|�d��}|�|jd��dS)	Nr�r�r#r$�Hello world!rz/hello?name=Bens
Hello Ben!)r�r�r�r^r@�request_timerI�r(r�s  r)�test_hello_worldz)HTTPClientCommonTestCase.test_hello_world�s����:�:�h�'�'��������,�,�,�����)�.�9�<�H�H�H�������8�8�8��$�0�0�0�����X�2�3�3�Q�7�7�7��:�:�/�0�0�������
�6�6�6�6�6r+c��g}|�d|j���}|�|dg��|�|j��dS)Nr���streaming_callbackr�)r��appendr��assertFalser@)r(�chunksr�s   r)�test_streaming_callbackz0HTTPClientCommonTestCase.test_streaming_callback�sS�����:�:�h�6�=�:�I�I������/�!2�3�3�3������'�'�'�'�'r+c��|�ddd���}|�|jd��|�|jd��dS)Nr��POSTzarg1=foo&arg2=barr�r�sPost arg1: foo, arg2: barr�r�s  r)�	test_postz"HTTPClientCommonTestCase.test_post�sQ���:�:�g�f�;N�:�O�O��������,�,�,������(D�E�E�E�E�Er+c��|�d��}|�|jd��g}|�d|j���}|�|ddg��|�|j��dS)Nr��asdfqwerr��asdf�qwer)r�r�r@r�r�)r(r�r�s   r)�test_chunkedz%HTTPClientCommonTestCase.test_chunked�s~���:�:�h�'�'��������4�4�4����:�:�h�6�=�:�I�I������'�7�!3�4�4�4������'�'�'�'�'r+c���t��\}}t|��5tj�fd���}t	j||����d|z��}|�����|j	d���j
�|�����ddd��dS#1swxYwYdS)Nc3��K�t|��}|�d��V�}d|vr��d��|�d�dd����V�|���dS)N�

�HTTP/1.�requires HTTP/1.xs7HTTP/1.1 200 OK
Transfer-Encoding: chunked

1
1
1
2
0

�
�
�r�
read_until�skipTestr>�replace�close��conn�address�stream�request_datar(s    �r)�accept_callbackzDHTTPClientCommonTestCase.test_chunked_close.<locals>.accept_callback�s������"�$����%+�%6�%6�{�%C�%C�C�C���\�1�1��M�M�"5�6�6�6��l�l�
��G��w���������������r+�http://127.0.0.1:%d/s12)
rrrrYr�add_accept_handlerr��rethrowr�r@�io_loop�remove_handler�fileno�r(�sock�portr��resps`    r)�test_chunked_closez+HTTPClientCommonTestCase.test_chunked_close�s���&�'�'�
��d�
�T�]�]�	7�	7�
�]�
�
�
�
��]�
�0
�&�t�_�=�=�=��:�:�4�t�;�<�<�D��L�L�N�N�N����T�Y��.�.�.��L�'�'����
�
�6�6�6�?	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s�B C�C�Cc�h�|�|�ddd���jd��dS)Nr��Aladdin�open sesame��
auth_username�
auth_password�"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==�r�r�r@r6s r)�test_basic_authz(HTTPClientCommonTestCase.test_basic_auth	sG������J�J��y�
�
�
�
��1�		
�	
�	
�	
�	
r+c�j�|�|�dddd���jd��dS)Nr�r�r��basic)r�r��	auth_moder�r�r6s r)�test_basic_auth_explicit_modez6HTTPClientCommonTestCase.test_basic_auth_explicit_modesN������J�J��'�+�!�	
�
�
�
�1�	
�	
�	
�	
�	
r+c���|�|�ddd���jd��tjdd��}|�|�d|d���jd	��dS)
Nr��testu123£r�sBasic dGVzdDoxMjPCow==�NFDujoséusəcrətsBasic am9zw6k6c8mZY3LJmXQ=)r�r�r@�unicodedata�	normalize)r(�usernames  r)�test_basic_auth_unicodez0HTTPClientCommonTestCase.test_basic_auth_unicodes�������J�J�w�f�G�J�L�L�Q�%�	
�	
�	
��(���9�9������J�J�w�h�j�J�Q�Q�V�)�	
�	
�	
�	
�	
r+c	��ttdd���5|�ttf��5|�ddddd�	��ddd��n#1swxYwYddd��dS#1swxYwYdS)
Nzuncaught exceptionF��requiredr�r�r�rTT)r�r�r��raise_error)rr�assertRaises�
ValueErrorrr�r6s r)�test_unsupported_auth_modez3HTTPClientCommonTestCase.test_unsupported_auth_mode,s���w� 4�u�
E�
E�
E�	�	��"�"�J�	�#:�;�;�
�
��
�
��"+�"/�$� $�����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s4�"A9�A!�A9�!A%	�%A9�(A%	�)A9�9A=�A=c��|�dd���}|�d|j��|�|jd�d����|�d��}|�d|j��|�|j�d����|�d	|j��dS)
Nz/countdown/2F��follow_redirects�.�Locationz/countdown/1r�z/countdown/0sZero)r�r�r��
assertTruer^�endswith�
effective_urlr@r�s  r)�test_follow_redirectz-HTTPClientCommonTestCase.test_follow_redirect:s����:�:�n�u�:�E�E������h�m�,�,�,�����(��4�=�=�n�M�M�N�N�N��:�:�n�-�-������h�m�,�,�,�����.�7�7��G�G�H�H�H�����(�-�0�0�0�0�0r+c�j�|�dd���}|�d|j��dS)Nr�Tr
rO�r�r�r�r�s  r)�test_redirect_without_locationz7HTTPClientCommonTestCase.test_redirect_without_locationDs8���:�:�:�T�:�R�R��
	
����h�m�,�,�,�,�,r+c�l�|�ddd���}|�|jd��dS)N�/redirect?url=/put&status=307�PUT�hellor��Put body: hello�r�r�r@r�s  r)�test_redirect_put_with_bodyz4HTTPClientCommonTestCase.test_redirect_put_with_bodyLsB���:�:�+�E���
�
��	
�����(:�;�;�;�;�;r+c�l�|�ddd���}|�|jd��dS)NrrT�r�allow_nonstandard_methodss
Put body: rr�s  r)�test_redirect_put_without_bodyz7HTTPClientCommonTestCase.test_redirect_put_without_bodyRsC���:�:�+��&*��
�
��
	
�����
�6�6�6�6�6r+c�4�dD]�}d|z}|�|dd���}|�d|j��dD]q}|�||d�	��}|d
vr)|�t|��|j���G|�|jt|��dg���r|�|d���}|�d
|j��|�d|j����dD]�}d}dD]B}|�||d�	��}|�|t
|j�����C|�|d���}|�d
|j��|�d|j����dS)N)rOri/z$/redirect?url=/all_methods&status=%dr�r+r�sGET)�GET�OPTIONSr�DELETETr )rOr�HEAD�rr�)i3i4z%/redirect?url=/all_methods&status=307)r$r%r�rr&)r�r�r@r�assertInr�r)r(rFrr�rs     r)�test_method_after_redirectz3HTTPClientCommonTestCase.test_method_after_redirect[s���%�	-�	-�F�8�6�A�C��:�:�c�&�s�:�;�;�D����V�T�Y�/�/�/�>�
E�
E���z�z�#�f�PT�z�U�U���Z�'�'��$�$�T�&�\�\�4�9�=�=�=�=��M�M�$�)�d�6�l�l�F�-C�D�D�D�D��:�:�c�&�:�1�1�D����S�$�)�,�,�,����S�$�)�,�,�,�,�!�	-�	-�F�9�C�E�
@�
@���z�z�#�f�PT�z�U�U��� � ���D�I�)>�)>�?�?�?�?��:�:�c�&�:�1�1�D����S�$�)�,�,�,����S�$�)�,�,�,�,�	-�	-r+c���|�d���dd��}|�|��}|�dt	jd��z|j��dS)Nr�zhttp://zhttp://me:secret@sBasic s	me:secret)�get_urlr�r�r��base64�	b64encoder@)r(rr�s   r)�test_credentials_in_urlz0HTTPClientCommonTestCase.test_credentials_in_urlysa���l�l�7�#�#�+�+�I�7J�K�K���:�:�c�?�?������V�%5�l�%C�%C�C�X�]�S�S�S�S�Sr+c�X�d}tjd��}|�dd|ddi���}|�|jdd	��|�|jt
|����|�dd|ddi���}|�|jdd
��|�|j|��|�dd|ddid���}|�|jdd
��|�|j|��dS)
N�ése9r�r�r#zapplication/blah)rr@r^rs�2�1�foo)rr@r^�
user_agent)�binascii�a2b_hexr�r�r^r@r)r(�unicode_body�	byte_bodyr�s    r)�test_body_encodingz+HTTPClientCommonTestCase.test_body_encoding~sW�����$�U�+�+�	��:�:����#�%7�8�	�
�
��	
����)�*:�;�S�A�A�A�������\�(:�(:�;�;�;��:�:����#�%7�8�	�
�
��	
����)�*:�;�S�A�A�A������	�2�2�2��:�:����#�%7�8���
�
��	
����)�*:�;�S�A�A�A������	�2�2�2�2�2r+c��|�d��}|�t|j��t��|�t|jd��t��|�t|j��t��|�t|j	��t��dS)Nr�r#)
r�r��typer@�bytesr^�strr�rIrr�s  r)�
test_typesz#HTTPClientCommonTestCase.test_types�s����:�:�h�'�'������h�m�,�,�e�4�4�4�����h�.�~�>�?�?��E�E�E�����h�m�,�,�c�2�2�2�����h�4�5�5�s�;�;�;�;�;r+c��|�ddddi���}|�|jdd��|�|jd��|�t|j��d��t
jd	|j�
��}|�|�	��d��dS)Nr�FzAccept-Encodingr�)�decompress_responser^r�r��"�r)�mode�fileobj)
r�r�r^�assertNotEqualr@�lenr��GzipFile�buffer�read)r(r��fs   r)�	test_gzipz"HTTPClientCommonTestCase.test_gzip�s����:�:��%�:K�V�9T��
�
��	
����)�*<�=�v�F�F�F����H�M�;�7�7�7�	
����X�]�+�+�R�0�0�0��M�s�H�O�<�<�<����������;�/�/�/�/�/r+c�0�ttdd���5	|�d��}|�|jd��|�|jdd�d��n#t$rYnwxYwddd��dS#1swxYwYdS)Nz*(Uncaught exception|Exception in callback)Frr�r��sHello World 0
)rrr�r�r�r@rr�s  r)�test_invalid_gzipz*HTTPClientCommonTestCase.test_invalid_gzip�s�����A�E�
�
�
�	�	�
��:�:�o�6�6��� � ����4�4�4�� � ���s��s�!3�5G�H�H�H�H���
�
�
���
����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s5�B�AA.�-B�.
A;�8B�:A;�;B�B�Bc������g�i�g���fd�}���fd�}��d||�����t���d������dd�����dd	g��dS)
Nc�"��|�d��rdS|�d��r��|��dS|dkrD|�dd��\}}|����|���<dSdS)NzHTTP/1.1 101zHTTP/z
�:rc)�
startswithr��split�strip�lower)�header_liner�r��
first_liner^s   ��r)�header_callbackzFHTTPClientCommonTestCase.test_header_callback.<locals>.header_callback�s�����%�%�n�5�5�
/����'�'��0�0�
/��!�!�+�.�.�.�.�.���&�&�"�(�(��a�0�0���1�%&�W�W�Y�Y�����	�	�"�"�"�'�&r+c�j�����dd����|��dS)Nzcontent-typeztext/html; charset=UTF-8)r�r�)�chunkr�r^r(s ���r)r�zIHTTPClientCommonTestCase.test_header_callback.<locals>.streaming_callback�s9���
���W�^�4�6P�Q�Q�Q��M�M�%� � � � � r+r�)rYr�rcrzHTTP/[0-9]\.[0-9] 200.*
r�r�)r�r�rG�assertRegex)r(rYr�r�rXr^s`  @@@r)�test_header_callbackz-HTTPClientCommonTestCase.test_header_callback�s��������
�����	/�	/�	/�	/�	/�	/�	!�	!�	!�	!�	!�	!�	!�	
�
�
��+�1�	�	
�	
�	
�
	
����Z���!�Z�8�8�8�����A��(F�G�G�G�����'�7�!3�4�4�4�4�4r+c#�JK�tdd���}|j�d|���}	|�|�d����V�}|�|jd��|���dS#|���wxYw)N�TestDefaultUserAgentF)r5�
allow_ipv6T)�force_instance�defaultsr�sTestDefaultUserAgent)�dict�http_client�	__class__r�r,r�r@r�)r(rb�clientr�s    r)�test_configure_defaultsz0HTTPClientCommonTestCase.test_configure_defaults�s������#9�e�L�L�L���!�+�+�4�(�+�S�S��	�#�\�\�$�,�,�}�*E�*E�F�F�F�F�H����X�]�,C�D�D�D��L�L�N�N�N�N�N��F�L�L�N�N�N�N���s�AB�B"c���dD]c}ttfD]R}|��}||d<|�d|���}|�|jdd|j�d|�d|�����S�ddS)	N)�MyUserAgent�MyUserAgentrnr��r^rjz	response=z, value=z, container=)rcrr�r�r@)r(�value�	containerr^r�s     r)�test_header_typesz*HTTPClientCommonTestCase.test_header_types�s���
6�
	�
	�E�"�K�0�	
�	
�	�#�)�+�+��(-���%��z�z�-��z�A�A��� � ��I�"�N��y�y�y�%�%�%���4�����		
�
	�
	r+c�,��t��\}}t|��5tj�fd���}t	j||��	��d|z��}|�����|j	dd���j
�|�����n1#�j
�|�����wxYw	ddd��dS#1swxYwYdS)Nc3��K�t|��}|�d��V�}d|vr��d��|�d�dd����V�|���dS)Nr�r�r�s2HTTP/1.1 200 OK
X-XSS-Protection: 1;
	mode=block

r�r�r�r�s    �r)r�zIHTTPClientCommonTestCase.test_multi_line_headers.<locals>.accept_callbacks������!�$����%+�%6�%6�{�%C�%C�C�C���\�1�1��M�M�"5�6�6�6��l�l��
�G��w���
	�	�	�	�	��������r+r�zX-XSS-Protectionz
1; mode=block)
rrrrYrr�r�r�r�r^r�r�r�r�s`    r)�test_multi_line_headersz0HTTPClientCommonTestCase.test_multi_line_headerssM���&�'�'�
��d�
�T�]�]�	;�	;�
�]�
�
�
�
��]�
�"
�&�t�_�=�=�=�
;��z�z�"8�4�"?�@�@��������� � ���.@�!A�?�S�S�S���+�+�D�K�K�M�M�:�:�:�:����+�+�D�K�K�M�M�:�:�:�:����:�5	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s*�-D	�A
C
�-D	�
.C8�8D	�	D
�D
c#��K�|j�|�d��ddi���V�}|�|jd�d����dS)Nr�r�ubärrkr�)rdr�r,r�r@r�r�s  r)�test_header_encodingz-HTTPClientCommonTestCase.test_header_encoding"su�����)�/�/��L�L�+�,�,��x��0�
�
�
�
��	
�����	�(8�(8��(E�(E�F�F�F�F�Fr+c��|�d��}|�|jd��|�|jdd��dS)Nr�rrrs�42)r�r�r�r^r�s  r)�test_304_with_content_lengthz5HTTPClientCommonTestCase.test_304_with_content_length,sS��
�:�:�8�9�9��������,�,�,�����)�*:�;�T�B�B�B�B�Br+c#�K�|j�|�d����V�}|�|jd��dS�Nr�r��rdr�r,r�r@r�s  r)�test_future_interfacez.HTTPClientCommonTestCase.test_future_interface5sL�����)�/�/����X�0F�0F�G�G�G�G��������8�8�8�8�8r+c#�K�|�t��5}|j�|�d����V�ddd��n#1swxYwY|j�J�|jj�J�|�|jjd��|�|jjjd��dS�N�	/notfound�)	r	rrdr�r,�	exceptionr�r�r�)r(�contexts  r)�test_future_http_errorz/HTTPClientCommonTestCase.test_future_http_error:s����
�
�
�y�
)�
)�	D�W��"�(�(����k�)B�)B�C�C�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�� �,�,�,�� �)�5�5�5�����*�/��5�5�5�����*�3�8�#�>�>�>�>�>s�0A�A� Ac#�K�|j�|�d��d���V�}|�|jd��dS)Nr}F)rr~)rdr�r,r�r�r�s  r)�test_future_http_error_no_raisez8HTTPClientCommonTestCase.test_future_http_error_no_raiseCs^�����)�/�/��L�L��%�%�5�0�
�
�
�
��	
������,�,�,�,�,r+c#�~K�|�d��}|j�|��V�}|�|jj|��|�t|jt����|j�|j��V�}|�|j	d��dSrx)
r,rdr�r�r?rr�
isinstancer	r@)r(rr��	response2s    r)� test_reuse_request_from_responsez9HTTPClientCommonTestCase.test_reuse_request_from_responseJs������l�l�8�$�$���)�/�/��4�4�4�4������)�-�s�3�3�3����
�8�#3�[�A�A�B�B�B��*�0�0��1A�B�B�B�B�	�������9�9�9�9�9r+c#��K�|�d��}t|d���}|j�|��V�}|�|jd��|�ttf��5}t|d���}|j�|��V�ddd��n#1swxYwY|�	dt|j����dS)Nr�z	127.0.0.1��network_interfacer�znot-interface-or-ip)r,r	rdr�r�r�r	r
rr)r>r)r(rr?r�r�s     r)�test_bind_source_ipz,HTTPClientCommonTestCase.test_bind_source_ipWs �����l�l�8�$�$���c�[�A�A�A���)�/�/��8�8�8�8��������,�,�,�
�
�
�
�I�6�
7�
7�	2�7�!�#�9N�O�O�O�G��"�(�(��1�1�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	
�
�
�+�S��1B�-C�-C�D�D�D�D�Ds�.B;�;B?�B?c���dD]A}|�d|���}|�|jt|�����BdD]B}|�d|d���}|�|jt|�����C|�dd���}|�|jd��|�ddd	�
��}|�|jd��dS)N�r$r&r%r�r(�r�rr�r+r�r'r}Tr sOTHER)r�r�r@r)r(rr�s   r)�test_all_methodsz)HTTPClientCommonTestCase.test_all_methodscs���2�	:�	:�F��z�z�.��z�@�@�H����X�]�D��L�L�9�9�9�9�.�	:�	:�F��z�z�.��c�z�J�J�H����X�]�D��L�L�9�9�9�9��:�:�n�V�:�<�<��������,�,�,��:�:��7�d��
�
��	
������1�1�1�1�1r+c��dD]�}|�t��5}|�d|d���ddd��n#1swxYwY|�dt	|j����|�d|d���}|�|jd����dD]�}|�t��5}|�d|d	d�
��ddd��n#1swxYwY|�dt	|j����|dkr5|�d|d	dd�
��|�|jd����dS)Nr�r�T)rrzmust not be Noner r�r�r�)rr@rzmust be Noner$)rr@r!r)r	r
r�r)r>rr�r�)r(rr�r�s    r)�test_body_sanity_checksz0HTTPClientCommonTestCase.test_body_sanity_checksqs��.�	-�	-�F��"�"�:�.�.�
L�'��
�
�>�&�d�
�K�K�K�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L����
L�
L�
L�
L��M�M�,�c�'�2C�.D�.D�E�E�E��:�:��v�����D�
���T�Y��,�,�,�,�3�	1�	1�F��"�"�:�.�.�
�'��
�
�"�6��T�����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�M�M�.�#�g�.?�*@�*@�A�A�A������
�
�"�!� �.2� $������ � ���C�0�0�0��#	1�	1s#�A�A	�A	�	C/�/C3	�6C3	c��|�ddd���}|���|�|jd��dS)Nz/redirect?status=307&url=/putrshellor�r)r�r�r�r@r�s  r)�test_put_307z%HTTPClientCommonTestCase.test_put_307�sT���:�:�+�E���
�
��	�����������(:�;�;�;�;�;r+c��|�d��}|���|�|jdt	d����dS)Nz/set_header?k=foo&v=%E9r�r1)r�r�r�r^rr�s  r)�test_non_ascii_headerz.HTTPClientCommonTestCase.test_non_ascii_header�sR���:�:�7�8�8������������)�%�0�*�Y�2G�2G�H�H�H�H�Hr+c���tj��}|�d��}|���|�|jd��|�|jd��|j�J�|�t|j|z
��d��|j�	��D]/\}}|�
d|cxkodkncd|�d|�����0dS)Nr�rg�?z
time_info[z] out of bounds: )�timer�r��assertGreaterEqualr��
assertLess�
start_time�abs�	time_info�itemsr)r(r�r�r�r�s     r)�test_response_timesz,HTTPClientCommonTestCase.test_response_times�s���Y�[�[�
��:�:�h�'�'������������ 5�q�9�9�9�����-�s�3�3�3��"�.�.�.�����H�/�*�<�=�=�s�C�C�C��&�,�,�.�.�	V�	V�D�A�q��O�O�A��L�L�L�L�S�L�L�L�L��q�q�q�RS�RS�*T�U�U�U�U�	V�	Vr+c�4�|�dd���}|�|jd��|�dd���}|�|jd��|�ddd���}|�|jd��dS)Nr�r)�connect_timeoutr�)�request_timeout)r�r�rr�s  r)�test_zero_timeoutz*HTTPClientCommonTestCase.test_zero_timeout�s����:�:�h��:�:�:��������,�,�,��:�:�h��:�:�:��������,�,�,��:�:�h��1�:�M�M��������,�,�,�,�,r+c#�pK�|j�|�d����}|�|�����ttd��5}td��D]!}tj	d��V�|j
rn�"ddd��dS#1swxYwYdS)Nz/404z$Exception after Future was cancelled�drU)rdr�r,r�cancelrrr�rrX�logged_stack)r(�fut�elr�s    r)�test_error_after_cancelz0HTTPClientCommonTestCase.test_error_after_cancel�s�������$�$�T�\�\�&�%9�%9�:�:������
�
���%�%�%�
�w� F�
G�
G�	�2�
�3�Z�Z�
�
���i��o�o�%�%�%��?���E��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�,2B+�+B/�2B/N),r-r.r/r�r�rr�r�r�r�r�r�r�rrrrrr"r*r/r:r?rLrOr]rrgrnrqrsrvrzr�r�r�r�r�r�r�r�r�r�r�r0r+r)r�r��s�������
�
�
�..�.�.��	7�	7��\�	7�(�(�(�F�F�F�
(�(�(�#7�#7�#7�J
�
�
�	
�	
�	
�

�

�

����1�1�1�-�-�-�<�<�<�7�7�7�-�-�-�<T�T�T�
"3�"3�"3�H<�<�<�0�0�0�"���5�5�5�>����X�����";�;�;�@�G�G��X�G�C�C�C��9�9��X�9��?�?��X�?��-�-��X�-��
:�
:��X�
:��	E�	E��X�	E�2�2�2�1�1�1�`<�<�<�I�I�I�V�V�V�"-�-�-�����X���r+r�c�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)�RequestProxyTestc��ttdd���t����}|�|jd��dS)N�http://example.com/r4)r5)rr	rcr�r5�r(�proxys  r)�test_request_setz!RequestProxyTest.test_request_set�sI����-�%�@�@�@�$�&�&�
�
��	
����)�5�1�1�1�1�1r+c��ttd��td�����}|�|jd��dS)Nr�r4r�)rr	rcr�r�r�s  r)�test_default_setz!RequestProxyTest.test_default_set�sK����-�.�.��u�0M�0M�0M�
�
��	
����0�%�8�8�8�8�8r+c��ttdd���td�����}|�|jd��dS)Nr�r4)�
proxy_host�bar)rr	rcr�r�r�s  r)�
test_both_setzRequestProxyTest.test_both_set�sQ����-�%�@�@�@�$�RW�BX�BX�BX�
�
��	
����)�5�1�1�1�1�1r+c��ttd��t����}|�|jd��dS�Nr�)rr	rc�assertIsr�r�s  r)�test_neither_setz!RequestProxyTest.test_neither_set�s;���k�*?�@�@�$�&�&�I�I���
�
�e�)�4�0�0�0�0�0r+c���ttd��t����}|�t��5|jddd��dS#1swxYwYdSr�)rr	rcr	�AttributeErrorr4r�s  r)�test_bad_attributez#RequestProxyTest.test_bad_attribute�s����k�*?�@�@�$�&�&�I�I��
�
�
�~�
.�
.�	�	��I�I�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A� Ac�v�ttd��d��}|�|jd��dSr�)rr	r�r�r�s  r)�test_defaults_nonez#RequestProxyTest.test_defaults_none�s7���k�*?�@�@�$�G�G���
�
�e�)�4�0�0�0�0�0r+N)	r-r.r/r�r�r�r�r�r�r0r+r)r�r��sn������2�2�2�9�9�9�2�2�2�1�1�1����
1�1�1�1�1r+r�c��eZdZd�ZdS)�HTTPResponseTestCasec��ttd��dt�����}t|��}|�|�d����|�d|��dS)N�http://example.comr�)rIz
HTTPResponse(zcode=200)r
r	rr>rrSr))r(r��ss   r)�test_strzHTTPResponseTestCase.test_str�so����,�-�-�s�7�9�9�
�
�
��
��M�M��������_�5�5�6�6�6��
�
�j�!�$�$�$�$�$r+N)r-r.r/r�r0r+r)r�r��s#������%�%�%�%�%r+r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�SyncHTTPClientTestc�L����td����_tj���tj��fd������fd�}tj|����_�j�����	��t���_dS)NF)�make_currentc����t��\}�_tdtfg��}t	|���_�j�|������dS)N�/)rr�rrr�server�
add_socket�set)r��app�eventr(s  ��r)�init_serverz-SyncHTTPClientTest.setUp.<locals>.init_servers^���.�0�0�O�D�$�)���%6�7�8�9�9�C�$�S�/�/�D�K��K�"�"�4�(�(�(��I�I�K�K�K�K�Kr+c�n���j�����j���dSrj)�
server_ioloop�run_sync�start)r�r(s��r)r�z'SyncHTTPClientTest.setUp.<locals>.starts5�����'�'��4�4�4���$�$�&�&�&�&�&r+)�target)rr��	threading�EventrrY�Thread�
server_threadr��waitr
rd)r(r�r�r�s` @@r)�setUpzSyncHTTPClientTest.setUps������#��7�7�7�����!�!��	��	�	�	�	�	�
��	�	'�	'�	'�	'�	'�	'�'�-�U�;�;�;����� � �"�"�"�
�
�
����%�<�<����r+c�����fd�}�j�|���j����j����j�d���dS)Nc����j���tj�fd���}�j�|��dS)Nc3��K��j���V�td��D]}dV���j���dS)N�)r��close_all_connectionsr�r��stop)r�r(s �r)�	slow_stopzCSyncHTTPClientTest.tearDown.<locals>.stop_server.<locals>.slow_stop#s^������k�7�7�9�9�9�9�9��q�����A��E�E�E�E��"�'�'�)�)�)�)�)r+)r�r�rrYr��add_callback)r�r(s �r)�stop_serverz0SyncHTTPClientTest.tearDown.<locals>.stop_servers]����K�������]�
*�
*�
*�
*��]�
*�
��+�+�I�6�6�6�6�6r+T)�all_fds)r�r�r�r�rdr�)r(r�s` r)�tearDownzSyncHTTPClientTest.tearDowns���	7�	7�	7�	7�	7�&	
��'�'��4�4�4�����!�!�!����� � � ��� � �� �.�.�.�.�.r+c��d|j|fzS)Nzhttp://127.0.0.1:%d%s)r�)r(�paths  r)r,zSyncHTTPClientTest.get_url3s��&�$�)�T�):�:�:r+c��|j�|�d����}|�d|j��dS)Nr�r�ryr�s  r)�test_sync_clientz#SyncHTTPClientTest.test_sync_client6sB���#�)�)�$�,�,�s�*;�*;�<�<������(�-�8�8�8�8�8r+c��|�t��5}|j�|�d����ddd��n#1swxYwY|�|jjd��dSr|)r	rrdr�r,r�rr�)r(�	assertions  r)�test_sync_client_errorz)SyncHTTPClientTest.test_sync_client_error:s����
�
�y�
)�
)�	>�Y���"�"�4�<�<��#<�#<�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�����,�1�3�7�7�7�7�7s�.A�A�AN)r-r.r/r�r�r,r�r�r0r+r)r�r�s_������(�(�(�,/�/�/�2;�;�;�9�9�9�8�8�8�8�8r+r�c��eZdZd�ZdS)�SyncHTTPClientSubprocessTestc�$�tjtjddgtjtjdd���}|jr0td��tt|j����|jr|�	d��dSdS)Nz-czMfrom tornado.httpclient import HTTPClient; f = lambda: None; c = HTTPClient()Tr�)�stdout�stderr�check�timeoutzSTDOUT:z%subprocess produced unexpected output)
�
subprocess�run�sys�
executable�PIPE�STDOUTr��printr�fail)r(�procs  r)�test_destructor_logz0SyncHTTPClientSubprocessTest.test_destructor_logCs����~����_�
�
�?��$���

�

�

���;�	+��)�����*�T�[�)�)�*�*�*��;�	?��I�I�=�>�>�>�>�>�	?�	?r+N)r-r.r/r�r0r+r)r�r�Bs#������?�?�?�?�?r+r�c�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)�HTTPRequestTestCasec�f�tdddi���}|�|jddi��dS)Nr�r4r�rk)r	r�r^�r(r?s  r)�test_headersz HTTPRequestTestCase.test_headersas;���2�U�E�N�K�K�K�������5�%�.�9�9�9�9�9r+c�p�td��}ddi|_|�|jddi��dS)Nr�r��baz�r	r^r�rs  r)�test_headers_setterz'HTTPRequestTestCase.test_headers_setteres=���2�3�3�� �%�.��������5�%�.�9�9�9�9�9r+c�h�td��}d|_|�|ji��dS)Nr�rrs  r)�test_null_headers_setterz,HTTPRequestTestCase.test_null_headers_setterjs5���2�3�3����������"�-�-�-�-�-r+c�x�tdd���}|�|jtd����dS)Nr�r4)r@)r	r�r@rrs  r)�	test_bodyzHTTPRequestTestCase.test_bodyos9���2��?�?�?�������t�E�{�{�3�3�3�3�3r+c��td��}d|_|�|jtd����dS)Nr�r4)r	r@r�rrs  r)�test_body_setterz$HTTPRequestTestCase.test_body_setterss;���2�3�3����������t�E�{�{�3�3�3�3�3r+c��tj���}td|���}|�|jdt|��i��dS)Nr�)�if_modified_sincezIf-Modified-Since)�datetime�utcnowr	r�r^r)r(�	http_dater?s   r)�test_if_modified_sincez*HTTPRequestTestCase.test_if_modified_sincexsa���%�,�,�.�.�	��2�i�P�P�P������O�1�3C�I�3N�3N�O�	
�	
�	
�	
�	
r+N)	r-r.r/rrr
rrrr0r+r)rr`sn������:�:�:�:�:�:�
.�.�.�
4�4�4�4�4�4�

�
�
�
�
r+rc� �eZdZd�Zd�Zd�ZdS)�HTTPErrorTestCasec��td��}tj|��}|�||��|�|j|j��dS)N�)r�copy�assertIsNotr�r�)r(�e�e2s   r)�	test_copyzHTTPErrorTestCase.test_copy�sP���c�N�N��
�Y�q�\�\������B�����������)�)�)�)�)r+c��td��}|�t|��d��|�t|��d��dS)Nr�HTTP 403: Forbidden)rr�r>�repr)r(rs  r)�test_plain_errorz"HTTPErrorTestCase.test_plain_error�sM���c�N�N������Q���!6�7�7�7�����a���"7�8�8�8�8�8r+c�f�ttd��d��}|�t��5}|���ddd��n#1swxYwY|j}|�t|��d��|�t|��d��dS)Nr�rr)	r
r	r	rr�rr�r>r )r(r��cmrs    r)�test_error_with_responsez*HTTPErrorTestCase.test_error_with_response�s����K�(=�>�>��D�D��
�
�
�y�
)�
)�	�R��L�L�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��L������Q���!6�7�7�7�����a���"7�8�8�8�8�8s�A�A� AN)r-r.r/rr!r$r0r+r)rr�sA������*�*�*�9�9�9�
9�9�9�9�9r+r)Lr-r6�
contextlibrrr�r�r�iorr�r�r��typingr�unittest�tornado.escaperrr�tornador�tornado.httpclientr	r
rrr
�tornado.httpserverr�tornado.ioloopr�tornado.iostreamr�tornado.logrrr�tornado.testingrrrr�tornado.test.utilr�tornado.webrrr�tornado.httputilrrrr2r;rDrMrRr[r`rhrlrprxr|r�r�r�r��TestCaser�r�r�r�rrr0r+r)�<module>r5s���
�
�
�
�������������������������������������
�
�
�
�����
�
�
�
���������7�7�7�7�7�7�7�7�7�7���������������������*�)�)�)�)�)�!�!�!�!�!�!�%�%�%�%�%�%�(�(�(�(�(�(�(�(�������T�T�T�T�T�T�T�T�T�T�T�T�*�*�*�*�*�*�8�8�8�8�8�8�8�8�8�8�:�:�:�:�:�:�:�:�(�(�(�(�(��(�(�(�
�
�
�
�
�.�
�
�
�&�&�&�&�&��&�&�&�
�
�
�
�
�n�
�
�
������^���������>����;�;�;�;�;�.�;�;�;�
�����~����&�&�&�&�&�n�&�&�&�
Q�Q�Q�Q�Q�~�Q�Q�Q�

�
�
�
�
�n�
�
�
�&�&�&�&�&�>�&�&�&�H�H�H�H�H��H�H�H�"�"�"�"�"�~�"�"�"�
�
�
�
�
��
�
�
�E�E�E�E�E�N�E�E�E�q�q�q�q�q�0�q�q�q�h1�1�1�1�1�x�(�1�1�1�B%�%�%�%�%�8�,�%�%�%�<8�<8�<8�<8�<8��*�<8�<8�<8�~?�?�?�?�?�8�#4�?�?�?�<
�
�
�
�
�(�+�
�
�
�@9�9�9�9�9��)�9�9�9�9�9r+

Youez - 2016 - github.com/yon3zu
LinuXploit