|
cwist
Modern C web framework with libttak runtime
|
HTTP Response Object. Supports standard string body or Zero-Copy pointer body. More...
#include <http.h>

Public Attributes | |
| cwist_sstring * | version |
| e.g., "HTTP/1.1" | |
| cwist_http_status_t | status_code |
| cwist_sstring * | status_text |
| e.g., "OK" | |
| cwist_http_header_node * | headers |
| cwist_sstring * | body |
| bool | keep_alive |
| cwist_endpoint_opt_t | endpoint_opts |
| Mirrors req->endpoint_opts. | |
| bool | is_ptr_body |
| Zero-Copy Pointer Body. | |
| const void * | ptr_body |
| Pointer to external data (e.g., mmap region) | |
| size_t | ptr_body_len |
| Length of external data. | |
| cwist_http_body_cleanup_fn | ptr_body_cleanup |
| Optional release hook. | |
| void * | ptr_body_cleanup_ctx |
| User data for release hook. | |
| bool | use_file_stream |
| Fast File Streaming. | |
| int | file_stream_fd |
| Open descriptor for sendfile. | |
| size_t | file_stream_len |
| Total bytes to stream. | |
| off_t | file_stream_offset |
| Current offset for sendfile loop. | |
| bool | file_stream_auto_close |
| Close fd after streaming. | |
| bool | stream_mode |
| cwist_http_response_stream_begin() ran. | |
| bool | stream_ended |
| cwist_http_response_stream_end() ran. | |
| bool | stream_failed |
| A live sink rejected a chunk/head. | |
| cwist_sstring * | stream_buf |
| Framed chunk payload (hex\r\ndata\r ...). | |
| size_t | stream_flushed |
| stream_buf prefix already pushed to stream_sink. | |
| int(* | stream_sink )(void *ctx, const char *data, size_t len) |
| Live sink (streaming dispatch only). | |
| void * | stream_sink_ctx |
| bool | stream_head_sent |
| Head serialized and pushed to the sink. | |
| char * | alt_svc |
| Alt-Svc header for HTTP/3 upgrade advertisement. | |
| void * | arena |
| Per-response arena for bump-allocated structs (internal). | |
| bool | arena_borrowed |
| bool | deferred |
| Deferred-response handoff (internal; see net/http/async.h) | |
| void * | async |
| Owning cwist_async while deferred (read-only). | |
HTTP Response Object. Supports standard string body or Zero-Copy pointer body.
| char* cwist_http_response::alt_svc |
Alt-Svc header for HTTP/3 upgrade advertisement.
Definition at line 237 of file http.h.
Referenced by cwist_http_response_destroy(), and cwist_http_response_set_alt_svc().
| void* cwist_http_response::arena |
Per-response arena for bump-allocated structs (internal).
Definition at line 239 of file http.h.
Referenced by cwist_http_response_add_hsts(), cwist_http_response_add_security_headers(), cwist_http_response_destroy(), cwist_http_response_stream_end(), and cwist_http_response_stream_write().
| bool cwist_http_response::arena_borrowed |
True when arena is shared (e.g. the request's) and must not be destroyed here.
Definition at line 240 of file http.h.
Referenced by cwist_http_response_destroy().
| void* cwist_http_response::async |
Owning cwist_async while deferred (read-only).
Definition at line 245 of file http.h.
Referenced by cwist_async_defer(), and cwist_async_dispatch_take().
| cwist_sstring * cwist_http_response::body |
Definition at line 87 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_app_healthz(), cwist_assets_respond(), cwist_async_abort(), cwist_async_respond(), cwist_bind_write_error_response(), cwist_graphql_serve(), cwist_grpc_set_response(), cwist_grpc_stream_send(), cwist_http2_push_resource(), cwist_http_async_send_response(), cwist_http_response_add_oob(), cwist_http_response_destroy(), cwist_http_response_html_redirect(), cwist_http_response_send_file(), cwist_http_response_serialize(), cwist_http_response_set_html(), cwist_http_response_stream_begin(), cwist_http_send_response(), cwist_http_send_response_async(), cwist_http_send_response_coalesced(), cwist_http_stringify_response(), cwist_https_send_response(), cwist_metrics_serve_http(), cwist_sse_response_comment(), and cwist_sse_response_event().
| bool cwist_http_response::deferred |
Deferred-response handoff (internal; see net/http/async.h)
Handler deferred the response via cwist_async_defer (read-only).
Definition at line 244 of file http.h.
Referenced by cwist_async_defer(), cwist_async_dispatch_take(), and cwist_async_res_deferred().
| cwist_endpoint_opt_t cwist_http_response::endpoint_opts |
Mirrors req->endpoint_opts.
Definition at line 206 of file http.h.
Referenced by cwist_http_response_send_file().
| bool cwist_http_response::file_stream_auto_close |
Close fd after streaming.
Definition at line 220 of file http.h.
Referenced by cwist_http_response_send_file().
| int cwist_http_response::file_stream_fd |
Open descriptor for sendfile.
Definition at line 217 of file http.h.
Referenced by cwist_http_response_send_file(), and cwist_https_send_response().
| size_t cwist_http_response::file_stream_len |
Total bytes to stream.
Definition at line 218 of file http.h.
Referenced by cwist_http_response_send_file(), and cwist_https_send_response().
| off_t cwist_http_response::file_stream_offset |
Current offset for sendfile loop.
Definition at line 219 of file http.h.
Referenced by cwist_http_response_send_file(), and cwist_https_send_response().
| cwist_http_header_node * cwist_http_response::headers |
Definition at line 86 of file http.h.
Referenced by cwist_app_healthz(), cwist_async_abort(), cwist_async_respond(), cwist_bind_write_error_response(), cwist_graphql_serve(), cwist_grpc_set_response(), cwist_grpc_stream_close(), cwist_grpc_stream_set_retry_pushback(), cwist_http2_push_resource(), cwist_http_response_add_hsts(), cwist_http_response_add_security_headers(), cwist_http_response_destroy(), cwist_http_response_html_redirect(), cwist_http_response_send_file(), cwist_https_send_response(), cwist_https_send_response_head(), cwist_metrics_serve_http(), cwist_mw_cors_handler(), cwist_mw_request_id_handler(), cwist_sse_response_init(), and cwist_websocket_upgrade_response().
| bool cwist_http_response::is_ptr_body |
Zero-Copy Pointer Body.
If true, body data is read from ptr_body
Definition at line 209 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_http_async_send_response(), cwist_http_response_serialize(), cwist_http_response_set_body_ptr_managed(), cwist_http_response_stream_begin(), cwist_http_send_response(), cwist_http_send_response_async(), cwist_http_send_response_coalesced(), cwist_http_stringify_response(), and cwist_https_send_response().
| bool cwist_http_response::keep_alive |
Definition at line 88 of file http.h.
Referenced by cwist_app_dispatch_memory(), cwist_app_dispatch_stream(), cwist_async_defer(), and cwist_sse_response_init().
Pointer to external data (e.g., mmap region)
Definition at line 210 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_http_async_send_response(), cwist_http_response_serialize(), cwist_http_response_set_body_ptr_managed(), cwist_http_send_response(), cwist_http_send_response_async(), cwist_http_send_response_coalesced(), cwist_http_stringify_response(), and cwist_https_send_response().
| cwist_http_body_cleanup_fn cwist_http_response::ptr_body_cleanup |
Optional release hook.
Definition at line 212 of file http.h.
Referenced by cwist_http_response_set_body_ptr_managed().
| void* cwist_http_response::ptr_body_cleanup_ctx |
User data for release hook.
Definition at line 213 of file http.h.
Referenced by cwist_http_response_set_body_ptr_managed().
| size_t cwist_http_response::ptr_body_len |
Length of external data.
Definition at line 211 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_http_async_send_response(), cwist_http_response_serialize(), cwist_http_response_set_body_ptr_managed(), cwist_http_send_response(), cwist_http_send_response_async(), cwist_http_send_response_coalesced(), cwist_http_stringify_response(), and cwist_https_send_response().
| cwist_http_status_t cwist_http_response::status_code |
Definition at line 84 of file http.h.
Referenced by cwist_app_healthz(), cwist_assets_respond(), cwist_async_abort(), cwist_async_respond(), cwist_bind_write_error_response(), cwist_graphql_serve(), cwist_grpc_set_response(), cwist_http2_push_resource(), cwist_http_response_html_redirect(), cwist_http_response_send_file(), cwist_metrics_serve_http(), cwist_mw_cors_handler(), and cwist_websocket_upgrade_response().
| cwist_sstring * cwist_http_response::status_text |
e.g., "OK"
Definition at line 85 of file http.h.
Referenced by cwist_async_abort(), cwist_async_respond(), cwist_bind_write_error_response(), cwist_http_response_destroy(), and cwist_websocket_upgrade_response().
| cwist_sstring* cwist_http_response::stream_buf |
Framed chunk payload (hex\r\ndata\r
...).
Definition at line 228 of file http.h.
Referenced by cwist_http_response_destroy(), cwist_http_response_serialize(), cwist_http_response_stream_end(), and cwist_http_response_stream_write().
| bool cwist_http_response::stream_ended |
cwist_http_response_stream_end() ran.
Definition at line 226 of file http.h.
Referenced by cwist_app_dispatch_memory(), cwist_app_dispatch_stream(), cwist_http_response_serialize(), cwist_http_response_stream_end(), and cwist_http_response_stream_write().
| bool cwist_http_response::stream_failed |
A live sink rejected a chunk/head.
Definition at line 227 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_http_response_stream_end(), and cwist_http_response_stream_write().
| size_t cwist_http_response::stream_flushed |
| bool cwist_http_response::stream_head_sent |
| bool cwist_http_response::stream_mode |
cwist_http_response_stream_begin() ran.
Streaming producer (handlers generate the body chunk-by-chunk; issue #201 Phase 1). Chunked framing is appended to stream_buf at write time, so the memory and streaming boundaries emit identical bytes.
Definition at line 225 of file http.h.
Referenced by cwist_app_dispatch_memory(), cwist_app_dispatch_stream(), cwist_http_response_serialize(), cwist_http_response_stream_begin(), cwist_http_response_stream_end(), and cwist_http_response_stream_write().
Live sink (streaming dispatch only).
Definition at line 230 of file http.h.
Referenced by cwist_app_dispatch_stream().
| void* cwist_http_response::stream_sink_ctx |
Definition at line 231 of file http.h.
Referenced by cwist_app_dispatch_stream().
| bool cwist_http_response::use_file_stream |
Fast File Streaming.
True when sendfile/splice path is used.
Definition at line 216 of file http.h.
Referenced by cwist_app_dispatch_stream(), cwist_http_async_send_response(), cwist_http_response_send_file(), cwist_http_response_serialize(), cwist_http_response_stream_begin(), cwist_http_send_response(), cwist_http_send_response_async(), cwist_http_send_response_coalesced(), and cwist_https_send_response().
| cwist_sstring * cwist_http_response::version |