+
     hh  c                   sJ   ^ RI HtHtHtHtHtHtHtHtH	t	H
t
 ^RIHtHtHtHtHtHtHt ^RIHtHtHt ^RIHtHt ^RIHt ^RIHtHtHtH t H!t!H"t"H#t#H$t$H%t%H&t& ^RI'H(t(H)t)H*t* ^RI+H,t,H-t- . ROt. ! R R
]*]*R7      t/ ! R R]*]*R7      t0Rt1R R lt2R R lt3 ! R R	4      t4R# )    )
AnyCallablecastDictListOptionaloverloadTupleTypeUnion)ConnectionClosedDataEndOfMessageEventInformationalResponseRequestResponse)get_comma_headerhas_expect_100_continueset_comma_header)READERSReadersType)ReceiveBuffer)
_SWITCH_CONNECT_SWITCH_UPGRADECLIENTConnectionStateDONEERRORMIGHT_SWITCH_PROTOCOL	SEND_BODYSERVERSWITCHED_PROTOCOL)LocalProtocolErrorRemoteProtocolErrorSentinel)WRITERSWritersType
Connection	NEED_DATAPAUSEDc                   s    ] tR t^3tRtR# )r(    N__name__
__module____qualname____firstlineno____static_attributes__r*       4/usr/lib/python3.14/site-packages/h11/_connection.pyr(   r(   3       r1   )Z	metaclassc                   s    ] tR t^7tRtR# )r)   r*   Nr+   r*   r1   r2   r)   r)   7   r3   r1   c                sR    V ^8  d   QhR\         \        \        3,          R\        /#    eventreturn)r
   r   r   boolformat   "r2   __annotate__r<   T   s$      uWh./ D r1   c                 sl    \        V P                  R 4      pRV9   d   R# \        V RR4      R8  d   R# R# )
   connection   closeFhttp_version   1.1T)r   headersZgetattr)r6   
connection   & r2   _keep_aliverD   T   s4    !%--?J:unf-6r1   c                s    V ^8  d   QhR\         R\        \        \        3,          R\        \
        \        \        R,          \        \        ,          3,          3,          /# )r5   request_methodr6   r7   r*   )bytesr
   r   r   r   Zstrintr9   r;   r2   r<   r<   ]   sJ     0  0 0 "'(9":0 
3eBis+,,-0 r1   c                 sv   \        V4      \        J d>   VP                  R9   g+   V R8X  g$   V R8X  d   ^VP                  u;8:  d   R8  d   M MR# \        VP                  R4      pV'       d   R	# \        VP                  R4      pV'       d   R\        V^ ,          4      33# \        V4      \        J d   R# R
# )      HEAD   CONNECT,  content-length   transfer-encoding   content-length)rH   i0  )rL   )r    )chunkedr*   )http/1.0r*   )typer   status_coder   rA   rG   r   )rE   r6   Ztransfer_encodingsZcontent_lengths   &&  r2   _body_framingrT   ]   s    * E{h+(*,8I8I1OC1O++ *%--9MN 'u}}6GHO 3q'9#:"<== E{g''r1   c                   s
  a  ] tR t^t o Rt]3V 3R lR llt]V 3R lR l4       t]V 3R lR l4       t	]V 3R lR	 l4       t
]V 3R
 lR l4       tV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltR0V 3R lR llt]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R lR  lt]V 3R! lR" l4       t]V 3R# lR$ l4       t]V 3R% lR& l4       tV 3R' lR( ltV 3R) lR* ltV 3R+ lR, ltV 3R- lR. ltR/tV tR# )1r'   a  An object encapsulating the state of an HTTP connection.

Args:
    our_role: If you're implementing a client, pass :data:`h11.CLIENT`. If
        you're implementing a server, pass :data:`h11.SERVER`.

    max_incomplete_event_size (int):
        The maximum number of bytes we're willing to buffer of an
        incomplete event. In practice this mostly sets a limit on the
        maximum size of the request/response line + headers. If this is
        exceeded, then :meth:`next_event` will raise
        :exc:`RemoteProtocolError`.

