|
KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
|


Go to the source code of this file.
Data Structures | |
| struct | KlSse |
| SSE (Server-Sent Events) stream handle. More... | |
Functions | |
| int | kl_sse_begin (KlResponse *res, KlSse *sse) |
| Begin an SSE stream. | |
| int | kl_sse_event (KlSse *sse, const char *event, const char *data, size_t data_len, const char *id) |
| Send an SSE event. | |
| int | kl_sse_comment (KlSse *sse, const char *text, size_t len) |
| Send an SSE comment (keep-alive ping pattern). | |
| int | kl_sse_end (KlSse *sse) |
| End the SSE stream. | |
| int kl_sse_begin | ( | KlResponse * | res, |
| KlSse * | sse | ||
| ) |
Begin an SSE stream.
Sets Content-Type: text/event-stream, Cache-Control: no-cache, and starts a chunked streaming response at status 200.
| res | Response to stream on. |
| sse | SSE handle to initialize (caller-owned). |
| int kl_sse_event | ( | KlSse * | sse, |
| const char * | event, | ||
| const char * | data, | ||
| size_t | data_len, | ||
| const char * | id | ||
| ) |
Send an SSE event.
Writes event:/id:/data: fields followed by a blank line. NULL event or id omits that field. Multiline data is auto-split on '
' — each line gets its own "data: " prefix.
| sse | SSE handle from kl_sse_begin. |
| event | Event type (NULL to omit). |
| data | Event data (may contain ' ' for multiline). |
| data_len | Length of data in bytes. |
| id | Event ID (NULL to omit). |
| int kl_sse_comment | ( | KlSse * | sse, |
| const char * | text, | ||
| size_t | len | ||
| ) |
Send an SSE comment (keep-alive ping pattern).
Writes ": text\n". Comments are ignored by SSE clients but keep the connection alive through proxies.
| sse | SSE handle. |
| text | Comment text. |
| len | Length of text in bytes. |
| int kl_sse_end | ( | KlSse * | sse | ) |
End the SSE stream.
Sends the final zero-length chunk via kl_response_end_stream.
| sse | SSE handle. |