o
    US`cą"  ć                   @   sģ   d dl Z ddlmZmZmZmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ dddZdd	d
ZdddZdddZeee
edeiZdddZdddZdddZ dddZ!dddZ"dddZ#dS )é    Né   )ŚConnectionClosedŚDataŚEndOfMessageŚEventŚInformationalResponseŚRequestŚResponse)Ś_SWITCH_CONNECTŚ_SWITCH_UPGRADEŚCLIENTŚCLOSEDŚConnectionStateŚDONEŚIDLEŚMIGHT_SWITCH_PROTOCOLŚ
MUST_CLOSEŚ	SEND_BODYŚSEND_RESPONSEŚSERVERŚSWITCHED_PROTOCOL)ŚLocalProtocolErrorŚreturnc                  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   Śstatesr   r   r   Śprocess_eventr   r   r   ŚpytestŚraisesr   r   r	   r   r   r   r   r   ©Ścs© r    ś?/usr/local/lib/python3.10/dist-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_DONEK   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   r   r   r   r   r   Zpending_switch_proposalsr	   r   r   r   r   )Zswitch_typeZ
deny_earlyr   r    r    r!   Ś"test_ConnectionState_switch_deniedW   s8   


ž
žą’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_switchr   )Zswitch_eventr   r    r    r!   Ś-test_ConnectionState_protocol_switch_accepted   s   
ņ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   N)$r   Z_eventsr   r   r   r   r   r   r	   Ś_stater
   r   r   r   r   r   r   r   r   r   r   r   r   Z_utilr   r"   r$   r%   r'   r(   r)   r+   r,   r-   r.   r/   r    r    r    r!   Ś<module>   s$    $<	

 

&ż




A