c                :   < V ^8  d   QhRS[ S[,          RS[RR/# )r5   our_rolemax_incomplete_event_sizer7   N)r	   r$   rG   r:   __classdict__   "r2   r<   Connection.__annotate__   s-     %8 %8x.%8 $'%8 
	%8r1   c                s   W n         V\        \        39  d   \        R V: 24      hWn        V  V\        J d   \        V n        M\        V n        \        4       V n        V P                  V P                  R\        4      V n
        V P                  V P
                  R\        4      V n        \        4       V n        RV n        RV n        RV n        RV n        R# )zexpected CLIENT or SERVER, not NF)_max_incomplete_event_sizer   r    Z
ValueErrorrV   
their_roler   _cstate_get_io_objectr%   _writerr   _readerr   _receive_buffer_receive_buffer_closedtheir_http_version_request_method"client_is_waiting_for_100_continue)selfrV   rW      &&&r2   __init__ZConnection.__init__   s    
 +D'FF++>xlKLL v$DO$DO&( **4==$H**4??D'J  - ',# 4804 38/r1   c                sV   < V ^8  d   QhRS[ S[S[,          S[S[,          3,          /# r5   r7   )r   r	   r$   rX   rZ   r2   r<   r[      s&     ) )T(^T(^;< )r1   c                s@    \        V P                  P                  4      # )zqA dictionary like::

   {CLIENT: <client state>, SERVER: <server state>}

See :ref:`state-machine` for details.

)dictr^   statesrg      &r2   rl   ZConnection.states   s     DLL''((r1   c                0   < V ^8  d   QhRS[ S[,          /# rj   r	   r$   rX   rZ   r2   r<   r[      s     2 24> 2r1   c                P    V P                   P                  V P                  ,          # )zZThe current state of whichever role we are playing. See
:ref:`state-machine` for details.
)r^   rl   rV   rm   rn   r2   	our_stateZConnection.our_state   s    
 ||""4==11r1   c                ro   rj   rp   rX   rZ   r2   r<   r[      s     4 4T(^ 4r1   c                rq   )z^The current state of whichever role we are NOT playing. See
:ref:`state-machine` for details.
)r^   rl   r]   rm   rn   r2   their_stateZConnection.their_state   s    
 ||""4??33r1   c                s    < V ^8  d   QhRS[ /# rj   )r8   rX   rZ   r2   r<   r[      s     U U4 Ur1   c                sN    V P                   \        J ;'       d    V P                  # N)r]   r   rf   rm   rn   r2   !they_are_waiting_for_100_continueZ,Connection.they_are_waiting_for_100_continue   s    &(TTT-T-TTr1   c                   < V ^8  d   QhRR/# r5   r7   Nr*   rX   rZ   r2   r<   r[      s     3 3$ 3r1   c                s    \        V P                  P                  4      pV P                  P                  4        RV n        V P                  V4       R# )aI  Attempt to reset our connection state for a new request/response
cycle.

If both client and server are in :data:`DONE` state, then resets them
both to :data:`IDLE` state in preparation for a new request/response
cycle on this same connection. Otherwise, raises a
:exc:`LocalProtocolError`.

See :ref:`keepalive-and-pipelining`.

N)rk   r^   rl   start_next_cyclere   _respond_to_state_changes)rg   
old_statesrC   r2   rx   ZConnection.start_next_cycle   s@     $,,--.
%%'# 	&&z2r1   c                s4   < V ^8  d   QhRS[ S[,          RR/# )r5   roler7   Nrp   rX   rZ   r2   r<   r[      s     3 34> 3d 3r1   c                s    \        V P                  P                  4      pV P                  P                  V4       V P	                  V4       R # rt   )rk   r^   rl   Zprocess_errorry   )rg   r{   rz      && r2   _process_errorZConnection._process_error   s6    $,,--.
""4(&&z2r1   c                F   < V ^8  d   QhRS[ RS[S[S[,          ,          /# r4   )r   r   r	   r$   rX   rZ   r2   r<   r[     s$     	 	% 	HT(^4L 	r1   c                s   \        V4      \        J d   VP                  ^e8X  d   \        # \        V4      \        J dC   \
        V P                  P                  9   d$   ^VP                  u;8:  d   R8  d    \
        #  R# R# )ie   rK   N)rQ   r   rR   r   r   r   r^   Zpending_switch_proposalsrg   r6      &&r2   _server_switch_eventZConnection._server_switch_event  sc    ;//E4E4E4L"";("4<<#H#HH5,,2s2&& 3 r1   c                rU   )r5   r{   r6   r7   N)r	   r$   r   rX   rZ   r2   r<   r[     s&     .: .:4> .:% .:D .:r1   c                s   \        V P                  P                  4      pV\        J d   \	        V4      \
        J dl   VP                  R 8X  d    V P                  P                  \        4       \        VP                  R4      '       d    V P                  P                  \        4       RpV\        J d   V P                  V4      pV P                  P                  V\	        V4      V4       \	        V4      \
        J d   VP                  V n        WP                   J dW   \	        V4      \
        \"        \$        39   d8   \'        \(        \
        \"        \$        3,          V4      pVP*                  V n        \	        V4      \
        \"        39   dK   \/        \'        \(        \
        \"        3,          V4      4      '       g   V P                  P1                  4        \	        V4      \
        J d   \3        V4      '       d   RV n        \	        V4      \$        \"        39   d   RV n        V\        J d"   \	        V4      \6        \8        39   d   RV n        V P;                  W24       R# )rJ   s   upgradeNTF)rk   r^   rl   r   rQ   r   ZmethodZprocess_client_switch_proposalr   r   rA   r   r    r   Zprocess_eventre   r]   r   r   r   r
   r?   rd   rD   Zprocess_keep_alive_disabledr   rf   r   r   ry   )rg   r{   r6   rz   Zserver_switch_events   &&&  r2   _process_eventZConnection._process_event  s    $,,--.
6>d5kW4||z);;OLz::;;OL"6>"&";";E"B""4e6IJ ;'!#(<<D ??"tE{!7
 (

 w2GGH%PE&+&8&8D# ;7H--kw()517
 7
 LL446 ;'!&=e&D&D6:D3;0(;;6;D36>d5kdL-AA6;D3&&z9r1   c                s   < V ^8  d   QhRS[ S[,          RS[S[,          RS[S[S[3,          RS[S[RS[3,          ,          /# )r5   r{   r6   io_dictr7   .)	r	   r$   r   r   r
   r   r&   r   r   rX   rZ   r2   r<   r[   @  sS     . .8n. . {K/0	.
 
(38$	%.r1   c                s.   V P                   P                  V,          pV\        J d^   \        \	        \
        V P                  4      \	        \        \        \        3,          V4      4      w  rVV\        ,          V,          ! V!  # VP                  W34      # rt   )r^   rl   r   rT   r   rF   re   r
   r   r   Zget)rg   r{   r6   r   stateframing_typeZargss   &&&&   r2   r_   ZConnection._get_io_object@  s}     ##D)I "/UD0014gx>O8PRW3X"L 9%l3T:: ;;}--r1   Nc                sp   < V ^8  d   QhRS[ S[S[,          S[S[,          3,          RS[S[,          RR/# )r5   rz   r6   r7   N)r   r	   r$   r   r   rX   rZ   r2   r<   r[   V  sD     	P 	Phh78	P 	P 
		Pr1   c                s&   V P                   WP                  ,          8w  d'   V P                  V P                  V\        4      V n        V P
                  WP                  ,          8w  d)   V P                  V P                  V\        4      V n        R # R # rt   )	rr   rV   r_   r%   r`   rs   r]   r   ra   )rg   rz   r6   rh   r2   ry   Z$Connection._respond_to_state_changesV  se     >>Z66..t}}eWMDLz//::..twODL ;r1   c                s6   < V ^8  d   QhRS[ S[S[3,          /# rj   )r   rF   r8   rX   rZ   r2   r<   r[   b  s      J JuUD[1 Jr1   c                sD    \        V P                  4      V P                  3# )a:  Data that has been received, but not yet processed, represented as
a tuple with two elements, where the first is a byte-string containing
the unprocessed data itself, and the second is a bool that is True if
the receive connection was closed.

See :ref:`switching-protocols` for discussion of why you'd want this.
)rF   rb   rc   rm   rn   r2   trailing_dataZConnection.trailing_dataa  s      d**+T-H-HIIr1   c                $   < V ^8  d   QhRS[ RR/# )r5   datar7   N)rF   rX   rZ   r2   r<   r[   l  s     ,/ ,/ ,/4 ,/r1   c                s    V'       d9   V P                   '       d   \        R4      hV ;P                  V,          un        R# RV n         R# )a  Add data to our internal receive buffer.

This does not actually do any processing on the data, just stores
it. To trigger processing, you have to call :meth:`next_event`.

Args:
    data (:term:`bytes-like object`):
        The new data that was just received.

        Special case: If *data* is an empty byte-string like ``b""``,
        then this indicates that the remote side has closed the
        connection (end of file). Normally this is convenient, because
        standard Python APIs like :meth:`file.read` or
        :meth:`socket.recv` use ``b""`` to indicate end-of-file, while
        other failures to read are indicated using other mechanisms
        like raising :exc:`TimeoutError`. When using such an API you
        can just blindly pass through whatever you get from ``read``
        to :meth:`receive_data`, and everything will work.

        But, if you have an API where reading an empty string is a
        valid non-EOF condition, then you need to be aware of this and
        make sure to check for such strings and avoid passing them to
        :meth:`receive_data`.

Returns:
    Nothing, but after calling this you should call :meth:`next_event`
    to parse the newly received data.

Raises:
    RuntimeError:
        Raised if you pass an empty *data*, indicating EOF, and then
        pass a non-empty *data*, indicating more data that somehow
        arrived after the EOF.

        (Calling ``receive_data(b"")`` multiple times is fine,
        and equivalent to calling it once.)

z(received close, then received more data?TN)rc   ZRuntimeErrorrb   )rg   r   r   r2   receive_dataZConnection.receive_datal  s9    N ***"#MNN  D( *.D'r1   c                Z   < V ^8  d   QhRS[ S[S[S[,          S[S[,          3,          /# rj   r
   r   r	   r(   r)   rX   rZ   r2   r<   r[     s)      	ud9otF|3	4r1   c                s   V P                   pV\        J d   V P                  '       d   \        # V\        J g   V\
        J d   \        # V P                  V P                  4      pVff   V P                  '       gT   V P                  '       dB   \        V P                  R4      '       d   V P                  P                  4       pM
\        4       pVf   \        pV# )Nread_eof)rs   r   rb   r)   r   r!   ra   rc   Zhasattrr   r   r(   )rg   r   r6      &  r2   _extract_next_receive_eventZ&Connection._extract_next_receive_event  s       
 D=T111M))U6G-GMT112='''D,G,G,G
 4<<44 LL113E,.E=Er1   c                r   rj   r   rX   rZ   r2   r<   r[     s(     ? ?E%i$v,"FG ?r1   c                sB   V P                   \        J d   \        R4      h V P                  4       pV\        \
        39  d+   V P                  V P                  \        \        V4      4       V\        J dO   \        V P                  4      V P                  8  d   \        RRR7      hV P                  '       d   \        R4      hV#   \         dN   pT P                  T P                  4       \!        T\"        4      '       d   TP%                  4         Rp?R# h Rp?ii ; i)an  Parse the next event out of our receive buffer, update our internal
state, and return it.

This is a mutating operation -- think of it like calling :func:`next`
on an iterator.

Returns:
    : One of three things:

    1) An event object -- see :ref:`events`.

    2) The special constant :data:`NEED_DATA`, which indicates that
       you need to read more data from your socket and pass it to
       :meth:`receive_data` before this method will be able to return
       any more events.

    3) The special constant :data:`PAUSED`, which indicates that we
       are not in a state where we can process incoming data (usually
       because the peer has finished their part of the current
       request/response cycle, and you have not yet called
       :meth:`start_next_cycle`). See :ref:`flow-control` for details.

Raises:
    RemoteProtocolError:
        The peer has misbehaved. You should close the connection
        (possibly after sending some kind of 4xx response).

Once this method returns :class:`ConnectionClosed` once, then all
subsequent calls will also return :class:`ConnectionClosed`.

If this method raises any exception besides :exc:`RemoteProtocolError`
then that's a bug -- if it happens please file a bug report!

If this method raises any exception then it also sets
:attr:`Connection.their_state` to :data:`ERROR` -- see
:ref:`error-handling` for discussion.

z+Can't receive data when peer state is ERRORzReceive buffer too longi  )Zerror_status_hintz#peer unexpectedly closed connectionN)rs   r   r#   r   r(   r)   r   r]   r   r   Zlenrb   r\   rc   ZBaseExceptionr}   Z
isinstancer"   Z!_reraise_as_remote_protocol_error)rg   r6   Zexcr   r2   
next_eventZConnection.next_event  s    P u$%&STT	446EY//##DOOT%5GH	!t++,t/N/NN .1S  ... ..STTL 	0#1225577	s%   BC 9C DADDDc                r   )r5   r6   r7   N)r   rX   rZ   r2   r<   r[     s      * t r1   c                    R # rt   r*   r   r   r2   sendConnection.send      r1   c                sH   < V ^8  d   QhRS[ S[S[S[S[S[3,          RS[/# r4   )r
   r   r   r   r   r   rF   rX   rZ   r2   r<   r[     s.      7$98T<WX	r1   c                r   rt   r*   r   r   r2   r   r     s     	r1   c                6   < V ^8  d   QhRS[ RS[S[,          /# r4   r   r   rF   rX   rZ   r2   r<   r[     s      % HUO r1   c                r   rt   r*   r   r   r2   r   r     r   r1   c                r   r4   r   rX   rZ   r2   r<   r[     s     ' '% 'HUO 'r1   c                sR    V P                  V4      pVf   R# RP                  V4      # )aC  Convert a high-level event into bytes that can be sent to the peer,
while updating our internal state machine.

Args:
    event: The :ref:`event <events>` to send.

Returns:
    If ``type(event) is ConnectionClosed``, then returns
    ``None``. Otherwise, returns a :term:`bytes-like object`.

Raises:
    LocalProtocolError:
        Sending this event at this time would violate our
        understanding of the HTTP/1.1 protocol.

If this method raises any exception then it also sets
:attr:`Connection.our_state` to :data:`ERROR` -- see
:ref:`error-handling` for discussion.

Nr1   )send_with_data_passthroughZjoin)rg   r6   	data_listr|   r2   r   r     s,    * 33E:	88I&&r1   c                r~   r4   )r   r   r   rF   rX   rZ   r2   r<   r[      s$       (4;:O r1   c                sr   V P                   \        J d   \        R4      h \        V4      \        J d   V P                  V4      pV P                  pV P                  V P                  V4       \        V4      \        J d   R# . pV! WP                  4       V#    T P                  T P                  4       h ; i)a@  Identical to :meth:`send`, except that in situations where
:meth:`send` returns a single :term:`bytes-like object`, this instead
returns a list of them -- and when sending a :class:`Data` event, this
list is guaranteed to contain the exact object you passed in as
:attr:`Data.data`. See :ref:`sendfile` for discussion.

z'Can't send data when our state is ERRORN)rr   r   r"   rQ   r   &_clean_up_response_headers_for_sendingr`   r   rV   r   Zappendr}   )rg   r6   Zwriterr   rS   r2   r   Z%Connection.send_with_data_passthrough   s     >>U"$%NOO	E{h&CCEJ \\Fu5E{..
 *,	u../  	.s   AB B B6c                rv   rw   r*   rX   rZ   r2   r<   r[   A  s     + +T +r1   c                s<    V P                  V P                  4       R# )zNotify the state machine that we failed to send the data it gave
us.

This causes :attr:`Connection.our_state` to immediately become
:data:`ERROR` -- see :ref:`error-handling` for discussion.

N)r}   rV   rm   rn   r2   send_failedZConnection.send_failedA  s     	DMM*r1   c                s&   < V ^8  d   QhRS[ RS[ /# )r5   responser7   )r   rX   rZ   r2   r<   r[   Z  s     9
 9
x 9
H 9
r1   c                s~   VP                   pR p\        \        V P                  4      pVR8X  d   Rp\	        WA4      w  rVVR9   d\   \        VR. 4      pV P                  e   V P                  R8  d"   \        VR. 4      pV P                  R8w  d   RpM\        VRR.4      pV P                  P                  '       d	   V'       dN   \        \        VR4      4      pVP                  R	4       VP                  R
4       \        VR\        V4      4      p\        VVP                  VP                   VP"                  R7      # )FrI   s   GETrN   r@   rM   Ts   chunkedr=   s
   keep-aliver>   )rA   rR   r?   reason)rO   rP   )rA   r   rF   re   rT   r   rd   r^   Z
keep_aliveZsetr   ZdiscardZaddZsortedr   rR   r?   r   )rg   r   rA   Z
need_closeZmethod_for_choosing_headersr   Z_rB   s   &&      r2   r   Z1Connection._clean_up_response_headers_for_sendingZ  s)    ""
 '+5$2F2F&G#&'1*0''(CN22 'w0A2FG&&.$2I2IF2R
 +74H"M
 ''72!%J*74H:,W||&&&*-g}EFJ}-NN8$&wvj?QRG ,,!..??	
 	
r1   )r^   r\   ra   rb   rc   re   r`   rf   rV   rd   r]   rt   )r,   r-   r.   r/   Z__doc__!DEFAULT_MAX_INCOMPLETE_EVENT_SIZEri   Zpropertyrl   rr   rs   ru   rx   r}   r   r   r_   ry   r   r   r   r   r   r   r   r   r   r0   Z__classdictcell__)rY   s   @r2   r'   r'      sG    $ *K%8 %8N ) ) 2 2 4 4 U U3 3(3 3
	 	.: .:`. .,	P 	P J J,/ ,/\ 8? ?B    
  ' '6 B+ +29
 9
r1   N)r'   r(   r)   i @  )5Ztypingr   r   r   r   r   r   r   r   r	   r
   Z_eventsr   r   r   r   r   r   r   Z_headersr   r   r   Z_readersr   r   Z_receivebufferr   Z_stater   r   r   r   r   r   r   r   r    r!   Z_utilr"   r#   r$   Z_writersr%   r&   Z__all__r(   r)   r   rD   rT   r'   r*   r1   r2   <module>r      s        R Q * )   
 + 0	H 		X 	 %. !0 t|
 |
r1   