§
    ŸjDX  ã                   ó„   — d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZ dadadadadad„ Z G d	„ d
¦  «        Zd
gZdS )zc
HTTP/2 server connection implementation.

Uses the hyper-h2 library for HTTP/2 protocol handling.
é    )ÚBytesIOé   )Ú
HTTP2ErrorÚHTTP2ProtocolErrorÚHTTP2ConnectionErrorÚHTTP2NotAvailableÚHTTP2ErrorCode)ÚHTTP2Stream)ÚHTTP2RequestNc                  óŽ   — t           �dS 	 ddlma  ddlma ddlma ddl	m
a ddlma dS # t          $ r t!          ¦   «         ‚w xY w)z$Lazily import h2 library components.Nr   )Ú_h2Úh2.connectionÚ
connectionÚ	h2.configÚconfigÚ
_h2_configÚ	h2.eventsÚeventsÚ
_h2_eventsÚh2.exceptionsÚ
exceptionsÚ_h2_exceptionsÚh2.settingsÚsettingsÚ_h2_settingsÚImportErrorr   © ó    úf/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/gunicorn/http2/connection.pyÚ
_import_h2r       sš   € õ €Øˆð"Ø#Ð#Ð#Ð#Ð#Ð#Ø&Ð&Ð&Ð&Ð&Ð&Ø&Ð&Ð&Ð&Ð&Ð&Ø.Ð.Ð.Ð.Ð.Ð.Ø*Ð*Ð*Ð*Ð*Ð*Ð*Ð*øÝð "ð "ð "ÝÑ!Ô!Ð!ð"øøøs	   ‹+ «Ac                   ó¼   — e Zd ZdZdZd„ Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zdd„Zd„ Zdd„Zd d„Zd!d„Zd„ Zed„ ¦   «         Zd„ Zd„ ZdS )"ÚHTTP2ServerConnectionzÑHTTP/2 server-side connection handler.

    Manages the HTTP/2 connection state and multiplexed streams.
    This class wraps the h2 library and provides a higher-level
    interface for gunicorn workers.
    i   c                 ó‚  — t          ¦   «          || _        || _        || _        i | _        g | _        |j        | _        |j        | _	        |j
        | _        |j        | _        t                               dd¬¦  «        }t                                |¬¦  «        | _        t'          ¦   «         | _        d| _        d| _        dS )a.  Initialize an HTTP/2 server connection.

        Args:
            cfg: Gunicorn configuration object
            sock: SSL socket with completed handshake
            client_addr: Client address tuple (host, port)

        Raises:
            HTTP2NotAvailable: If h2 library is not installed
        Fzutf-8)Úclient_sideÚheader_encoding)r   N)r    ÚcfgÚsockÚclient_addrÚstreamsÚ_pending_requestsÚhttp2_initial_window_sizeÚinitial_window_sizeÚhttp2_max_concurrent_streamsÚmax_concurrent_streamsÚhttp2_max_frame_sizeÚmax_frame_sizeÚhttp2_max_header_list_sizeÚmax_header_list_sizer   ÚH2Configurationr   ÚH2ConnectionÚh2_connr   Ú_read_bufferÚ_closedÚ_initialized)Úselfr&   r'   r(   r   s        r   Ú__init__zHTTP2ServerConnection.__init__:   sÅ   € õ 	‰ŒˆàˆŒØˆŒ	Ø&ˆÔð ˆŒð "$ˆÔð $'Ô#@ˆÔ Ø&)Ô&FˆÔ#Ø!Ô6ˆÔØ$'Ô$BˆÔ!õ ×+Ò+ØØ#ð ,ñ 
ô 
ˆõ ×'Ò'¨vÐ'Ñ6Ô6ˆŒõ $™IœIˆÔð ˆŒØ!ˆÔÐÐr   c           
      ód  — | j         rdS | j                             t          j        j        | j        t          j        j        | j        t          j        j	        | j
        t          j        j        | j        i¦  «         | j                             ¦   «          |                      ¦   «          d| _         dS )z”Send initial HTTP/2 settings to client.

        Should be called after the SSL handshake completes and
        before processing any data.
        NT)r8   r5   Úupdate_settingsr   ÚSettingCodesÚMAX_CONCURRENT_STREAMSr.   ÚINITIAL_WINDOW_SIZEr,   ÚMAX_FRAME_SIZEr0   ÚMAX_HEADER_LIST_SIZEr2   Úinitiate_connectionÚ_send_pending_data©r9   s    r   rB   z)HTTP2ServerConnection.initiate_connectione   s£   € ð Ôð 	ØˆFð 	Œ×$Ò$ÝÔ%Ô<¸dÔ>YÝÔ%Ô9¸4Ô;SÝÔ%Ô4°dÔ6IÝÔ%Ô:¸DÔ<Uð	&
