|
Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
|
Abstract interface for writing HTTP responses. More...
#include <ResponseWriter.hpp>

Public Types | |
| using | Interceptor = std::function< void(HttpResponse &)> |
Public Member Functions | |
| virtual | ~ResponseWriter ()=default |
| virtual void | add_interceptor (Interceptor interceptor)=0 |
| Adds an interceptor to modify the response before it is sent. | |
| virtual void | set_header (const std::string &key, const std::string &value)=0 |
| Adds a default header that will be included in the final response. | |
| virtual network::Proactor & | proactor ()=0 |
| Gets the underlying Proactor to dispatch async operations. | |
| virtual concurrency::ThreadPool & | thread_pool ()=0 |
| Gets the thread pool to offload blocking tasks. | |
| virtual void | send (HttpResponse &&response)=0 |
| Sends a complete HTTP response. | |
| virtual void | send_headers (HttpResponse &response)=0 |
| Sends only the HTTP headers. | |
| virtual void | write_chunk (std::string_view chunk)=0 |
| Streams a chunk of data (for Chunked Transfer Encoding). | |
| virtual void | end ()=0 |
| Ends a chunked response stream. | |
| virtual void | send_sse_event (std::string_view data, std::string_view event="", std::string_view id="")=0 |
| Sends a Server-Sent Events (SSE) message. | |
| virtual void | upgrade_to_raw_stream (std::function< void(std::string_view)> on_data, std::function< void()> on_close)=0 |
| Upgrades the connection to a raw bi-directional byte stream. | |
| virtual void | read_body_stream (std::function< void(std::string_view)> on_data, std::function< void()> on_end)=0 |
| Asynchronously streams the incoming HTTP request body. | |
Abstract interface for writing HTTP responses.
This is used by middlewares and route handlers to write data back to the client.
| using http::ResponseWriter::Interceptor = std::function<void(HttpResponse&)> |
|
virtualdefault |
|
pure virtual |
Adds an interceptor to modify the response before it is sent.
| interceptor | The interceptor callback. |
Implemented in http::h2::Http2ResponseWriter.
|
pure virtual |
Ends a chunked response stream.
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Gets the underlying Proactor to dispatch async operations.
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Asynchronously streams the incoming HTTP request body.
| on_data | Callback invoked when a body chunk is received. |
| on_end | Callback invoked when the entire body has been read. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Sends a complete HTTP response.
Takes ownership of any file descriptors managed by the response.
| response | The HttpResponse to send. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Sends only the HTTP headers.
Useful for streaming bodies or Server-Sent Events.
| response | The HttpResponse containing the headers to send. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Sends a Server-Sent Events (SSE) message.
| data | The event data payload. |
| event | The event type/name (optional). |
| id | The event ID (optional). |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Adds a default header that will be included in the final response.
| key | The header name. |
| value | The header value. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Gets the thread pool to offload blocking tasks.
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Upgrades the connection to a raw bi-directional byte stream.
| on_data | Callback invoked when data is received. |
| on_close | Callback invoked when the stream is closed. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.
|
pure virtual |
Streams a chunk of data (for Chunked Transfer Encoding).
| chunk | The data chunk to write. |
Implemented in http::h2::Http2ResponseWriter, and server::Connection.