+
    Xj                       a  R  t0 t ^ RIHtHt ^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHt RRRRRR	/R
RR	/RRR	/RRRR^ ///t] ^ k  ! R R]4      tR R ltR R ltR R lt ! R R]4      tRRR
RRRRRRR/R R lltRtRt] ^k R# )!    )	AnnotatedAny)Doc)AfterValidator	BaseModelFieldmodel_validator)StreamingResponsetypeobject
propertiesdatastringeventidretryintegerminimumc                       ] tR t^tRtRtRtR# )EventSourceResponsea  Streaming response with `text/event-stream` media type.

Use as `response_class=EventSourceResponse` on a *path operation* that uses `yield`
to enable Server Sent Events (SSE) responses.

Works with **any HTTP method** (`GET`, `POST`, etc.), which makes it compatible
with protocols like MCP that stream SSE over `POST`.

The actual encoding logic lives in the FastAPI routing layer. This class
serves mainly as a marker and sets the correct `Content-Type`.
ztext/event-stream N)__name__
__module____qualname____firstlineno____doc__
media_type__static_attributes__r       g   /Users/wind/Downloads/Coruna-main学习资料A/backend/venv/lib/python3.14/site-packages/fastapi/sse.pyr   r      s    
 %Jr   r   c                X    V ^8  d   QhR\         R,          R\         R\         R,          /# )   vN
field_namereturnstr)formats   "r    __annotate__r)   $   s)      #* # #* r   c                 H    V e   RV 9   g   RV 9   d   \        RV R24      hV # )N
zSSE 'z' must be a single line)
ValueError)r#   r$   s   &&r    _check_single_liner.   $   s-    }$!)tqy5,CDEEHr   c                L    V ^8  d   QhR\         R,          R\         R,          /# r"   r#   Nr%   r&   )r(   s   "r    r)   r)   *   s"     * *d
 *sTz *r   c                     \        V R 4      # )r   )r.   r#   s   &r    _check_event_single_liner3   *   s    a))r   c                L    V ^8  d   QhR\         R,          R\         R,          /# r0   r&   )r(   s   "r    r)   r)   .   s"     ' 'sTz 'cDj 'r   c                 F    V e   RV 9   d   \        R4      h\        V R4      # )N z)SSE 'id' must not contain null charactersr   )r-   r.   r2   s   &r    _check_id_validr7   .   s&    }DEEa&&r   c                   r   a  ] tR t^4t o RtRtRtRtRtRt	Rt
]! RR7      V 3R lR l4       tV 3R ltRtV tR# )	ServerSentEventaL  Represents a single Server-Sent Event.

When `yield`ed from a *path operation function* that uses
`response_class=EventSourceResponse`, each `ServerSentEvent` is encoded
into the [SSE wire format](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream)
(`text/event-stream`).

If you yield a plain object (dict, Pydantic model, etc.) instead, it is
automatically JSON-encoded and sent as the `data:` field.

All `data` values **including plain strings** are JSON-serialized.

For example, `data="hello"` produces `data: "hello"` on the wire (with
quotes).
Nafter)modec                   < V ^8  d   QhRR/# )r"   r%   r9   r   )r(   __classdict__s   "r    r)   ServerSentEvent.__annotate__   s      '8 r   c                T    V P                   e   V P                  e   \        R4      hV # )NzCannot set both 'data' and 'raw_data' on the same ServerSentEvent. Use 'data' for JSON-serialized payloads or 'raw_data' for pre-formatted strings.)r   raw_datar-   )selfs   &r    _check_data_exclusive%ServerSentEvent._check_data_exclusive   s.    99 T]]%>; 
 r   c                  < V ^8  d   Qh/ S[ S[S[! R4      3,          ;R&   S[ S[R,          S[! R4      3,          ;R&   S[ S[R,          S[! S[4      S[! R4      3,          ;R&   S[ S[R,          S[! S[4      S[! R4      3,          ;R	&   S[ S[R,          S[! ^ R
7      S[! R4      3,          ;R&   S[ S[R,          S[! R4      3,          ;R&   # )r"   aB  
            The event payload.

            Can be any JSON-serializable value: a Pydantic model, dict, list,
            string, number, etc. It is **always** serialized to JSON: strings
            are quoted (`"hello"` becomes `data: "hello"` on the wire).

            Mutually exclusive with `raw_data`.
            r   NaQ  
            Raw string to send as the `data:` field **without** JSON encoding.

            Use this when you need to send pre-formatted text, HTML fragments,
            CSV lines, or any non-JSON payload. The string is placed directly
            into the `data:` field as-is.

            Mutually exclusive with `data`.
            r@   z
            Optional event type name.

            Maps to `addEventListener(event, ...)` on the browser. When omitted,
            the browser dispatches on the generic `message` event. Must be a
            single line.
            r   z
            Optional event ID.

            The browser sends this value back as the `Last-Event-ID` header on
            automatic reconnection. **Must be a single line** and must not contain
            null (`\0`) characters.
            r   )gez
            Optional reconnection time in **milliseconds**.

            Tells the browser how long to wait before reconnecting after the
            connection is lost. Must be a non-negative integer.
            r   z
            Optional comment line(s).

            Comment lines start with `:` in the SSE wire format and are ignored by
            `EventSource` clients. Useful for keep-alive pings to prevent
            proxy/load-balancer timeouts.
            comment)	r   r   r   r'   r   r3   r7   intr   )r(   r=   s   "r    r)   r>   4   s/    " 
	
	 # > d

	
	 ? Z d
/0	

	 [ t 	d
'	

		 u N d
	
		 O f d
	
		 g r   r   )r   r   r   r   r   r   r@   r   r   r   rF   r	   rB   __annotate_func__r   __classdictcell__)r=   s   @r    r9   r9   4   sg     : 	 	6 	 4 	 
2 	 0 	 
. 	  '" #C  r   r9   data_strNrF   c                   V ^8  d   QhR\         \        R,          \        R4      3,          R\         \        R,          \        R4      3,          R\         \        R,          \        R4      3,          R\         \        R,          \        R	4      3,          R
\         \        R,          \        R4      3,          R\        /# )r"   rJ   NzQ
            Pre-serialized data string to use as the `data:` field.
            r   zD
            Optional event type name (`event:` field).
            r   z:
            Optional event ID (`id:` field).
            r   zV
            Optional reconnection time in milliseconds (`retry:` field).
            rF   z@
            Optional comment line(s) (`:` prefix).
            r%   )r   r'   r   rG   bytes)r(   s   "r    r)   r)      s     D, D,d
	
	D, d
	
	D,$ 	d
	
		%D,4 d
	
	5D,D d
	
	ED,T UD,r   c                   . pVe,   VP                  4        F  pVP                  RV 24       K  	  Ve   VP                  RV 24       V e,   V P                  4        F  pVP                  RV 24       K  	  Ve   VP                  RV 24       Ve   VP                  RV 24       VP                  R4       VP                  R4       RP                  V4      P                  R4      # )	z|Build SSE wire-format bytes from **pre-serialized** data.

    The result always ends with `

` (the event terminator).
    z: zevent: zdata: zid: zretry:  r,   zutf-8)
splitlinesappendjoinencode)rJ   r   r   r   rF   lineslines   $$$$$  r    format_sse_eventrU      s    ^ E&&(DLL2dV% ) wug&''')DLL6$) * 
~tB4[!wug&'	LL	LL99U""7++r   s   : ping

g      .@c                    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   ^\         9   d
   \        ;R&   # )r"   _SSE_EVENT_SCHEMA_PING_INTERVAL)__conditional_annotations__dictr'   r   float)r(   s   "r    r)   r)      s:     ! ! 4S>  "T   U "r   )rY   typingr   r   annotated_docr   pydanticr   r   r   r	   starlette.responsesr
   rW   r   r.   r3   r7   r9   rU   KEEPALIVE_COMMENTrX   r)   )rY   s   @r    <module>ra      s    ! !  F F 1
 H"&(#vx &)Y2	%  %+ % *'hi hVD, 	D," 	#D,2 	3D,B 	CD,R 	SD,P "   r   