ñ 	ô 	ð 	ð 	Œ×(Ò(Ñ*Ô*Ð*Ø×ÒÑ!Ô!Ð!Ø ˆÔÐÐr   Nc                 óê  — |€L	 | j                              | j        ¦  «        }n+# t          t          f$ r}t          d|› �¦  «        ‚d}~ww xY w|s	d| _        g S 	 | j                             |¦  «        }�nµ# t          j
        $ rA}|                      t          j        ¬¦  «         t          t          |¦  «        ¦  «        ‚d}~wt          j        $ rA}|                      t          j        ¬¦  «         t          t          |¦  «        ¦  «        ‚d}~wt          j        $ rk}t'          |dd¦  «        }|�|                      |¬¦  «         n |                      t          j        ¬¦  «         t          t          |¦  «        ¦  «        ‚d}~wt          j        $ rA}|                      t          j        ¬¦  «         t          t          |¦  «        ¦  «        ‚d}~wt          j        $ rA}|                      t          j        ¬¦  «         t          t          |¦  «        ¦  «        ‚d}~ww xY wg }|D ].}|                      |¦  «        }|�|                     |¦  «         Œ/|                      ¦   «          |S )aA  Process received data and return completed requests.

        Args:
            data: Optional bytes to process. If None, reads from socket.

        Returns:
            list: List of HTTP2Request objects for completed requests

        Raises:
            HTTP2ConnectionError: On protocol or connection errors
        NzSocket read error: T©Ú
error_coderG   )r'   ÚrecvÚREAD_BUFFER_SIZEÚOSErrorÚIOErrorr   r7   r5   Úreceive_datar   ÚFlowControlErrorÚcloser	   ÚFLOW_CONTROL_ERRORr   ÚstrÚFrameTooLargeErrorÚFRAME_SIZE_ERRORÚInvalidSettingsValueErrorÚgetattrÚPROTOCOL_ERRORÚTooManyStreamsErrorÚREFUSED_STREAMÚProtocolErrorÚ_handle_eventÚappendrC   )r9   ÚdataÚer   rG   Úcompleted_requestsÚeventÚrequests           r   rL   z"HTTP2ServerConnection.receive_dataz   s„  € ð ˆ<ðFØ”y—~’~ dÔ&;Ñ<Ô<��øÝ�WÐ%ð Fð Fð FÝ*Ð+DÀÐ+DÐ+DÑEÔEÐEøøøøðFøøøð ð 	àˆDŒLØˆIð	-Ø”\×.Ò.¨tÑ4Ô4ˆF‰FøÝÔ.ð 	-ð 	-ð 	-à�JŠJ¥.Ô"CˆJÑDÔDÐDÝ$¥S¨¡V¤VÑ,Ô,Ð,øøøøÝÔ0ð 	-ð 	-ð 	-à�JŠJ¥.Ô"AˆJÑBÔBÐBÝ$¥S¨¡V¤VÑ,Ô,Ð,øøøøÝÔ7ð 		-ð 		-ð 		-õ !  L°$Ñ7Ô7ˆJØÐ%Ø—
’
 j�
