a c3@sUddlmZmZmZmZmZmZmZddlTddl m Z m Z gdZ Gddde e dZ Gd d d e e dZGd d d e e dZGd dde e dZGddde e dZGddde e dZGddde e dZGddde e dZGddde e dZGddde e dZGddde e dZGddde e dZGdd d e e dZeee eee eeeeeeeee ffee fffZe eeeeeieeeeeieeeieeeieeeieieieiieeeee eee feiee!ee ee!efee efeieeeeeieeeieeeieeeieieiiiZ"ee#d!<eeee ee feee ee ffZ$eefe eieefeeieefeeieefeeieefe eieefe eieefe eiiZ%e$e#d"<Gd#d$d$Z&d%S)&)castDictOptionalSetTupleTypeUnion)*)LocalProtocolErrorSentinel) CLIENTSERVERIDLE SEND_RESPONSE SEND_BODYDONE MUST_CLOSECLOSEDMIGHT_SWITCH_PROTOCOLSWITCHED_PROTOCOLERRORc@s eZdZdS)r N__name__ __module__ __qualname__rrW/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/h11/_state.pyr sr ) metaclassc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)rNrrrrrrsrc@s eZdZdS)_SWITCH_UPGRADENrrrrrrsrc@s eZdZdS)_SWITCH_CONNECTNrrrrrr sr EVENT_TRIGGERED_TRANSITIONSSTATE_TRIGGERED_TRANSITIONSc@seZdZddddZeeddddZdddd Zeedd d d Zdeeee e eedd ddZ eee ee e ee eeffddddZddddZddddZdS)ConnectionStateN)returncCs d|_t|_tttti|_dS)NT) keep_alivesetpending_switch_proposalsr rrstatesselfrrr__init__szConnectionState.__init__)roler$cCst|j|<|dSN)rr(!_fire_state_triggered_transitions)r*r,rrr process_errors zConnectionState.process_errorcCsd|_|dS)NF)r%r.r)rrrprocess_keep_alive_disabled sz+ConnectionState.process_keep_alive_disabled) switch_eventr$cCs|j||dSr-)r'addr.)r*r1rrrprocess_client_switch_proposals z.ConnectionState.process_client_switch_proposal)r, event_typeserver_switch_eventr$cCs|}|dur8|tusJ||jvr0td|||f}|durP|turPt|_||||tur|tuspJ|tttf| dS)Nz3Received server {} event without a pending proposal) rr'r formatResponser&!_fire_event_triggered_transitionsRequestr r.)r*r,r4r5Z _event_typerrr process_events"    zConnectionState.process_event)r,r4r$c Csj|j|}zt|||}Wn<tyZttt|}td|j||j|dYn0||j|<dS)Nz4can't handle event type {} when role={} and state={}) r(r!KeyErrorrrEventr r6r)r*r,r4stateZ new_staterrrr8-s  z1ConnectionState._fire_event_triggered_transitionscCst|j}|jr(|jttur(t|jt<|jsF|jtturFt|jt<|jsrttfD]}|j|turTt|j|<qT|jt|jtf}t |i}|j ||j|krdSqdSr-) dictr(r'r rrr%rrr"getupdate)r*Z start_statesr,Z joint_statechangesrrrr.>s         z1ConnectionState._fire_state_triggered_transitionscCsH|jttttikr"td|j|js,J|jr6Jtttti|_dS)Nz'not in a reusable state. self.states={}) r(r rrr r6r%r'rr)rrrstart_next_cyclefs   z ConnectionState.start_next_cycle)N)rrrr+rr r/r0r3r<rr:rrr8r.rBrrrrr#s"    (r#N)'typingrrrrrrrZ_eventsZ_utilr r __all__r rrrrrrrrrrrr r<ZEventTransitionTyper9ZConnectionClosedZDataZ EndOfMessager7ZInformationalResponser!__annotations__ZStateTransitionTyper"r#rrrrqs&*      !&