o
    ŻhJ"  ć                   @   s   d dl Z ddlmZ ddlT ddlT ddlmZmZmZ dd Zdd	 Z	d
d Z
dd ZeeeedeiZdd Zdd Zdd Zdd Zdd Zdd ZdS )é    Né   )ŚLocalProtocolError)Ś*)ŚConnectionStateŚ_SWITCH_UPGRADEŚ_SWITCH_CONNECTc                  C   s"  t  } | jttttiksJ |  tt” | jttttiksJ t	 
t” |  tt” W d    n1 s5w   Y  | jttttiksEJ |  tt” | jttttiksVJ |  tt” | jttttiksgJ |  tt” |  tt” | jttttiks~J |  tt” | jttttiksJ d S ©N)r   ŚstatesŚCLIENTŚIDLEŚSERVERŚprocess_eventŚRequestŚ	SEND_BODYŚSEND_RESPONSEŚpytestŚraisesr   ŚInformationalResponseŚResponseŚEndOfMessageŚDONEŚConnectionClosedŚ
MUST_CLOSEZCLOSED©Ścs© r   ś\/var/www/html/magazine_api/magazine_env/lib/python3.10/site-packages/h11/tests/test_state.pyŚtest_ConnectionState   s"   ’r   c                  C   sn   t  } |  tt” |  ”  |  tt” | jtttt	iksJ |  tt
” |  tt” | jttttiks5J d S r   )r   r   r
   r   Śprocess_keep_alive_disabledr   r	   r   r   r   r   r   r   r   r   Śtest_ConnectionState_keep_alive'   s   r   c                  C   sN   t  } |  tt” |  tt” | jt tu sJ |  ”  | jt tu s%J d S r   )	r   r   r
   r   r   r	   r   r   r   r   r   r   r   Ś'test_ConnectionState_keep_alive_in_DONE3   s   r    c                  C   s  t tfD ]} dD ]{}t }| | ” | tt” | tt” |jtt	t
tiks)J | |jv s0J |r=| t
t” |jr=J | tt” |rQ|jttt
t	iksPJ q|jttt
tiks\J | t
t” |jttt
tiksmJ | t
t” |jttt
t	iks~J |jrJ qqd S )N)TF)r   r   r   Śprocess_client_switch_proposalr   r
   r   ŚDatar	   r   r   r   Zpending_switch_proposalsr   r   r   ŚMIGHT_SWITCH_PROTOCOLr   )Zswitch_typeZ
deny_earlyr   r   r   r   Ś"test_ConnectionState_switch_denied>   s4   


’
’ä’r$   c                  C   s¼   t tfD ]W} t }| | ” | tt” | tt” |jtt	t
tiks%J | tt” |jttt
tiks6J | t
t” |jttt
tiksGJ | t
t|  | ” |jttt
tiks[J qd S r   )r   r   r   r!   r   r
   r   r"   r	   r   r   r   r   r#   r   Ś_response_type_for_switchŚSWITCHED_PROTOCOL)Zswitch_eventr   r   r   r   Ś-test_ConnectionState_protocol_switch_acceptedd   s0   

’
’
’ž’ķr'   c                  C   s¤   d t tfD ]J} t }| t ” | t” | tt” | tt” |jtt	t
tiks+J | t
t|  | ” | d u rD|jttt
tiksCJ q|jttt
tiksOJ qd S r   )r   r   r   r!   r   r
   r   r   r	   r#   r   r   r%   r   r   r&   )Śserver_switchr   r   r   r   Ś+test_ConnectionState_double_protocol_switch{   s&   


’ž’ņr)   c               	   C   s   g t fg tftgt ft gtffD ]3\} }t }| D ]}| |” q| tt” t t	” | t
t|” W d    n1 s>w   Y  qd S r   )r   r   r   r!   r   r
   r   r   r   r   r   r   )Zclient_switchesr(   r   Zclient_switchr   r   r   Ś1test_ConnectionState_inconsistent_protocol_switch   s   ü’ör*   c                  C   s   t  } |  t” |  tt” |  ”  |  tt” | jtt	t
tiks#J |  tt” | jttt
tiks4J |  t
t” | jttt
t	iksEJ d S r   )r   r!   r   r   r
   r   r   r"   r	   r   r   r   r   r#   r   r   r   r   r   r   Ś:test_ConnectionState_keepalive_protocol_switch_interaction   s   
r+   c                  C   sb  t  } t t” |  ”  W d    n1 sw   Y  |  tt” |  tt” t t” |  ”  W d    n1 s<w   Y  |  t	t
” |  t	t” |  ”  | jttt	tiks\J |  tt” |  ”  |  tt” |  t	t
” |  t	t” t t” |  ”  W d    n1 sw   Y  t  } |  tt” |  tt” |  tt” |  t	t
” |  t	t” t t” |  ”  W d    n1 sĘw   Y  t  } |  t” |  tt” |  tt” |  t	tt” t t” |  ”  W d    n1 sśw   Y  t  } |  t” |  tt” |  tt” |  t	t
” |  t	t” |  ”  | jttt	tiks/J d S r   )r   r   r   r   Zstart_next_cycler   r
   r   r   r   r   r	   r   r   r   r!   r   r   r   r   r   r   Śtest_ConnectionState_reuse°   s\   
’
’
’
’

’
r,   c                  C   sB   t  } t t” |  tt” W d    d S 1 sw   Y  d S r   )r   r   r   r   r   r   r   r   r   r   r   Śtest_server_request_is_illegalš   s   "’r-   )r   Z_utilr   Z_eventsŚ_stater   r   r   r   r   r    r$   r   r   r%   r'   r)   r*   r+   r,   r-   r   r   r   r   Ś<module>   s&    !ż@