Ñ1Ô1Ð1Ð1à—
’
¥nÔ&C�
ÑDÔDÐDÝ$¥S¨¡V¤VÑ,Ô,Ð,øøøøÝÔ1ð 	-ð 	-ð 	-à�JŠJ¥.Ô"?ˆJÑ@Ô@Ð@Ý$¥S¨¡V¤VÑ,Ô,Ð,øøøøÝÔ+ð 	-ð 	-ð 	-à�JŠJ¥.Ô"?ˆJÑ@Ô@Ð@Ý$¥S¨¡V¤VÑ,Ô,Ð,øøøøð	-øøøð  ÐØð 	3ð 	3ˆEØ×(Ò(¨Ñ/Ô/ˆGØÐ"Ø"×)Ò)¨'Ñ2Ô2Ð2øð 	×ÒÑ!Ô!Ð!à!Ð!s]   „$ ¤AµAÁAÁA7 Á7H)Â<CÃH)Ã<DÄH)Ä"A&FÆH)Æ<GÇH)Ç(<H$È$H)c                 ó
  — t          |t          j        ¦  «        r|                      |¦  «        S t          |t          j        ¦  «        r|                      |¦  «        S t          |t          j        ¦  «        r|                      |¦  «        S t          |t          j        ¦  «        r|  	                    |¦  «         nÅt          |t          j
        ¦  «        rnªt          |t          j        ¦  «        r|                      |¦  «         nzt          |t          j        ¦  «        rn_t          |t          j        ¦  «        r|                      |¦  «         n/t          |t          j        ¦  «        r|                      |¦  «        S dS )z¨Handle a single h2 event.

        Args:
            event: h2 event object

        Returns:
            HTTP2Request if a request is complete, None otherwise
        N)Ú
isinstancer   ÚRequestReceivedÚ_handle_request_receivedÚDataReceivedÚ_handle_data_receivedÚStreamEndedÚ_handle_stream_endedÚStreamResetÚ_handle_stream_resetÚWindowUpdatedÚPriorityUpdatedÚ_handle_priority_updatedÚSettingsAcknowledgedÚConnectionTerminatedÚ_handle_connection_terminatedÚTrailersReceivedÚ_handle_trailers_received©r9   r^   s     r   rY   z#HTTP2ServerConnection._handle_event¼   sa  € õ �e�ZÔ7Ñ8Ô8ð 	9Ø×0Ò0°Ñ7Ô7Ð7å˜�zÔ6Ñ7Ô7ð 	9Ø×-Ò-¨eÑ4Ô4Ð4å˜�zÔ5Ñ6Ô6ð 	9Ø×,Ò,¨UÑ3Ô3Ð3å˜�zÔ5Ñ6Ô6ð 	9Ø×%Ò% eÑ,Ô,Ð,Ð,å˜�zÔ7Ñ8Ô8ð 	9Øå˜�zÔ9Ñ:Ô:ð 
	9Ø×)Ò)¨%Ñ0Ô0Ð0Ð0å˜�zÔ>Ñ?Ô?ð 	9Øå˜�zÔ>Ñ?Ô?ð 	9Ø×.Ò.¨uÑ5Ô5Ð5Ð5å˜�zÔ:Ñ;Ô;ð 	9Ø×1Ò1°%Ñ8Ô8Ð8àˆtr   c                 ó„   — |j         }|j        }t          || ¦  «        }|| j        |<   |                     |d¬¦  «         dS )z{Handle RequestReceived event (HEADERS frame).

        Args:
            event: RequestReceived event with headers
        F©Ú
end_streamN)Ú	stream_idÚheadersr
   r)   Úreceive_headers)r9   r^   rv   rw   Ústreams        r   rc   z.HTTP2ServerConnection._handle_request_receivedâ   sP   € ð ”Oˆ	Ø”-ˆõ ˜Y¨Ñ-Ô-ˆØ"(ˆŒ�YÑð 	×Ò˜w°5ÐÑ9Ô9Ð9Ð9Ð9r   c                 óú  — |j         }|j        }| j                             |¦  «        }|€dS |                     |d¬¦  «         t          |¦  «        dk    r¤	 | j                             t          |¦  «        |¬¦  «         | j                             t          |¦  «        d¬¦  «         |                      ¦   «          n<# t          t          j        f$ r# |                      t          j        ¬¦  «         Y nw xY wdS )z¶Handle DataReceived event.

        Args:
            event: DataReceived event with body data

        Returns:
            None (request completion handled by StreamEnded)
        NFrt   r   )rv   rF   )rv   r[   r)   ÚgetrL   Úlenr5   Úincrement_flow_control_windowrC   Ú
