|
Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
|
ResponseWriter for HTTP/3 streams. More...
#include <QuicHttp3Session.hpp>


Public Member Functions | |
| Http3ResponseWriter (std::weak_ptr< QuicConnection > conn, int64_t stream_id, network::Proactor &proactor, concurrency::ThreadPool &thread_pool, bool suppress_body=false) | |
| 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. | |
Public Member Functions inherited from orbit::http::ResponseWriter | |
| virtual | ~ResponseWriter ()=default |
| bool | has_responded () const |
| True once anything of a response to the current request has been sent: a full response, its headers, a chunk or an event. | |
| void | set_error_sink (ErrorSink sink) |
| uint64_t | request_generation () const |
| bool | is_open () const |
| False once the client can no longer receive anything: the connection (HTTP/1.1) or stream (HTTP/2, HTTP/3) closed, because the client left, a timeout fired or the server shut down. | |
| void | on_close (std::function< void()> callback) |
Runs callback once when the writer closes (see is_open()), or right away if it already has. | |
Private Member Functions | |
| void | apply_response_hooks (http::HttpResponse &response) |
| template<typename Fn > | |
| void | with_session (Fn &&fn) |
Runs fn on the session with the connection locked, then flushes. | |
Private Attributes | |
| std::weak_ptr< QuicConnection > | conn_ |
| int64_t | stream_id_ |
| network::Proactor & | proactor_ |
| concurrency::ThreadPool & | thread_pool_ |
| std::unordered_map< std::string, std::string > | default_headers_ |
| std::vector< Interceptor > | interceptors_ |
| bool | headers_sent_ {false} |
| bool | suppress_body_ {false} |
| std::shared_ptr< void > | body_owner_ |
| std::string_view | body_ |
Friends | |
| class | QuicHttp3Session |
Additional Inherited Members | |
Public Types inherited from orbit::http::ResponseWriter | |
| using | Interceptor = std::function< void(HttpResponse &)> |
| using | ErrorSink = std::function< void(std::exception_ptr, std::shared_ptr< ResponseWriter >)> |
| Receives an exception that escaped asynchronous handler code, such as a coroutine handler that threw after a co_await. | |
Static Public Member Functions inherited from orbit::http::ResponseWriter | |
| static void | report_async_exception (const std::shared_ptr< ResponseWriter > &writer, uint64_t generation, std::exception_ptr error) noexcept |
| Reports an exception from asynchronous handler code. | |
Protected Member Functions inherited from orbit::http::ResponseWriter | |
| void | mark_responded () |
| Implementations call this whenever they write part of a response. | |
| void | reset_responded () |
| void | mark_closed () noexcept |
ResponseWriter for HTTP/3 streams.
Handlers run on the thread pool and may finish after the client has gone, so the writer refers to its connection only weakly.
| orbit::server::Http3ResponseWriter::Http3ResponseWriter | ( | std::weak_ptr< QuicConnection > | conn, |
| int64_t | stream_id, | ||
| network::Proactor & | proactor, | ||
| concurrency::ThreadPool & | thread_pool, | ||
| bool | suppress_body = false |
||
| ) |
|
overridevirtual |
Adds an interceptor to modify the response before it is sent.
| interceptor | The interceptor callback. |
Implements orbit::http::ResponseWriter.
|
private |
|
overridevirtual |
Ends a chunked response stream.
Implements orbit::http::ResponseWriter.
|
inlineoverridevirtual |
Gets the underlying Proactor to dispatch async operations.
Implements orbit::http::ResponseWriter.
|
overridevirtual |
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. |
Implements orbit::http::ResponseWriter.
|
overridevirtual |
Sends a complete HTTP response.
Takes ownership of any file descriptors managed by the response.
| response | The HttpResponse to send. |
Implements orbit::http::ResponseWriter.
|
overridevirtual |
Sends only the HTTP headers.
Useful for streaming bodies or Server-Sent Events.
| response | The HttpResponse containing the headers to send. |
Implements orbit::http::ResponseWriter.
|
overridevirtual |
Sends a Server-Sent Events (SSE) message.
| data | The event data payload. |
| event | The event type/name (optional). |
| id | The event ID (optional). |
Implements orbit::http::ResponseWriter.
|
overridevirtual |
Adds a default header that will be included in the final response.
| key | The header name. |
| value | The header value. |
Implements orbit::http::ResponseWriter.
|
inlineoverridevirtual |
Gets the thread pool to offload blocking tasks.
Implements orbit::http::ResponseWriter.
|
overridevirtual |
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. |
Implements orbit::http::ResponseWriter.
|
private |
Runs fn on the session with the connection locked, then flushes.
|
overridevirtual |
Streams a chunk of data (for Chunked Transfer Encoding).
| chunk | The data chunk to write. |
Implements orbit::http::ResponseWriter.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |