SSE (Server Sent Events)¶
- class litestar.response.sse.ServerSentEventMessage[原始碼]¶
基底類別:
objectServerSentEventMessage(data: 'str | int | bytes | None' = '', event: 'str | None' = None, id: 'int | str | None' = None, retry: 'int | None' = None, comment: 'str | None' = None, sep: 'str' = 'rn')
- class litestar.response.sse.ServerSentEvent[原始碼]¶
基底類別:
Stream- __init__(content: str | bytes | StreamType[SSEData], *, background: BackgroundTask | BackgroundTasks | None = None, cookies: ResponseCookies | None = None, encoding: str = 'utf-8', headers: ResponseHeaders | None = None, event_type: str | None = None, event_id: int | str | None = None, retry_duration: int | None = None, comment_message: str | None = None, status_code: int | None = None) None[原始碼]¶
Initialize the response.
- 參數:
content¶ -- Bytes, string or a sync or async iterator or iterable.
background¶ -- A
BackgroundTaskinstance orBackgroundTasksto execute after the response is finished. Defaults to None.cookies¶ -- A list of
Cookieinstances to be set under the responseSet-Cookieheader.encoding¶ -- The encoding to be used for the response headers.
headers¶ -- A string keyed dictionary of response headers. Header keys are insensitive.
status_code¶ -- The response status code. Defaults to 200.
event_type¶ -- The type of the SSE event. If given, the browser will sent the event to any 'event-listener' declared for it (e.g. via 'addEventListener' in JS).
event_id¶ -- The event ID. This sets the event source's 'last event id'.
retry_duration¶ -- Retry duration in milliseconds.
comment_message¶ -- A comment message. This value is ignored by clients and is used mostly for pinging.