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_urllib2net.cpython-310.pyc
o

�9jD8�@sLddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddlZ
ddlZ
ddlZe�d�dd	�Zd
d�Ze�de
jvd
�Zee
jje
jj�ZGdd�de�Zeeejd�Zeeej d�Z!eeej d�Z"Gdd�dej#�Z$Gdd�dej#�Z%Gdd�dej#�Z&Gdd�dej#�Z'e(dkr�e�)�dSdS)�N)�support)�	os_helper)�
socket_helper)�ResourceDenied)�sanepathname2url�networkcOsNtd�D] }z
||i|��WS|y$}z|}WYd}~qd}~ww|�)N�)�range)�func�exc�args�kwargs�i�e�last_exc�r�+/usr/lib/python3.10/test/test_urllib2net.py�
_retry_thrices��rcs��fdd�}|S)Ncst��g|�Ri|��S�N)r)rr
�rr
rr�wrappedsz(_wrap_with_retry_thrice.<locals>.wrappedr)r
rrrrr�_wrap_with_retry_thricesr�TRAVISz%bpo-35411: skip FTP test on Travis CIc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�TransientResourcez�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dSr)r�attrs)�selfrr
rrr�__init__2s
zTransientResource.__init__cCs|Srr�rrrr�	__enter__6�zTransientResource.__enter__NcCs\|dur*t|j|�r,|j��D]\}}t||�sdSt||�|kr%dSqtd��dSdS)z�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).Nz%an optional resource is not available)�
issubclassrr�items�hasattr�getattrr)r�type_�value�	traceback�attr�
attr_valuerrr�__exit__9s
��zTransientResource.__exit__)NNN)�__name__�
__module__�__qualname__�__doc__rrr)rrrrr-s
r)�errnoc@seZdZdZdS)�	AuthTestsz&Tests urllib2 authentication features.N)r*r+r,r-rrrrr/Nsr/c@seZdZdd�ZdS)�CloseSocketTestcCsr|�tjj�tj}t�|�� t|�}|j	}|�
|j�|��|�
|j�Wd�dS1s2wYdSr)�
addCleanup�urllib�request�
urlcleanupr�
TEST_HTTP_URLr�transient_internet�_urlopen_with_retry�fp�assertFalse�closed�close�
assertTrue)r�url�response�sockrrr�
test_closews"�zCloseSocketTest.test_closeN)r*r+r,r@rrrrr0usr0c@sdeZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	e
�d
�dd��Zddd�Z
dd�ZdS)�OtherNetworkTestscCsdSr)�logging�	getLogger�
addHandler�
StreamHandler)rrB�loggerrrr�setUp�rzOtherNetworkTests.setUpcCs&dddtjjfg}|�||���dS)Nzftp://www.pythontest.net/READMEz*ftp://www.pythontest.net/non-existent-file)r2�error�URLError�
_test_urls�_extra_handlers)r�urlsrrr�test_ftp�s��zOtherNetworkTests.test_ftpc	Cs�tj}t|d�}z+|�d�|��dttj�|��ddt	j
jfg}|j||�
�dd�Wt�|�nt�|�w|�tt	jjd�dS)N�wz	hi there
zfile:zfile:///nonsensename/etc/passwdT)�retryz./relative_path/to/file)r�TESTFN�open�writer;r�os�path�abspathr2rHrIrJrK�remove�assertRaises�
ValueErrorr3�urlopen)rrP�frLrrr�	test_file�s

��zOtherNetworkTests.test_filecCs\d}t�|��tj�|�}tj�|�}|�|��d�Wd�dS1s'wYdS)Nz)http://www.pythontest.net/index.html#frag�rr6r2r3�RequestrY�assertEqual�geturl)r�urlwith_frag�req�resrrr�test_urlwithfrag��
�"�z"OtherNetworkTests.test_urlwithfragcCs\d}t�|��tj�|�}tj�|�}|�|��d�Wd�dS1s'wYdS)Nz*http://www.pythontest.net/redir/with_frag/z)http://www.pythontest.net/elsewhere/#fragr\)r�redirect_url_with_fragrarbrrr�test_redirect_url_withfrag�rdz,OtherNetworkTests.test_redirect_url_withfragcCs�tj}t�|��Ctj��}tj�|�}|�|�	��|�
|�|�|�	��|�|�d��|�
dd�|�
|�|�|�d�d�Wd�dS1sNwYdS)Nz
User-agentz
User-Agentz
Test-Agent)rr5rr6r2r3�build_openerr]r9�header_itemsrQr<�
has_header�
add_headerr^�
get_header)rr=�openerr3rrr�test_custom_headers�s


"�z%OtherNetworkTests.test_custom_headersz XXX: http://www.imdb.com is gonec	Cs�d}t�|��Dztj�|��}Wd�n1swYWnty.|�d�Ynw|�|�tj�|�}|��}|�|�Wd�dS1sNwYdS)Nzhttp://www.imdb.comzOurlopen failed for site not sending                            Connection:close)	rr6r2r3rYrX�failr<�read)r�URLrbrarrr�test_sites_no_connection_close�s���
"�z0OtherNetworkTests.test_sites_no_connection_closeTc
Cs�ddl}ddl}|�d�j}tjj|�j}|rt|tj	j
�}|D]�}|j|d���t|t
�r4|\}}	}
nd}	}
t�|���z	|||	tj�}Wn(tyo}z|
rdd|
||	t|�|f}
|�||
|
�n�WYd}~n`d}~wwzDt�8t�&t�|��}|dt|��Wd�n1s�wYWd�n1s�wYWd�n1s�wYWnty�td|tjd�Ynw|��Wd�n1s�wY|�d�Wd�n1s�wYq dS)	Nr�test_urllib2)r=z5Didn't get expected error(s) %s for %s %s, got %s: %sz
read %d bytesz
<timeout: %s>)�fileg�������?) �timerBrC�debugr2r3rgrQrrHrI�subTest�
isinstance�tuplerr6r�INTERNET_TIMEOUT�OSError�type�assertIsInstance�time_out�socket_peer_reset�ioerror_peer_resetro�len�TimeoutError�print�sys�stderrr;�sleep)rrL�handlersrOrtrBrurYr=ra�expected_errrZ�err�msg�bufrrrrJ�s`
����������������zOtherNetworkTests._test_urlscCs2g}tj��}|�|j�|�d�|�|�|S)N�)r2r3�CacheFTPHandlerr1�clear_cache�
setTimeout�append)rr��cfhrrrrKs


z!OtherNetworkTests._extra_handlersN)T)r*r+r,rG�skip_ftp_test_on_travisrMr[rcrfrm�unittest�skiprqrJrKrrrrrA�s	
-

'rAc@sheZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdZe	dd
��Z
e	dd��Ze	dd��Ze	dd��Z
dS)�TimeoutTestcCs|�tjj�dSr)r1r2r3r4rrrrrG*szTimeoutTest.setUpcCsp|�t���tj}tj|dd��t|�}|�|j	�|�|j
jj�
��Wd�dS1s1wYdS�N��timeout)�assertIsNone�socket�getdefaulttimeoutrr5rr6r7r1r;r8�raw�_sock�
gettimeout�rr=�urrr�test_http_basic.s"�zTimeoutTest.test_http_basicc
Cs�|�t���tj}t�|��1t�d�zt|�}|�	|j
�Wt�d�nt�d�w|�|jj
j��d�Wd�dS1sCwYdS�N�<)r�r�r�rr5rr6�setdefaulttimeoutr7r1r;r^r8r�r�r�r�rrr�test_http_default_timeout6s
"�z%TimeoutTest.test_http_default_timeoutc
Cs�|�t���tj}t�|��2t�d�zt|dd�}|�	|j
�Wt�d�nt�d�w|�|jjj
���Wd�dS1sDwYdS�Nr�r�)r�r�r�rr5rr6r�r7r1r;r8r�r�r�r�rrr�test_http_no_timeoutBs
"�z TimeoutTest.test_http_no_timeoutcCsdtj}t�|�� t|dd�}|�|j�|�|jj	j
��d�Wd�dS1s+wYdS)N�xr�)rr5rr6r7r1r;r^r8r�r�r�r�rrr�test_http_timeoutNs"�zTimeoutTest.test_http_timeoutzftp://www.pythontest.net/cCsp|�t���tj|jdd��t|j�}|�|j�|�|j	j	j
j���Wd�dS1s1wYdSr�)
r�r�r�rr6�FTP_HOSTr7r1r;r8r�r�r��rr�rrr�test_ftp_basicWs
"�zTimeoutTest.test_ftp_basicc
Cs�|�t���t�|j��3t�d�zt|j�}|�|j	�Wt�d�nt�d�w|�
|jjjj
��d�Wd�dS1sCwYdSr�)r�r�r�rr6r�r�r7r1r;r^r8r�r�r�r�rrr�test_ftp_default_timeout_s

"�z$TimeoutTest.test_ftp_default_timeoutc
Cs�|�t���t�|j��4t�d�zt|jdd�}|�|j	�Wt�d�nt�d�w|�|j
j
jj�
��Wd�dS1sDwYdSr�)r�r�r�rr6r�r�r7r1r;r8r�r�r�r�rrr�test_ftp_no_timeoutks
"�zTimeoutTest.test_ftp_no_timeoutcCsdt�|j��"t|jdd�}|�|j�|�|jjjj	�
�d�Wd�dS1s+wYdSr�)rr6r�r7r1r;r^r8r�r�r�r�rrr�test_ftp_timeoutws
"�zTimeoutTest.test_ftp_timeoutN)r*r+r,rGr�r�r�r�r�r�r�r�r�r�rrrrr�)s


r��__main__)*r.r��testr�test.supportrrr�test.test_urllib2rrSr��urllib.errorr2�urllib.requestr��requiresrr�skipIf�environr�r3rYrHrIr7�objectrrz�	ETIMEDOUTr}�
ECONNRESETr~r�TestCaser/r0rAr�r*�mainrrrr�<module>sB
	��'%V�

Youez - 2016 - github.com/yon3zu
LinuXploit