ValueErrorr   rM   rN   r	   rO   )r9   r^   rv   r[   ry   s        r   re   z+HTTP2ServerConnection._handle_data_receivedó   s  € ð ”Oˆ	ØŒzˆà”×!Ò! )Ñ,Ô,ˆØˆ>à�4à×Ò˜D¨UÐÑ3Ô3Ð3õ ˆt‰9Œ9�qŠ=ˆ=ð	Ià”×:Ò:½3¸t¹9¼9ÐPYÐ:ÑZÔZÐZà”×:Ò:½3¸t¹9¼9ÐPTÐ:ÑUÔUÐUà×'Ò'Ñ)Ô)Ð)Ð)øÝ¥Ô ?Ð@ð Ið Ið Ià—
’
¥nÔ&G�
ÑHÔHÐHÐHÐHðIøøøð ˆts   ÁA&B? Â?6C8Ã7C8c                 óÞ   — |j         }| j                             |¦  «        }|€dS d|_        d|_        |j        r|j                             ¦   «          t          || j        | j	        ¦  «        S )z›Handle StreamEnded event.

        Args:
            event: StreamEnded event

        Returns:
            HTTP2Request for the completed request
        NT)
rv   r)   r{   Úrequest_completeÚ_body_completeÚ_body_eventÚsetr   r&   r(   ©r9   r^   rv   ry   s       r   rg   z*HTTP2ServerConnection._handle_stream_ended  su   € ð ”Oˆ	Ø”×!Ò! )Ñ,Ô,ˆàˆ>Ø�4ð
 #'ˆÔØ $ˆÔØÔð 	%ØÔ×"Ò"Ñ$Ô$Ð$õ ˜F D¤H¨dÔ.>Ñ?Ô?Ð?r   c                 ó„   — |j         }| j                             |¦  «        }|�|                     |j        ¦  «         dS dS )ziHandle StreamReset event (RST_STREAM frame).

        Args:
            event: StreamReset event
        N)rv   r)   r{   ÚresetrG   r„   s       r   ri   z*HTTP2ServerConnection._handle_stream_reset/  sI   € ð ”Oˆ	Ø”×!Ò! )Ñ,Ô,ˆàÐØ�LŠL˜Ô)Ñ*Ô*Ð*Ð*Ð*ð Ðr   c                 ó   — d| _         dS )zwHandle ConnectionTerminated event (GOAWAY frame).

        Args:
            event: ConnectionTerminated event
        TN©r7   rr   s     r   ro   z3HTTP2ServerConnection._handle_connection_terminated<  s   € ð ˆŒˆˆr   c                 ó¶   — |j         }| j                             |¦  «        }|€dS |                     |j        ¦  «         t          || j        | j        ¦  «        S )z¾Handle TrailersReceived event.

        Args:
            event: TrailersReceived event with trailer headers

        Returns:
            HTTP2Request if this completes the request
        N)rv   r)   r{   Úreceive_trailersrw   r   r&   r(   r„   s       r   rq   z/HTTP2ServerConnection._handle_trailers_receivedE  sY   € ð ”Oˆ	Ø”×!Ò! )Ñ,Ô,ˆàˆ>Ø�4à×Ò ¤Ñ.Ô.Ð.õ ˜F D¤H¨dÔ.>Ñ?Ô?Ð?r   c                 óš   — | j                              |j        ¦  «        }|�)|                     |j        |j        |j        ¬¦  «         dS dS )z‚Handle PriorityUpdated event (PRIORITY frame).

        Args:
            event: PriorityUpdated event with priority info
        N)ÚweightÚ
