ResponseWriter implementation for HTTP/2 streams.
More...
#include <Http2Session.hpp>
|
| | Http2ResponseWriter (Http2Session *session, int32_t stream_id) |
| |
| void | add_interceptor (Interceptor interceptor) override |
| | Adds an interceptor to modify the response before it is sent.
|
| |
| void | set_header (const std::string &key, const std::string &value) override |
| | Adds a default header that will be included in the final response.
|
| |
| network::Proactor & | proactor () override |
| | Gets the underlying Proactor to dispatch async operations.
|
| |
| concurrency::ThreadPool & | thread_pool () override |
| | Gets the thread pool to offload blocking tasks.
|
| |
| void | send (http::HttpResponse &&response) override |
| | Sends a complete HTTP response.
|
| |
| void | send_headers (http::HttpResponse &response) override |
| | Sends only the HTTP headers.
|
| |
| void | write_chunk (std::string_view chunk) override |
| | Streams a chunk of data (for Chunked Transfer Encoding).
|
| |
| void | end () override |
| | Ends a chunked response stream.
|
| |
| void | send_sse_event (std::string_view data, std::string_view event="", std::string_view id="") override |
| | Sends a Server-Sent Events (SSE) message.
|
| |
| void | upgrade_to_raw_stream (std::function< void(std::string_view)> on_data, std::function< void()> on_close) override |
| | Upgrades the connection to a raw bi-directional byte stream.
|
| |
| void | read_body_stream (std::function< void(std::string_view)> on_data, std::function< void()> on_end) override |
| | Asynchronously streams the incoming HTTP request body.
|
| |
| virtual | ~ResponseWriter ()=default |
| |
ResponseWriter implementation for HTTP/2 streams.
◆ Http2ResponseWriter()
| http::h2::Http2ResponseWriter::Http2ResponseWriter |
( |
Http2Session * |
session, |
|
|
int32_t |
stream_id |
|
) |
| |
◆ add_interceptor()
| void http::h2::Http2ResponseWriter::add_interceptor |
( |
Interceptor |
interceptor | ) |
|
|
overridevirtual |
Adds an interceptor to modify the response before it is sent.
- Parameters
-
| interceptor | The interceptor callback. |
Implements http::ResponseWriter.
◆ end()
| void http::h2::Http2ResponseWriter::end |
( |
| ) |
|
|
overridevirtual |
◆ proactor()
◆ read_body_stream()
| void http::h2::Http2ResponseWriter::read_body_stream |
( |
std::function< void(std::string_view)> |
on_data, |
|
|
std::function< void()> |
on_end |
|
) |
| |
|
overridevirtual |
Asynchronously streams the incoming HTTP request body.
- Parameters
-
| on_data | Callback invoked when a body chunk is received. |
| on_end | Callback invoked when the entire body has been read. |
Implements http::ResponseWriter.
◆ send()
Sends a complete HTTP response.
Takes ownership of any file descriptors managed by the response.
- Parameters
-
Implements http::ResponseWriter.
◆ send_headers()
Sends only the HTTP headers.
Useful for streaming bodies or Server-Sent Events.
- Parameters
-
Implements http::ResponseWriter.
◆ send_sse_event()
| void http::h2::Http2ResponseWriter::send_sse_event |
( |
std::string_view |
data, |
|
|
std::string_view |
event = "", |
|
|
std::string_view |
id = "" |
|
) |
| |
|
overridevirtual |
Sends a Server-Sent Events (SSE) message.
- Parameters
-
| data | The event data payload. |
| event | The event type/name (optional). |
| id | The event ID (optional). |
Implements http::ResponseWriter.
◆ set_header()
| void http::h2::Http2ResponseWriter::set_header |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
| |
|
overridevirtual |
Adds a default header that will be included in the final response.
- Parameters
-
| key | The header name. |
| value | The header value. |
Implements http::ResponseWriter.
◆ thread_pool()
◆ upgrade_to_raw_stream()
| void http::h2::Http2ResponseWriter::upgrade_to_raw_stream |
( |
std::function< void(std::string_view)> |
on_data, |
|
|
std::function< void()> |
on_close |
|
) |
| |
|
overridevirtual |
Upgrades the connection to a raw bi-directional byte stream.
- Parameters
-
| on_data | Callback invoked when data is received. |
| on_close | Callback invoked when the stream is closed. |
Implements http::ResponseWriter.
◆ write_chunk()
| void http::h2::Http2ResponseWriter::write_chunk |
( |
std::string_view |
chunk | ) |
|
|
overridevirtual |
Streams a chunk of data (for Chunked Transfer Encoding).
- Parameters
-
| chunk | The data chunk to write. |
Implements http::ResponseWriter.
The documentation for this class was generated from the following files: