C++ Actor Framework 1.0.0
|
Responds to an HTTP request at the server. More...
#include <responder.hpp>
Classes | |
class | promise |
Allows users to respond to an incoming HTTP request at some later time. More... | |
class | promise_state |
Implementation detail for promise . More... | |
Public Member Functions | |
responder (const request_header *hdr, const_byte_span body, http::router *router) | |
responder (const responder &) noexcept=default | |
responder & | operator= (const responder &) noexcept=default |
const request_header & | header () const noexcept |
Returns the HTTP header for the responder. | |
const_byte_span | body () const noexcept |
Returns the HTTP body (payload) for the responder. | |
const_byte_span | payload () const noexcept |
Returns the HTTP body (payload) for the responder. | |
http::router * | router () const noexcept |
Returns the router that has created this responder. | |
actor_shell * | self () |
Returns the actor_shell object from the router for interacting with actors in the system. | |
lower_layer::server * | down () |
Returns a pointer to the HTTP layer. | |
void | respond (status code) |
Sends an HTTP response that only consists of a header with a status code such as status::no_content . | |
void | respond (status code, std::string_view content_type, const_byte_span content) |
Sends an HTTP response message to the client. | |
void | respond (status code, std::string_view content_type, std::string_view content) |
Sends an HTTP response message to the client. | |
void | respond (status code, const error &what) |
Sends an HTTP response message with an error to the client. | |
void | begin_header (status code) |
Starts writing an HTTP header. | |
void | add_header_field (std::string_view key, std::string_view val) |
Adds a header field. | |
bool | end_header () |
Seals the header and transports it to the client. | |
bool | send_payload (const_byte_span bytes) |
Sends the payload after the header. | |
bool | send_chunk (const_byte_span bytes) |
Sends a chunk of data if the full payload is unknown when starting to send. | |
bool | send_end_of_chunks () |
Sends the last chunk, completing a chunked payload. | |
request | to_request () && |
Converts a responder to a request for processing the HTTP request asynchronously. | |
promise | to_promise () && |
Converts the responder to a promise object for responding to the HTTP request at some later time but from the same socket_manager. | |
Responds to an HTTP request at the server.
Provides functions for accessing the HTTP client request and for writing the HTTP response.
This class has a similar API to request, but is used at the server directly. While a request is meant to handled outside of the server by eventually fulfilling the response promise, a responder
must generate the response immediately.
void caf::net::http::responder::add_header_field | ( | std::string_view | key, |
std::string_view | val ) |
Adds a header field.
Users may only call this function between begin_header
and end_header
.
|
noexcept |
Returns the HTTP body (payload) for the responder.
valid()
|
noexcept |
Returns the HTTP header for the responder.
valid()
|
noexcept |
Returns the HTTP body (payload) for the responder.
valid()
Sends an HTTP response message with an error to the client.
Converts what
to a string representation and then transfers this description to the client.
void caf::net::http::responder::respond | ( | status | code, |
std::string_view | content_type, | ||
const_byte_span | content ) |
Sends an HTTP response message to the client.
Automatically sets the Content-Type
and Content-Length
header fields.
valid()
void caf::net::http::responder::respond | ( | status | code, |
std::string_view | content_type, | ||
std::string_view | content ) |
Sends an HTTP response message to the client.
Automatically sets the Content-Type
and Content-Length
header fields.
valid()