Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
stream.cpython-313.pyc395 linesDownload Raw Back to __pycache__
1�

2��j�����%SrSSKJr SSKJrJr SSKJrJrJ	r	J3r4 SSKJr SSK
JrJrJrJrJrJrJrJr SSKJrJr SS	KJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r( SS5K)J*r*J+r+J,r,J-r- SSK.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8 SSK9J:r: \(aSS
K;J<r<J=r=J>r> SSK?J@r@ SSKAJBrBJCrC SSKDJErE "SS\5rF"SS\5rG"SS\5rH\I"\J"\F55Vs/sHnSPM snrKS\K\FR�'S\K\FR�'S\K\FR�'"SS5rO0\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_0\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_E0\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_E0\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4S\FR�4_\FR�\GR�4\OR�\FR�4_\FR�\GR�4\OR�\FR�4_E\FR�\GR�4S\FR�4\FR�\GR�4S\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�4\FR�\GR�4\OR�\FR�40	Er~S\S'"SS5r�S!S jr�gs snf)"z<6h2/stream7~~~~~~~~~8 9An implementation of a HTTP/2 stream.10�)�annotations)�Enum�IntEnum)�
TYPE_CHECKING�Any�Union�cast)�HeaderTuple)�AltSvcFrame�ContinuationFrame�	DataFrame�Frame�HeadersFrame�PushPromiseFrame�RstStreamFrame�WindowUpdateFrame�)�11ErrorCodes�_error_code_from_int)�AlternativeServiceAvailable�DataReceived�Event�InformationalResponseReceived�PushedStreamReceived�RequestReceived�ResponseReceived�StreamEnded�StreamReset�TrailersReceived�
WindowUpdated�_PushedRequestSent�_RequestSent�
_ResponseSent�
_TrailersSent)�FlowControlError�InvalidBodyLengthError�
ProtocolError�StreamClosedError)12�HeaderValidationFlags�authority_from_headers�extract_method_header�guard_increment_window�is_informational_response�normalize_inbound_headers�normalize_outbound_headers�utf8_encode_headers�validate_headers�validate_outbound_headers)�
WindowManager)�Callable�	Generator�Iterable)�Encoder)�Header�HeaderWeaklyTyped)�H2Configurationc�0�\rSrSrSrSrSrSrSrSr	Sr13S	rg14)�StreamState�9rr������N)�__name__�15__module__�__qualname__�__firstlineno__�IDLE�RESERVED_REMOTE�RESERVED_LOCAL�OPEN�HALF_CLOSED_REMOTE�HALF_CLOSED_LOCAL�CLOSED�__static_attributes__rC��OD:\code\apps\devtools\python\user_packages\Python313\site-packages\h2/stream.pyr<r<9s'���D��O��N��D�����
�FrPr<c�`�\rSrSrSrSrSrSrSrSr	Sr16S	rS17rSr
SrS
rSrSrSrSrSrSrSrSrg)�StreamInputs�Crrr>r?r@rArB���	�18���
�����rCN)rDrErFrG�SEND_HEADERS�SEND_PUSH_PROMISE�SEND_RST_STREAM�	SEND_DATA�SEND_WINDOW_UPDATE�SEND_END_STREAM�RECV_HEADERS�RECV_PUSH_PROMISE�RECV_RST_STREAM�	RECV_DATA�RECV_WINDOW_UPDATE�RECV_END_STREAM�RECV_CONTINUATION�SEND_INFORMATIONAL_HEADERS�RECV_INFORMATIONAL_HEADERS�SEND_ALTERNATIVE_SERVICE�RECV_ALTERNATIVE_SERVICE�UPGRADE_CLIENT�UPGRADE_SERVERrOrCrPrQrSrSCsj���L����O��I����O��L����O��I����O���!#��!#��!��!���N��NrPrSc�$�\rSrSrSrSrSrSrSrg)�StreamClosedBy�Yrrr>r?rCN)	rDrErFrGrfrlrcrirOrCrPrQruruYs���O��O��O��OrPruFTc��\rSrSrSrSSjrS SjrS!SjrS!SjrS!Sjr	S!Sjr19S!S	jrS!S20jrS!Sjr
S!SjrS!S
jrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrS!SjrSrg)"�H2StreamStateMachine�kz�21A single HTTP/2 stream state machine.22 23This stream object implements basically the state machine described in24RFC 7540 section 5.1.25 26:param stream_id: The stream ID of this stream. This is stored primarily27    for logging purposes.28c��[RUlXlSUlSUlSUlSUlSUlSUl	g)N)29r<rH�state�	stream_id�client�headers_sent�
trailers_sent�headers_received�trailers_received�stream_closed_by)�selfr|s  rQ�__init__�H2StreamStateMachine.__init__vsI�� �%�%��30�"��$(���*.���*.���-1���.2���8<��rPc���[U[5(d
Sn[U5e[URU4up4URnX@lUb	U"X5$/$![31a [RUle[a&n[RUl[U5UeSnAff=f![a:nURn[RUlSUSU3n[U5UeSnAff=f)z032Process a specific input in the state machine.33z)Input must be an instance of StreamInputsNzInvalid input z34 in state )35�36isinstancerS�37ValueError�_transitionsr{r'r<rN�AssertionError�KeyError)r��input_�msg�func�target_state�previous_state�err�	old_states        rQ�
process_input�"H2StreamStateMachine.process_input�s����&�,�/�/�=�C��S�/�!�	�!-�t�z�z�6�.B�!C��D�"�Z�Z�N�%�J���6���5�5��I��%��!,�!3�!3�D�J��%�6�!,�!3�!3�D�J�'��,�#�5��6���	.��38�39�I�$�+�+�D�J�"�6�(�*�Y�K�@�C���$�#�-��		.�s/�B-�A�)B*�!B%�%B*�-40C1�75C,�,C1c�8�SUlSUl[5nU/$)z41Fires when a request is sent.42T)r}r~r"�r�r��events   rQ�request_sent�!H2StreamStateMachine.request_sent�s!����� �������w�rPc���UR(d;URSLd
URc
Sn[U5eSUl[5/$UR(aeSUl[5/$)zc43Fires when something that should be a response is sent. This 'response'44may actually be trailers.45TzClient cannot send responses.)r~r}r'r#rr$�r�r�r�s   rQ�
response_sent�"H2StreamStateMachine.response_sent�sg��46� � ��{�{�d�"�d�k�k�&9�5��#�C�(�(� $�D��!�O�$�$��%�%�%�%�!����� � rPc��UR(aeUR(aeSUlSUl[URS9nU/$)z#47Fires when a request is received.48FT�r|)r�r�r}rr|r�s   rQ�request_received�%H2StreamStateMachine.request_received�sF���(�(�(�(��)�)�)�)���� $����$�.�.�9���w�rPc���UR(d,URSLdeSUl[URS9nO-UR(aeSUl[URS9nURUlU/$)zW49Fires when a response is received. Also disambiguates between responses50and trailers.51Tr�)r�r}rr|r�rr�s   rQ�response_received�&H2StreamStateMachine.response_received�sl���$�$��;�;�$�&�&�&�$(�D�!�$�t�~�~�>�E��-�-�-�-�%)�D�"�$�t�~�~�>�E��.�.����w�rPc�j�UR(d
Sn[U5e[URS9nU/$)z52Fires when data is received.53z"cannot receive data before headersr�)r�r'rr|�r�r�r�r�s    rQ�
data_received�"H2StreamStateMachine.data_received�s2���$�$�6�C���$�$��t�~�~�6���w�rPc�*�[URS9/$)z/54Fires when a window update frame is received.55r�)r r|�r�r�s  rQ�window_updated�#H2StreamStateMachine.window_updated�s������7�8�8rPc�.�[URS9nU/$)zw56Fires when an END_STREAM flag is received in the OPEN state,57transitioning this stream to a HALF_CLOSED_REMOTE state.58r�)rr|r�s   rQ�stream_half_closed�'H2StreamStateMachine.stream_half_closed�s��59�d�n�n�5���w�rPc�X�[RUl[URS9nU/$)z'60Fires when a stream is cleanly ended.61r�)rurlr�rr|r�s   rQ�stream_ended�!H2StreamStateMachine.stream_ended�s'��!/� >� >����d�n�n�5���w�rPc�T�[RUl[URS9/$)z*62Fired when a stream is forcefully reset.63r�)rurir�rr|r�s  rQ�stream_reset�!H2StreamStateMachine.stream_reset�s$��!/� >� >����d�n�n�5�6�6rPc�@�URbeSUlSUl/$)z�64Fires on the newly pushed stream, when pushed by the local peer.65 66No event here, but definitionally this peer must be a server.67FT)r}r�r�s  rQ�send_new_pushed_stream�+H2StreamStateMachine.send_new_pushed_streams(���{�{�"�"�"���� $����	rPc�@�URbeSUlSUl/$)z�68Fires on the newly pushed stream, when pushed by the remote peer.69 70No event here, but definitionally this peer must be a client.71T)r}r~r�s  rQ�recv_new_pushed_stream�+H2StreamStateMachine.recv_new_pushed_stream
s(���{�{�"�"�"���� ����	rPc�T�URSLa
Sn[U5e[5nU/$)z�72Fires on the already-existing stream when a PUSH_PROMISE frame is sent.73We may only send PUSH_PROMISE frames if we're a server.74Tz&Cannot push streams from client peers.)r}r'r!r�s    rQ�send_push_promise�&H2StreamStateMachine.send_push_promises/��75�;�;�$��:�C���$�$�"�$���w�rPc��UR(dURcSnOSn[U5e[5nURUlU/$)z�76Fires on the already-existing stream when a PUSH_PROMISE frame is77received. We may only receive PUSH_PROMISE frames if we're a client.78 79Fires a PushedStreamReceived event.80z"Idle streams cannot receive pushesz)Cannot receive pushed streams as a server)r}r'rr|�parent_stream_idr�s    rQ�recv_push_promise�&H2StreamStateMachine.recv_push_promise$sE���{�{��{�{�"�:��A����$�$�$�&��!%������w�rPc�0�[RUl/$)zT81Called when an attempt is made to send END_STREAM in the82HALF_CLOSED_REMOTE state.83)rurfr�r�s  rQ�send_end_stream�$H2StreamStateMachine.send_end_stream6���84!/� >� >����	rPc�0�[RUl/$)zQ85Called when an attempt is made to send RST_STREAM in a non-closed86stream state.87)rurcr�r�s  rQ�send_reset_stream�&H2StreamStateMachine.send_reset_stream>r�rPc��[RUl[UR5n[UR[RSS9/UlUe)aK88Called when we need to forcefully emit another RST_STREAM frame on89behalf of the state machine.90 91If this is the first time we've done this, we should also hang an event92off the StreamClosedError so that the user can be informed. We know93it's the first time we've done this if the stream is currently in a94state other than CLOSED.95F�r|�96error_code�remote_reset)	rurcr�r(r|rr�
STREAM_CLOSED�_events)r�r��errors   rQ�reset_stream_on_error�*H2StreamStateMachine.reset_stream_on_errorFsK��!/� >� >���!�$�.�.�1����.�.�%�3�3�"�
�97��
��rPc�,�[UR5e)a?98Called when an unexpected frame is received on an already-closed99stream.100 101An endpoint that receives an unexpected frame should treat it as102a stream error or connection error with type STREAM_CLOSED, depending103on the specific frame. The error handling is done at a higher level:104this just raises the appropriate error.105�r(r|r�s  rQ�recv_on_closed_stream�*H2StreamStateMachine.recv_on_closed_stream\��� ����/�/rPc�,�[UR5e)a#106Called when an attempt is made to send data on an already-closed107stream.108 109This essentially overrides the standard logic by throwing a110more-specific error: StreamClosedError. This is a ProtocolError, so it111matches the standard API of the state machine, but provides more detail112to the user.113r�r�s  rQ�send_on_closed_stream�*H2StreamStateMachine.send_on_closed_streamhr�rPc��URceUR[R:Xa[UR5eSn[U5e)a�114Called when a PUSH_PROMISE frame is received on a full stop115stream.116 117If the stream was closed by us sending a RST_STREAM frame, then we118presume that the PUSH_PROMISE was in flight when we reset the parent119stream. Rathen than accept the new stream, we just reset it.120Otherwise, we should call this a PROTOCOL_ERROR: pushing a stream on a121naturally closed stream is a real problem because it creates a brand122new stream that the remote peer now believes exists.123�#Attempted to push on closed stream.)r�rurcr(r|r'r�s   rQ�recv_push_on_closed_stream�/H2StreamStateMachine.recv_push_on_closed_streamtsI���$�$�0�0�0�� � �N�$B�$B�B�#�D�N�N�3�3�3���C� � rPc��Sn[U5e)ac124Called when an attempt is made to push on an already-closed stream.125 126This essentially overrides the standard logic by providing a more127useful error message. It's necessary because simply indicating that the128stream is closed is not enough: there is now a new stream that is not129allowed to be there. The only recourse is to tear the whole connection130down.131r�)r'r�s   rQ�send_push_on_closed_stream�/H2StreamStateMachine.send_push_on_closed_stream�s��4���C� � rPc�X�UR(a
Sn[U5e[5nU/$)z�132Called when an informational header block is sent (that is, a block133where the :status header has a 1XX value).134 135Only enforces that these are sent *before* final headers are sent.136z)Information response after final response)r~r'r#r�s    rQ�send_informational_response�0H2StreamStateMachine.send_informational_response�s+�����=�C���$�$�����w�rPc�f�UR(a
Sn[U5e[URS9/$)zt137Called when an informational header block is received (that is, a block138where the :status header has a 1XX value).139z+Informational response after final responser�)r�r'rr|r�s   rQ�recv_informational_response�0H2StreamStateMachine.recv_informational_response�s/��140� � �?�C���$�$�-����G�H�HrPc�`�URSLa/$UR(a/$[5/$)a�141Called when receiving an ALTSVC frame.142 143RFC 7838 allows us to receive ALTSVC frames at any stream state, which144is really absurdly overzealous. For that reason, we want to limit the145states in which we can actually receive it. It's really only sensible146to receive it after we've sent our own headers and before the server147has sent its header block: the server can't guarantee that we have any148state around after it completes its header block, and the server149doesn't know what origin we're talking about before we've sent ours.150 151For that reason, this function applies a few extra checks on both state152and some of the little state variables we keep around. If those suggest153an unreasonable situation for the ALTSVC frame to have been sent in,154we quietly ignore it (as RFC 7838 suggests).155 156This function is also *not* always called by the state machine. In some157states (IDLE, RESERVED_LOCAL, CLOSED) we don't bother to call it,158because we know the frame cannot be valid in that state (IDLE because159the server cannot know what origin the stream applies to, CLOSED160because the server cannot assume we still have state around,161RESERVED_LOCAL because by definition if we're in the RESERVED_LOCAL162state then *we* are the server).163F)r}r�rr�s  rQ�recv_alt_svc�!H2StreamStateMachine.recv_alt_svc�s3��6�;�;�%���I�164� � ��I�,�-�.�.rPc�B�UR(a
Sn[U5e/$)a�165Called when sending an ALTSVC frame on this stream.166 167For consistency with the restrictions we apply on receiving ALTSVC168frames in ``recv_alt_svc``, we want to restrict when users can send169ALTSVC frames to the situations when we ourselves would accept them.170 171That means: when we are a server, when we have received the request172headers, and when we have not yet sent our own response headers.173z2Cannot send ALTSVC after sending response headers.)r~r'r�s   rQ�send_alt_svc�!H2StreamStateMachine.send_alt_svc�s"�����F�C���$�$��	rP)r}r�r~r{r�r|r�rN)r|�int�return�None)r�rSr��list[Event])r�r<r�r�) rDrErFrG�__doc__r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rOrCrPrQrxrxks����<� �<�
!�174��$�9���7�	�	�175��$���,1760�1770�!�&!��	I�&/�PrPrxNz}dict[tuple[StreamState, StreamInputs], tuple[Callable[[H2StreamStateMachine, StreamState], list[Event]] | None, StreamState]]r�c��\rSrSrSrS#SjrS$Sjr\S%Sj5r\S&Sj5r	\S&Sj5r178\S'Sj5rS(S	jrS)S*S179jjr
S+SjrS,SjrS-S.SjjrS,SjrS/SjrS0SjrS1SjrS2SjrS3SjrS4SjrS5SjrS6SjrS7SjrS8S9SjjrS:SjrS;SjrS<SjrS=SjrS>Sjr S?Sjr!S@S jr"SAS!jr#S"r$g
)B�H2Streami�aJ180A low-level HTTP/2 stream object. This handles building and receiving181frames and maintains per-stream state.182 183This wraps a HTTP/2 Stream state machine implementation, ensuring that184frames can only be sent/received when the stream is in a valid state.185Attempts to create frames that cannot be sent will raise a186``ProtocolError``.187c��[U5UlXlSUlSUlX@l[
U5UlSUlSUl	SUl188X lg)Nr)rx�
state_machiner|�max_outbound_frame_size�request_method�outbound_flow_control_windowr3�_inbound_window_manager�_expected_content_length�_actual_content_length�189_authority�config)r�r|r��inbound_window_size�outbound_window_sizes     rQr��H2Stream.__init__sc��1902�)�<���"��37��$�,0���-A�)�(5�5H�'I��$�59��%�'(��#�)-����rPc�~�S[U5RSURSURR<S3$)N�<z id:z state:�>)�typerDr|r�r{�r�s rQ�__repr__�H2Stream.__repr__!s;���4��:�&�&�'�t�D�N�N�+;�7�4�CU�CU�C[�C[�B^�^_�`�`rPc�.�URR$)a191The size of the inbound flow control window for the stream. This is192rarely publicly useful: instead, use :meth:`remote_flow_control_window193<h2.stream.H2Stream.remote_flow_control_window>`. This shortcut is194largely present to provide a shortcut to this data.195)r��current_window_sizers rQ�inbound_flow_control_window�$H2Stream.inbound_flow_control_window$s���+�+�?�?�?rPc�<�[URR$)zq196Whether the stream is 'open' in any sense: that is, whether it counts197against the number of concurrent streams.198)�STREAM_OPENr�r{rs rQ�open�
H2Stream.open.s���4�-�-�3�3�4�4rPc�P�URR[R:H$)z199Whether the stream is closed.200)r�r{r<rNrs rQ�closed�H2Stream.closed;s!��201�!�!�'�'�;�+=�+=�=�=rPc�.�URR$)z>202Returns how the stream was closed, as one of StreamClosedBy.203)r�r�rs rQ�	closed_by�H2Stream.closed_byBs��204�!�!�2�2�2rPc���URRRSU5 URS:XdeU(a[R205O[RnURRU5 g)z�206Called by the connection to indicate that this stream is the initial207request/response of an upgraded connection. Places the stream into an208appropriate state.209zUpgrading %rrN)	r��logger�debugr|rSrrrsr�r�)r��client_sider�s   rQ�upgrade�H2Stream.upgradeIs_��	
����� � ���6��~�~��"�"�"�+6�L�'�'��,�,�	�	
���(�(��0rPc�V�URRRSX5 [Rn[U5nURR(d4[U5(a$U(a
Sn[U5e[RnURRU5n[UR5nURU5n	URXRX�5n210U(aGURR[R 5 U211SR"R%S5 URR&(aU(d
Sn[U5eURR(aUR(c[+U5Ul[-U5UlU212$)zV213Returns a list of HEADERS/CONTINUATION frames to emit as either headers214or trailers.215zSend headers %s on %rz1Cannot set END_STREAM on informational responses.r�216END_STREAMz"Trailers must have END_STREAM set.)r�rrrSrar0r�r}r-r'rnr�rr|�_build_hdr_validation_flags�_build_headers_framesrf�flags�addrr�r*r+r�)r��headers�encoder�217end_streamr��
bytes_headersr��events�hf�hdr_validation_flags�framess           rQ�send_headers�H2Stream.send_headersZsH��	
����� � �!8�'�H��*�*��+�G�4�
��#�#�*�*�)�-�8�8��I��#�C�(�(�!�<�<�F��#�#�1�1�&�9��
�$�.�.�
)��#�?�?��G���+�+��B�218���
���,�,�\�-I�-I�J��1�I�O�O����-����+�+�J�6�C���$�$����$�$����)@�4�]�C�D�O�4�M�B����
rPc�2�URRRSU5 URR	[219R5n[UR5nXl	URU5n[U5nURXsXV5$)z�220Returns a list of PUSH_PROMISE/CONTINUATION frames to emit as a pushed221stream header. Called on the stream that has the PUSH_PROMISE frame222sent on it.223zPush stream %r)
r�rrr�r�rSrbrr|�promised_stream_idrr0r )r��related_stream_idr#r$r'�ppfr)r&s        rQ�push_stream_in_band�H2Stream.push_stream_in_band�s���	
����� � �!1�4�8�224�#�#�1�1��*�*�225���t�~�~�.��!2��#�?�?��G��+�G�4�
��)�)��C�226�	227rPc�j�URR[R5nU(ae/$)z�228Mark this stream as one that was pushed by this peer. Must be called229immediately after initialization. Sends no frames, simply updates the230state machine.231)r�r�rSrb)r�r's  rQ�locally_pushed�H2Stream.locally_pushed�s2���#�#�1�1��*�*�232����z��	rPNc��URRRSX5 URR	[233R5 [UR5nXl	U(aDURR	[234R5 URRS5 Ub!URRS5 X4l
U=RUR-slURS:�deU/$)zj235Prepare some data frames. Optionally end the stream.236 237.. warning:: Does not perform flow control checks.238z)Send data on %r with end stream set to %sr�PADDEDr)r�rrr�r�rSrdr
r|�datarfr!r"�239pad_lengthr��flow_controlled_length)r�r8r%r9�dfs     rQ�	send_data�H2Stream.send_data�s���	
����� � �7��	240�	
���(�(��)?�)?�@�
�t�~�~�
&��������,�,�\�-I�-I�J��H�H�L�L��&��!��H�H�L�L��"�&�M�	
�)�)�R�-F�-F�F�)��0�0�A�5�5�5��t�rPc��URRRSU5 URR	[241R5 [UR5nURRS5 U/$)z$242End a stream without sending data.243z
End stream %rr)r�rrr�r�rSrfr
r|r!r")r�r;s  rQr%�H2Stream.end_stream�s]��	
����� � ��$�7����(�(��)E�)E�F�
�t�~�~�
&��244�����\�"��t�rPc���URRRSX5 URR	[245R5 [UR5nXl	U/$)zw246Advertise an RFC 7838 alternative service. The semantics of this are247better documented in the ``H2Connection`` class.248z*Advertise alternative service of %r for %r)249r�rrr�r�rSrprr|�field)r��field_value�asfs   rQ�advertise_alternative_service�&H2Stream.advertise_alternative_service�sW��250	
����� � �8�+�	251�	
���(�(��)N�)N�O��$�.�.�)���	��u�rPc��URRRSX5 URR	[252R5 URRU5 [UR5nXlU/$)zC253Increase the size of the flow control window for the remote side.254z)Increase flow control window for %r by %d)r�rrr�r�rSrer��
window_openedrr|�window_increment)r��	increment�wufs   rQ�increase_flow_control_window�%H2Stream.increase_flow_control_window�sm��	
����� � �7��	255�	
���(�(��)H�)H�I��$�$�2�2�9�=�����/��(���u�rPc�"�URRRSX5 URR	[256R5n[SUS5nXlURU5nURX&U5Ul/U4$)z�257Receives a push promise frame sent on this stream, pushing a remote258stream. This is called on the stream that has the PUSH_PROMISE sent259on it.260z/Receive Push Promise on %r for remote stream %drr)r�rrr�r�rSrhr	�pushed_stream_idr�_process_received_headersr#)r�r.r#�header_encodingr'�261push_eventr)s       rQ�receive_push_promise_in_band�%H2Stream.receive_push_promise_in_bands���	
����� � �=��	262��#�#�1�1��*�*�263���0�&��)�<�264�&8�#�#�?�?��G��!�;�;��?�265�266���6�z�rPc���URRRSU5 URR	[267R5n[U5Ul/U4$)z�268Mark this stream as one that was pushed by the remote peer. Must be269called immediately after initialization. Sends no frames, simply270updates the state machine.271z%r pushed by remote peer)	r�rrr�r�rSrhr*r�)r��pushed_headersr's   rQ�remotely_pushed�H2Stream.remotely_pushedsV��	
����� � �!;�T�B��#�#�1�1��*�*�272��1��@����6�z�rPc�P�[U5(a%U(a
Sn[U5e[RnO[RnUR273R
U5n[SUS5nU(aKUR274R
[R5n[SUS5[SU5l	Xh-
nURU5 [U[5(aU(d
Sn[U5eURU5n	URXU5Ul/U4$)z)275Receive a set of headers (or trailers).276z0Cannot set END_STREAM on informational responseszYUnion[RequestReceived, ResponseReceived, TrailersReceived, InformationalResponseReceived]rrz:Union[RequestReceived, ResponseReceived, TrailersReceived]z!Trailers must have END_STREAM set)r-r'rSrorgr�r�r	rlr��_initialize_content_lengthr�rrrOr#)277r�r#r%rPr�r�r'�
headers_event�	es_eventsr)s278          rQ�receive_headers�H2Stream.receive_headers&s��%�W�-�-��H��#�C�(�(�!�<�<�F�!�.�.�F��#�#�1�1�&�9���g��1�I�279�
�280��*�*�8�8��,�,��I�"�-��1��>�
�L��
����F��'�'��0��m�%5�6�6�z�5�C���$�$�#�?�?��G�� $� >� >��?�!281�
���6�z�rPc���URRRSXU5 URR	[282R5n[SUS5nURRU5 UR[U5U5 U(aNURR	[283R5n[SUS5Ul
URU5 XlX5l/U4$)z284Receive some data.285zGReceive data on %r with end stream %s and flow control length set to %drrr)r�rrr�r�rSrjr	r��window_consumed�_track_content_length�lenrlr��extendr8r:)r�r8r%�flow_control_lenr'�286data_eventr[s       rQ�receive_data�H2Stream.receive_dataRs���	
����� � �
��+;�	287��#�#�1�1�,�2H�2H�I���.�&��)�4�288��$�$�4�4�5E�F��"�"�3�t�9�j�9���*�*�8�8��,�,��I�'+�=�)�A�,�&G�J�#��M�M�)�$���,<�)��6�z�rPc���URRRSX5 URR	[289R5n/nU(a3U[SUS5l[URU5Ul290X24$X24$![aH [UR[RSS9/nUR![R5nX24$f=f)z#291Handle a WINDOW_UPDATE increment.292z/Receive Window Update on %r for increment of %dr rFr�)r�rrr�r�rSrkr	�deltar,r�r%rr|r�FLOW_CONTROL_ERROR�reset_stream)r�rIr'r*s    rQ�receive_window_update�H2Stream.receive_window_updatejs���	
����� � �=��	293��#�#�1�1��+�+�294����295�5>�D��&��)�,�2�
J�4J��5�5��5��1� �~��v�~���$�296
J� �"&�.�.�#-�#@�#@�%*�����*�*�:�+H�+H�I���~��297
J�s�.B�A
C!� C!c��URRRSU5 URR	[298R5 Sn[U5e)z�299A naked CONTINUATION frame has been received. This is always an error,300but the type of error it is depends on the state of the stream and must301transition the state of the stream, so we need to handle it.302z Receive Continuation frame on %rzShould not be reachable)r�rrr�r�rSrmr�)r�r�s  rQ�receive_continuation�H2Stream.receive_continuation�sN��	
����� � �!C�T�J����(�(��*�*�	303�(���S�!�!rPc�d�URRRSU5 UR(a//4$URR[R5nU(aB[US[5(deURUSlURUSl/U4$)zv304An Alternative Service frame was received on the stream. This frame305inherits the origin associated with this stream.306z.Receive Alternative Service frame on stream %rr)
r�rr�originr�r�rSrqr�rr�rArB�r��framer's   rQ�receive_alt_svc�H2Stream.receive_alt_svc�s���307	
����� � �<�d�	308�309�<�<��r�6�M��#�#�1�1��1�1�310����f�Q�i�)D�E�E�E�E�#���F�1�I��$)�K�K�F�1�I�!��6�z�rPc���URRRSX5 URR	[311R5 [UR5nXl	U/$)z@312Close the stream locally. Reset the stream with an error code.313z"Local reset %r with error code: %d)314r�rrr�r�rSrcrr|r�)r�r��rsfs   rQrj�H2Stream.reset_stream�sW��	
����� � �0�$�	315�	
���(�(��)E�)E�F��T�^�^�,��#���u�rPc��URRRSXR5 URR[R5nU(a'[UR5[SUS5l/U4$)z'316Handle a stream being reset remotely.317z#Remote reset %r with error code: %drr)318r�rrr�r�r�rSrirr	rrs   rQr��H2Stream.stream_reset�sp��	
����� � �1�4�9I�9I�	319��#�#�1�1�,�2N�2N�O���8L�U�M]�M]�8^�D���q�	�*�5��6�z�rPc���URRRSX5 URR	U5nU(a[UR5nX#lU/$/$)z�320The user has informed us that they've processed some amount of data321that was received on this stream. Pass that to the window manager and322potentially return some WindowUpdate frames.323z,Acknowledge received data with size %d on %r)r�rrr��
process_bytesrr|rH)r��acknowledged_sizerI�fs    rQ�acknowledge_received_data�"H2Stream.acknowledge_received_data�sb��	
����� � �:��	324��0�0�>�>��325�	��!�$�.�.�1�A�!*���3�J��	rPc���[US[[45n[US[[[32645n[US[[45n[URR=(d SUUUS9$)zd327Constructs a set of header validation flags for use when normalizing328and validating header blocks.329rF)�	is_client�330is_trailer�is_response_header�is_push_promise)r�r$rr#rrrr!r)r�r})r�r'r�r�r�s     rQr�$H2Stream._build_hdr_validation_flags�s���331 ��1�I�
�'7�8�332�333�(��1�I�� �-�
�334��%��1�I�,�.@�A�335��%��(�(�/�/�8�5�!�1�+�	336�	337rPc�~�URR(a"URRn[XU5nURR(a[X5nUR	U5n[S[
U5UR=(d S5Vs/sHnXgXpR=(d S-PM nn/n	USUlU	RU5 USSH/n338[UR5nX�lU	RU5 M1 U	SRRS5 U	$s snf)z8339Helper method to build headers or push promise frames.340rrN������END_HEADERS)r�r/�split_outbound_cookiesr2�encode�rangerar�r8�appendrr|r!r")r�r#r$�first_framer)�should_split_outbound_cookies�encoded_headers�i�
header_blocksr*�block�cfs            rQr �H2Stream._build_headers_framess*���;�;�1�1�-1�K�K�,N�,N�)�0��/L��G��;�;�0�0�/���G�"�.�.��1����3��'�$�*F�*F�*K�!��341���
�a�!=�!=�!B��C�D��	�342�MO��(��+����
�
�k�"�"�1�2�&�E�"�4�>�>�2�B��G��M�M�"��'�343	�r�344�����]�+��
��#345s� #D:c���URR(a[X5nURR(a[X5n[	U[3465(a[
X5n[U5$)z�347When headers have been received from the remote peer, run a processing348pipeline on them to transform them into the appropriate form for349attaching to an event.350)r�r.�validate_inbound_headersr1r��str�_decode_headers�list)r�r#�header_validation_flagsrPs    rQrO�"H2Stream._process_received_headers2sZ���;�;�0�0�/���G��;�;�/�/�&�w�H�G��o�s�+�+�%�g�?�G��G�}�rPc���URS:XaSUlgUHup#US:XdM
[US5Ul g g![anSU<3n[	U5UeSnAff=f)z�351Checks the headers for a content-length header and initializes the352_expected_content_length field from it. It's not an error for no353Content-Length header to be present.354sHEADrNscontent-lengthrXzInvalid content-length header: )r�r�r�r�r')r�r#�n�vr�r�s      rQrY�#H2Stream._initialize_content_lengthJsu�����'�)�,-�D�)���D�A��%�%�6�47��2�J�D�1�355���"�6�;�A�5�A�C�'��,�#�5��6�s�?�356A �	A�A c��U=RU-
slURnURnUb)XC:a[XC5eU(aXC:wa[XC5eggg)ae357Update the expected content length in response to data being received.358Validates that the appropriate amount of data is sent. Always updates359the received data, but only validates the length against the360content-length header if one was sent.361 362:param length: The length of the body chunk received.363:param end_stream: If this is the last body chunk received.364N)r�r�r&)r��lengthr%�actual�expecteds     rQr`�H2Stream._track_content_length^sa��	
�#�#�v�-�#��,�,���0�0����� �,�X�>�>��h�0�,�X�>�>�1�z�	 rPc��URRU-nURRU5 X Rlg)a)365We changed SETTINGS_INITIAL_WINDOW_SIZE, which means we need to366update the target window size for flow control. For our flow control367strategy, this means we need to do two things: we need to adjust the368current window size, but we also need to set the target maximum window369size to the new value.370N)r��max_window_sizerG)r�rh�new_max_sizes   rQ�*_inbound_flow_control_change_from_settings�3H2Stream._inbound_flow_control_change_from_settingsss:���3�3�C�C�e�K���$�$�2�2�5�9�7C�$�$�4rP)371r�r�r�r�r�r�r�r�r�r|)372r|r�r�r:r�r�rr�r�r�)r�r�)r�r�)r��bool)r�zStreamClosedBy | None)rr�r�r�)F)r#�Iterable[HeaderWeaklyTyped]r$r7r%r�r��9list[HeadersFrame | ContinuationFrame | PushPromiseFrame])r/r�r#r�r$r7r�r�)r��list[Frame])FN)r8zbytes | memoryviewr%r�r9z373int | Noner�r�)rB�bytesr�r�)rIr�r�r�)r.r�r#�Iterable[Header]rP�bool | str | Noner��tuple[list[Frame], list[Event]])rUr�r�r�)r#r�r%r�rPr�r�r�)r8r�r%r�rcr�r�r�)rIr�r�r�)r�r�)rsrr�r�)r)r�zErrorCodes | intr�r�)rsrr�r�)r}r�r�r�)r'rr�r))374r#r�r$r7r�zHeadersFrame | PushPromiseFramer)r)r�r�)r#r�r�r)rPr�r�zlist[Header])r#r�r�r�)r�r�r%r�r�r�)rhr�r�r�)%rDrErFrGr�r�r�propertyrrrrrr+r1r4r<r%rDrKrRrVr\rerkrnrtrjr�rrr rOrYr`r�rOrCrPrQr�r��s0������(��'*��(+�	�04�	�8a��@��@��3755��3765��>��>��3��3�1�().�5�9�5�%�5�"&�5�3l�5�n377�/2�378�%@�379�&-�380�2k�381�:�&+�+/��*��"��)��5@��<	��
��9<��.>��7H��Ml��2�*�!1�*�$(�*�*;�*�@_�*�X�0#�J"��6�
��(382�6.�'7�.�'.�.�,K�.�5J�	.�383I�.�`�+;��;P��4E��JV��0�(?�*384DrPr�c#�# �UH�n[U[5(deUup4[U[5(de[U[5(deURU5nURU5nUR	XV5v� M� g7f)z�385Given an iterable of header two-tuples and an encoding, decodes those386headers using that encoding while preserving the type of the header tuple.387This ensures that the use of ``HeaderTuple`` is preserved.388N)r�r389r��decode�	__class__)r#�encoding�header�name�valuer�r�s       rQr�r��s�������&�+�.�.�.�.�����$��&�&�&�&��%��'�'�'�'��K�K��!���L�L��"�����q�$�$��s�B	B)r#r�r�r�r�z"Generator[HeaderTuple, None, None])�r��390__future__r�enumrr�typingrrrr	�hpackr391�hyperframe.framerrr
rrrrr�errorsrrr'rrrrrrrrrrr r!r"r#r$�392exceptionsr%r&r'r(�	utilitiesr)r*r+r,r-r.r/r0r1r2�windowsr3�collections.abcr4r5r6�hpack.hpackr7�hpack.structr8r9r�r:r<rSrur�rarrKrMrLrxrHrar�rgr�rjr�rNrbr�rJrhr�rIrqrrrsr�rerkr�rcr�rir�rpr�r�r�rdr�rfrlr�r�r�rnr�ror�r�r�r�r�r�r�r��__annotations__r�r�)�_s0rQ�<module>r�s����#��2�2��Q�Q�Q�4������"c�b����#��=�=�#�6�'��'���4��,�T��$�C��$4�5�6�5��u�5�6�� $��K����-1��K�)�)�*�.2��K�*�*�+�z�z�LF����|�0�0�1�	�	*�	*�K�,<�,<�=�F����|�0�0�1�	�	.�	.��0@�0@�A�F����|�-�-�.�	�	3�	3�[�5G�5G�H�F����|�5�5�6�	�	4�	4��&�&�	(�F����|�5�5�6�	�	4�	4��'�'�	)�F����|�<�<�=�	
�{��� �F� ���|�2�2�3�	�	*�	*�K�,I�,I�J�#F�$���|�2�2�3�	�	.�	.��*�*�	,�'F�.����!:�!:�;�	�	+�	+�[�-K�-K�L�1F�2����!7�!7�8�	�	3�	3�[�5G�5G�H�5F�6����!@�!@�A�	
�{�)�)�*�9F�:����!@�!@�A�	�	,�	,�k�.H�.H�I�=F�>����!=�!=�>�	�	/�	/��1C�1C�D�AF�B����!=�!=�>�	�	*�	*�K�,>�,>�?�EF�F����!F�!F�G�	�	*�	*�K�,F�,F�G�IF�J����!F�!F�G�	
�{�)�)�*�MF�R� � �,�";�";�<�	�	/�	/��)�)�	+�UF�X� � �,�"8�"8�9�	�	3�	3�[�5G�5G�H�[F�\� � �,�"A�"A�B�	
�{�*�*�+�_F�`� � �,�"A�"A�B�	�	,�	,�k�.I�.I�J�cF�d� � �,�">�">�?�	�	/�	/��1C�1C�D�gF�h� � �,�">�">�?�	�	*�	*�K�,>�,>�?�kF�l� � �,�"G�"G�H�	�	*�	*�K�,G�,G�H�oF�t���|�0�0�1�	�	+�	+�[�-=�-=�>�wF�x���|�0�0�1�	�	/�	/��1A�1A�B�{F�|���|�-�-�.�	
�{��� �F�@���|�-�-�.�	�	+�	+�[�-=�-=�>�CF�D���|�3�3�4�	
�{�,�,�-�GF�H���|�3�3�4�	�	0�	0�	�	'�	'�	)�KF�N���|�6�6�7�	
�{��� �QF�R���|�6�6�7�	�	,�	,�k�.>�.>�?�UF�V���|�3�3�4�	�	/�	/��1C�1C�D�YF�Z���|�3�3�4�	�	*�	*�K�,>�,>�?�]F�^���|�5�5�6�	�	/�	/��1A�1A�B�aF�b���|�5�5�6�	�	/�	/��1A�1A�B�eF�f���|�>�>�?�	�	9�	9�;�;K�;K�L�iF�j���|�>�>�?�	�	9�	9�;�;K�;K�L�mF�n���|�<�<�=�	�	*�	*�K�,<�,<�=�qF�r���|�<�<�=�	�	*�	*�K�,<�,<�=�uF�z�#�#�\�%>�%>�?�	�	+�	+�[�-K�-K�L�}F�~�#�#�\�%>�%>�?�	�	3�	3�[�5G�5G�H�AF�B�#�#�\�%;�%;�<�	
�{�-�-�.�EF�F�#�#�\�%;�%;�<�	�	3�	3�[�5G�5G�H�IF�J�#�#�\�%A�%A�B�	�	-�	-�{�/A�/A�B�MF�N�#�#�\�%D�%D�E�	
�{�-�-�.�QF�R�#�#�\�%D�%D�E�	�	,�	,�k�.L�.L�M�UF�V�#�#�\�%A�%A�B�	�	/�	/��1C�1C�D�YF�Z�#�#�\�%A�%A�B�	�	*�	*�K�,>�,>�?�]F�^�#�#�\�%C�%C�D�	�	/�	/��*�*�	,�aF�d�#�#�\�%C�%C�D�	�	3�	3�[�5G�5G�H�gF�h�#�#�\�%L�%L�M�	�	9�	9��*�*�	,�kF�n�#�#�\�%J�%J�K�	�	*�	*�K�,J�,J�K�qF�r�#�#�\�%J�%J�K�	�	*�	*�K�,J�,J�K�uF�z�"�"�L�$=�$=�>�	�	/�	/��)�)�	+�}F�@�"�"�L�$:�$:�;�	�	+�	+�[�-J�-J�K�CF�D�"�"�L�$@�$@�A�	�	*�	*�K�,>�,>�?�GF�H�"�"�L�$C�$C�D�	
�{�,�,�-�KF�L�"�"�L�$C�$C�D�	�	,�	,�k�.K�.K�L�OF�P�"�"�L�$@�$@�A�	�	/�	/��1C�1C�D�SF�T�"�"�L�$@�$@�A�	�	*�	*�K�,>�,>�?�WF�X�"�"�L�$B�$B�C�	�	/�	/��)�)�	+�[F�^�"�"�L�$K�$K�L�	�	9�	9��)�)�	+�aF�d�"�"�L�$I�$I�J�	�	*�	*�K�,I�,I�J�gF�h�"�"�L�$I�$I�J�	�	*�	*�K�,I�,I�J�kF�p����5�5�6�	
�{�!�!�"�sF�t����>�>�?�	
�{�!�!�"�wF�J����2�2�3�	�	3�	3�[�5G�5G�H�MF�N����/�/�0�	�	3�	3�[�5G�5G�H�QF�\����8�8�9�	
�{�!�!�"�����5�5�6�	
�{�!�!�"�393����7�7�8�	�	8�	8�+�:L�:L�M�����2�2�3�	�	3�	3�[�5G�5G�H�����7�7�8�	�	8�	8�+�:L�:L�M�����5�5�6�	�	3�	3�[�5G�5G�H�����/�/�0�	�	3�	3�[�5G�5G�H�����8�8�9�	�	3�	3�[�5G�5G�H�����5�5�6�	�	3�	3�[�5G�5G�H�KF�
��I�XC394D�C395D�L%��w(7s�"{
codekingpro/portable-devtools · Team Ai