a c @sddlmZmZmZmZmZddlmZmZm Z ddl m Z m Z m Z mZmZmZmZddlmZmZmZmZmZddlmZzddlmZWneyddlmZYn0eeedd d Zeeeed d d ZeeeedddZ GdddZ!dS))castListTypeUnion ValuesView) Connection NEED_DATAPAUSED)ConnectionClosedData EndOfMessageEventInformationalResponseRequestResponse)CLIENTCLOSEDDONE MUST_CLOSESERVER)Sentinel)Literal)connreturncCsBg}|}|ttfvrq>tt|}||t|turq>q|SN)Z next_eventr r rrappendtyper )r got_eventseventr ^/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/h11/tests/helpers.pyget_all_eventss    r")rdatarcCs||t|Sr) receive_datar")rr#r r r!receive_and_get#s r%) in_eventsrcCsg}|D]}t|tur,tt|jddd}|rt|dt|urPturnn,t|dj|j|dj|djd|d<q||q|S)NF)r# chunk_start chunk_end)rr bytesr#r'r(r)r&Z out_eventsrr r r!normalize_data_events*s (  r+c@sheZdZddddZeeedddZd ee e e e e fe e e e e dfedd d ZdS) ConnectionPairN)rcCs(tttttti|_tttti|_dSr)rrrrotherselfr r r!__init__?szConnectionPair.__init__cCs |jSr)rvaluesr.r r r!connsCszConnectionPair.connsmatch)role send_eventsexpectrc Cst|ts|g}d}d}|D]*}|j||}|dur>d}q||7}q|rb|j|j|||r||j|j|dt|j|j|}|dkr|}t|ts|g}||ksJ|S)NFTr3) isinstancelistrsendr-r$r") r/r4r5r6r#closedZ send_eventZnew_datarr r r!r:Hs(    zConnectionPair.send)r3)__name__ __module__ __qualname__r0propertyrrr2rrrrrrr*r:r r r r!r,>sr,N)"typingrrrrr _connectionrr r Z_eventsr r r rrrr_staterrrrrZ_utilrr ImportErrorZtyping_extensionsr"r*r%r+r,r r r r!s$