depends_onÚ	exclusive)r)   r{   rv   Úupdate_priorityrŒ   r�   rŽ   )r9   r^   ry   s      r   rl   z.HTTP2ServerConnection._handle_priority_updatedY  s`   € ð ”×!Ò! %¤/Ñ2Ô2ˆØÐØ×"Ò"Ø”|Ø Ô+Øœ/ð #ñ ô ð ð ð ð Ðr   c                 ó¢  — |dk     s|dk    rt          d|› �¦  «        ‚| j                             |¦  «        }|€t          d|› d�¦  «        ‚dt          |¦  «        fg}|D ];\  }}|                     |                     ¦   «         t          |¦  «        f¦  «         Œ<| j                             ||d¬	¦  «         |                      ¦   «          dS )
aÆ  Send an informational response (1xx) on a stream.

        This is used for 103 Early Hints and other 1xx responses.
        Informational responses are sent before the final response
        and do not end the stream.

        Args:
            stream_id: The stream ID
            status: HTTP status code (100-199)
            headers: List of (name, value) header tuples

        Raises:
            HTTP2Error: If status is not in 1xx range
        éd   éÈ   zInvalid informational status: NzStream z
 not foundú:statusFrt   )	r   r)   r{   rP   rZ   Úlowerr5   Úsend_headersrC   )r9   rv   Ústatusrw   ry   Úresponse_headersÚnameÚvalues           r   Úsend_informationalz(HTTP2ServerConnection.send_informationalg  sí   € ð �CŠ<ˆ<˜6 Sš=˜=ÝÐF¸fÐFÐFÑGÔGÐGà”×!Ò! )Ñ,Ô,ˆØˆ>ÝÐ< yÐ<Ð<Ð<Ñ=Ô=Ð=ð '­¨F©¬Ð4Ð5ÐØ"ð 	@ð 	@‰KˆD�%à×#Ò# T§Z¢Z¡\¤\µ3°u±:´:Ð$>Ñ?Ô?Ð?Ð?ð 	Œ×!Ò! )Ð-=È%Ð!ÑPÔPÐPØ×ÒÑ!Ô!Ð!Ð!Ð!r   c                 óz  — | j                              |¦  «        }|€dS dt          |¦  «        fg}|D ];\  }}|                     |                     ¦   «         t          |¦  «        f¦  «         Œ<|du pt          |¦  «        dk    }		 | j                             |||	¬¦  «         |                     ||	¬¦  «         |                      ¦   «          |r+t          |¦  «        dk    r|  	                    ||d¬¦  «         dS # t          j        $ r- |                     ¦   «          |                      |¦  «         Y dS w xY w)a©  Send a response on a stream.

        Args:
            stream_id: The stream ID to respond on
            status: HTTP status code (int)
            headers: List of (name, value) header tuples
            body: Optional response body bytes

        Raises:
            HTTP2Error: If stream not found or in invalid state

        Returns:
            bool: True if response sent, False if stream was already closed
        NFr“   r   rt   T)r)   r{   rP   rZ   r”   r|   r5   r•   rC   Ú	send_datar   ÚStreamClosedErrorrN   Úcleanup_stream)
r9   rv   r–   rw   Úbodyry   r—   r˜   r™   ru   s
             r   Úsend_responsez#HTTP2ServerConnection.send_response‡  s[  € ð ”×!Ò! )Ñ,Ô,ˆØˆ>à�5ð '­¨F©¬Ð4Ð5ÐØ"ð 	@ð 	@‰KˆD�%à×#Ò# T§Z¢Z¡\¤\µ3°u±:´:Ð$>Ñ?Ô?Ð?Ð?à˜T�\Ð3¥S¨¡Y¤Y°!¢^ˆ
ð	àŒL×%Ò% iÐ1AÈjÐ%ÑYÔYÐYØ×ÒÐ 0¸ZÐÑHÔHÐHØ×#Ò#Ñ%Ô%Ð%ð ð A�˜D™	œ	 Aš˜Ø—’˜y¨$¸4�Ñ@Ô@Ð@Ø�4øÝÔ/ð 	ð 	ð 	à�LŠL‰NŒNˆNØ×Ò 	Ñ*Ô*Ð*Ø�5�5ð		øøøs   ÂA5C> Ã>8D:Ä9D:c                 óÀ  — ddl }d}	 |                     ¦   «         }|                     | j        |j        ¦  «         n# t
          t          f$ r Y dS w xY wd}	 t          |¦  «        D �]-}| j         	                    |¦  «        }|dk    r|} �n!| 
                    d¬¦  «        }|rí	 | j                             | j        ¦  «        }	n## t          t          t          j        f$ r Y  nÉw xY w|	s	d| _         nº	 | j                             |	¦  «        }
n# t          j        $ r Y  nŒw xY w|
D ]Q}t'          |t(          j        ¦  «        r|j        |k    rd} n=Œ,t'          |t(          j        ¦  «        rd| _        d} nŒR|                      ¦   «          �Œ+ n�Œ/| j         	                    |¦  «        }|                     ¦   «          n# |                     ¦   «          w xY w|S )z‹Wait for flow control window to become positive.

        Returns:
            int: Available window size, or -1 if waiting failed
        r   Né2   éÿÿÿÿgš™™™™™¹?)ÚtimeoutT)Ú	selectorsÚDefaultSelectorÚregisterr'   Ú
EVENT_READÚ	TypeErrorr~   Úranger5   Úlocal_flow_control_windowÚselectrH   rI   rJ   rK   r   rX   r7   rL   ra   r   rh   rv   rn   rC   rN   )r9   rv   r¥   Úmax_wait_attemptsÚselÚresultÚ_Ú	availableÚreadyÚincomingr   r^   s               r   Ú_wait_for_flow_control_windowz3HTTP2ServerConnection._wait_for_flow_control_window³  sA  € ð 	ÐÐÐàÐð	Ø×+Ò+Ñ-Ô-ˆCØ�LŠL˜œ IÔ$8Ñ9Ô9Ð9Ð9øÝ�:Ð&ð 	ð 	ð 	à�2�2ð	øøøð ˆð%	ÝÐ,Ñ-Ô-ð "Kñ "K�Ø œL×BÒBÀ9ÑMÔM�	Ø˜q’=�=Ø&�FØ‘EàŸ
š
¨3˜
Ñ/Ô/�Øð ðØ#'¤9§>¢>°$Ô2GÑ#HÔ#H˜˜øÝ#¥W­nÔ.JÐKð ð ð Ø˜˜ðøøøà#ð Ø'+˜œØ˜ðØ!%¤×!:Ò!:¸8Ñ!DÔ!D˜˜øÝ)Ô7ð ð ð Ø˜˜ðøøøà!'ð !ð !˜Ý% e­ZÔ-CÑDÔDð "Ø$œ°)Ò;Ð;Ø)+ Ø % ð  <õ (¨­zÔ/NÑOÔOð "Ø+/˜DœLØ%'˜FØ!˜Eð"ð
 ×/Ò/Ñ1Ô1Ð1Ù Ø�Eñ1ð6 œ×?Ò?À	ÑJÔJ�à�IŠI‰KŒKˆKˆKøˆC�IŠI‰KŒKˆKˆKøøøàˆse   ˆ4= ½AÁAÁAG Â(CÃG ÃC(Ã$G Ã'C(Ã(G Ã7DÄG ÄD%Ä!G Ä$D%Ä%BG ÇGFc                 óö  — | j                              |¦  «        }|€dS |}	 |ró| j                             |¦  «        }t	          || j        t          |¦  «        ¦  «        }|dk    rT|                      ¦   «          |                      |¦  «        }|dk    rdS t	          || j        t          |¦  «        ¦  «        }|d|…         }||d…         }|ot          |¦  «        dk    }	| j         	                    |||	¬¦  «         |                      ¦   «          |°ó| 	                    ||¬¦  «         dS # t          j        t          j        f$ r- |                     ¦   «          |                      |¦  «         Y dS w xY w)a  Send data on a stream.

        Args:
            stream_id: The stream ID
            data: Body data bytes
            end_stream: Whether this ends the stream

        Returns:
            bool: True if data sent, False if stream was already closed
        NFr   rt   T)r)   r{   r5   r«   Úminr0   r|   rC   r´   rœ   r   r�   rM   rN   rž   )
r9   rv   r[   ru   ry   Údata_to_sendr±   Ú
chunk_sizeÚchunkÚis_finals
             r   rœ   zHTTP2ServerConnection.send_dataí  s˜  € ð ”×!Ò! )Ñ,Ô,ˆØˆ>Ø�5àˆð	Øð *Ø œL×BÒBÀ9ÑMÔM�	Ý  ¨DÔ,?ÅÀ\ÑARÔARÑSÔS�
à ’?�?à×+Ò+Ñ-Ô-Ð-Ø $× BÒ BÀ9Ñ MÔ M�IØ  A’~�~Ø$˜uÝ!$ Y°Ô0CÅSÈÑEVÔEVÑ!WÔ!W�Jà$ [ j [Ô1�Ø+¨J¨K¨KÔ8�Ø%Ð@­#¨lÑ*;Ô*;¸qÒ*@�à”×&Ò& y°%ÀHÐ&ÑMÔMÐMØ×'Ò'Ñ)Ô)Ð)ð# ð *ð& ×Ò˜T¨jÐÑ9Ô9Ð9Ø�4øÝÔ0µ.Ô2QÐRð 	ð 	ð 	à�LŠL‰NŒNˆNØ×Ò 	Ñ*Ô*Ð*Ø�5�5ð		øøøs   ¢A4D0 ÂBD0 Ä0AE8Å7E8c                 ó4  — | j                              |¦  «        }|€dS |j        sdS g }|D ]e\  }}|                     ¦   «         }|                     d¦  «        rt          d|› d�¦  «        ‚|                     |t          |¦  «        f¦  «         Œf	 | j         	                    ||d¬¦  «         | 
                    |¦  «         |                      ¦   «          dS # t          j        $ r- |                     ¦   «          |                      |¦  «         Y dS w xY w)aë  Send trailing headers on a stream.

        Trailers are headers sent after the response body, commonly used
        for gRPC status codes, checksums, and timing information.

        Args:
            stream_id: The stream ID
            trailers: List of (name, value) trailer tuples

        Raises:
            HTTP2Error: If stream not found, headers not sent, or pseudo-headers used

        Returns:
            bool: True if trailers sent, False if stream was already closed
        NFú:zPseudo-header 'z' not allowed in trailersTrt   )r)   r{   Úresponse_headers_sentr”   Ú
startswithr   rZ   rP   r5   r•   Úsend_trailersrC   r   r�   rN   rž   )r9   rv   Útrailersry   Útrailer_headersr˜   r™   Úlnames           r   r¿   z#HTTP2ServerConnection.send_trailers  s@  € ð  ”×!Ò! )Ñ,Ô,ˆØˆ>à�5ØÔ+ð 	à�5ð ˆØ#ð 	8ð 	8‰KˆD�%Ø—J’J‘L”LˆEØ×Ò Ñ$Ô$ð TÝ Ð!R°4Ð!RÐ!RÐ!RÑSÔSÐSØ×"Ò" E­3¨u©:¬:Ð#6Ñ7Ô7Ð7Ð7ð
	àŒL×%Ò% i°ÈTÐ%ÑRÔRÐRØ× Ò  Ñ1Ô1Ð1Ø×#Ò#Ñ%Ô%Ð%Ø�4øÝÔ/ð 	ð 	ð 	à�LŠL‰NŒNˆNØ×Ò 	Ñ*Ô*Ð*Ø�5�5ð		øøøs   ÂAC Ã8DÄDc                 óÒ   — |r|                      ¦   «         nd}dt          t          |¦  «        ¦  «        fg}|r|                     d¦  «         |                      ||||¦  «         dS )z»Send an error response on a stream.

        Args:
            stream_id: The stream ID
            status_code: HTTP status code
            message: Optional error message body
        r   zcontent-length)zcontent-typeztext/plain; charset=utf-8N)ÚencoderP   r|   rZ   r    )r9   rv   Ústatus_codeÚmessagerŸ   rw   s         r   Ú
send_errorz HTTP2ServerConnection.send_errorE  sr   € ð $+Ð3ˆw�~Š~ÑÔÐ°ˆØ$¥c­#¨d©)¬)¡n¤nÐ5Ð6ˆØð 	JØ�NŠNÐHÑIÔIÐIà×Ò˜9 k°7¸DÑAÔAÐAÐAÐAr   é   c                 óÈ   — | j                              |¦  «        }|�|                     |¦  «         | j                             ||¬¦  «         |                      ¦   «          dS )z¡Reset a stream with RST_STREAM.

        Args:
            stream_id: The stream ID to reset
            error_code: HTTP/2 error code (default: CANCEL)
        NrF   )r)   r{   r†   r5   Úreset_streamrC   )r9   rv   rG   ry   s       r   rÊ   z"HTTP2ServerConnection.reset_streamT  sd   € ð ”×!Ò! )Ñ,Ô,ˆØÐØ�LŠL˜Ñ$Ô$Ð$àŒ×!Ò! )¸
Ð!ÑCÔCÐCØ×ÒÑ!Ô!Ð!Ð!Ð!r   r   c                 ó
  — | j         rdS d| _         |€/| j        r&t          | j                             ¦   «         ¦  «        nd}	 | j                             |¬¦  «         |                      ¦   «          dS # t          $ r Y dS w xY w)zÊClose the connection gracefully with GOAWAY.

        Args:
            error_code: HTTP/2 error code (default: NO_ERROR)
            last_stream_id: Last processed stream ID (default: highest)
        NTr   rF   )r7   r)   ÚmaxÚkeysr5   Úclose_connectionrC   Ú	Exception)r9   rG   Úlast_stream_ids      r   rN   zHTTP2ServerConnection.closeb  sŸ   € ð Œ<ð 	ØˆFàˆŒàÐ!à9=¼ÐL�S ¤×!2Ò!2Ñ!4Ô!4Ñ5Ô5Ð5È1ˆNð	ØŒL×)Ò)°ZÐ)Ñ@Ô@Ð@Ø×#Ò#Ñ%Ô%Ð%Ð%Ð%øÝð 	ð 	ð 	ØˆDˆDð	øøøs   Á/A4 Á4
BÂBc                 óÚ   — | j                              ¦   «         }|rO	 | j                             |¦  «         dS # t          t
          f$ r}d| _        t          d|› �¦  «        ‚d}~ww xY wdS )z,Send any pending data from h2 to the socket.TzSocket write error: N)r5   r·   r'   ÚsendallrJ   rK   r7   r   )r9   r[   r\   s      r   rC   z(HTTP2ServerConnection._send_pending_datax  s’   € àŒ|×(Ò(Ñ*Ô*ˆØð 	GðGØ”	×!Ò! $Ñ'Ô'Ð'Ð'Ð'øÝ�WÐ%ð Gð Gð GØ#�”Ý*Ð+EÀ!Ð+EÐ+EÑFÔFÐFøøøøðGøøøð	Gð 	Gs   �9 ¹A(Á
A#Á#A(c                 ó   — | j         S )zCheck if connection is closed.rˆ   rD   s    r   Ú	is_closedzHTTP2ServerConnection.is_closed‚  s   € ð Œ|Ðr   c                 ó<   — | j                              |d¦  «         dS )zvRemove a stream after processing is complete.

        Args:
            stream_id: The stream ID to clean up
        N)r)   Úpop)r9   rv   s     r   rž   z$HTTP2ServerConnection.cleanup_stream‡  s"   € ð 	Œ×Ò˜ DÑ)Ô)Ð)Ð)Ð)r   c                 óB   — dt          | j        ¦  «        › d| j        › d�S )Nz<HTTP2ServerConnection streams=z closed=ú>)r|   r)   r7   rD   s    r   Ú__repr__zHTTP2ServerConnection.__repr__�  s7   € ð&Ý˜4œ<Ñ(Ô(ð&ð &à”lð&ð &ð &ð	
r   )N)F)rÈ   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rI   r:   rB   rL   rY   rc   re   rg   ri   ro   rq   rl   rš   r    r´   rœ   r¿   rÇ   rÊ   rN   rC   ÚpropertyrÔ   rž   rÙ   r   r   r   r"   r"   /   sÃ  € € € € € ðð ð Ðð)"ð )"ð )"ðV!ð !ð !ð*@"ð @"ð @"ð @"ðD$ð $ð $ðL:ð :ð :ð" ð  ð  ðD@ð @ð @ð4
+ð 
+ð 
+ðð ð ð@ð @ð @ð(ð ð ð"ð "ð "ð@*ð *ð *ð *ðX8ð 8ð 8ðt*ð *ð *ð *ðX*ð *ð *ðXBð Bð Bð Bð"ð "ð "ð "ðð ð ð ð,Gð Gð Gð ðð ñ „Xðð*ð *ð *ð
ð 
ð 
ð 
ð 
r   r"   )rÝ   Úior   Úerrorsr   r   r   r   r	   ry   r
   r_   r   r   r   r   r   r   r    r"   Ú__all__r   r   r   ú<module>râ      sø   ððð ð Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð  Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !ð €Ø€
Ø€
Ø€Ø€ð"ð "ð "ð"e	
ð e	
ð e	
ð e	
ð e	
ñ e	
ô e	
ð e	
ðP #Ð
#€€€r   