Sends HTTP data asynchronously.
More...
#include <staticlib/pion/http_response_writer.hpp>
Static Public Member Functions |
| static void | send (std::unique_ptr< http_response_writer > self) |
| | Sends all data buffered as a single HTTP message (without chunking).
|
| static void | send_final_chunk (std::unique_ptr< http_response_writer > self) |
| | Sends all data buffered (if any) and also sends the final HTTP chunk.
|
Detailed Description
Sends HTTP data asynchronously.
Constructor & Destructor Documentation
| staticlib::pion::http_response_writer::http_response_writer |
( |
tcp_connection_ptr & |
tcp_conn, |
|
|
const http_request & |
http_request |
|
) |
| |
|
inline |
Constructor to be used with std::make_unique
- Parameters
-
| tcp_conn | TCP connection used to send the response |
| http_request | the request we are responding to |
Deleted copy constructor.
Member Function Documentation
| void staticlib::pion::http_response_writer::clear |
( |
| ) |
|
|
inline |
Clears out all of the memory buffers used to cache payload content data.
| tcp_connection_ptr& staticlib::pion::http_response_writer::get_connection |
( |
| ) |
|
|
inline |
Returns a shared pointer to the TCP connection.
- Returns
- shared pointer to the TCP connection
| size_t staticlib::pion::http_response_writer::get_content_length |
( |
| ) |
const |
|
inline |
Returns the length of the payload content (in bytes)
- Returns
- length of the payload content (in bytes)
| http_response& staticlib::pion::http_response_writer::get_response |
( |
| ) |
|
|
inline |
Returns a non-const reference to the response that will be sent.
- Returns
- reference to the response that will be sent
Deleted copy assignment operator.
| static void staticlib::pion::http_response_writer::send |
( |
std::unique_ptr< http_response_writer > |
self | ) |
|
|
inlinestatic |
Sends all data buffered as a single HTTP message (without chunking).
Following a call to this function, it is not thread safe to use your reference to the writer object.
- Parameters
-
template<typename SendHandler >
| void staticlib::pion::http_response_writer::send_chunk |
( |
SendHandler |
send_handler | ) |
|
|
inline |
Sends all data buffered as a single HTTP chunk.
Following a call to this function, it is not thread safe to use your reference to the writer object until the send_handler has been called.
- Parameters
-
| send_handler | function that is called after the chunk has been sent to the client. Your callback function must end by calling one of send_chunk() or send_final_chunk(). Also, be sure to clear() the writer before writing data to it. |
| static void staticlib::pion::http_response_writer::send_final_chunk |
( |
std::unique_ptr< http_response_writer > |
self | ) |
|
|
inlinestatic |
Sends all data buffered (if any) and also sends the final HTTP chunk.
This function (either overloaded version) must be called following any calls to send_chunk(). Following a call to this function, it is not thread safe to use your reference to the writer object.
- Parameters
-
| bool staticlib::pion::http_response_writer::sending_chunked_message |
( |
| ) |
const |
|
inline |
Returns true if we are sending a chunked message to the client.
- Returns
- true if we are sending a chunked message to the client
| void staticlib::pion::http_response_writer::supports_chunked_messages |
( |
bool |
b | ) |
|
|
inline |
Sets whether or not the client supports chunked messages.
- Parameters
-
| b | whether or not the client supports chunked messages |
| bool staticlib::pion::http_response_writer::supports_chunked_messages |
( |
| ) |
const |
|
inline |
Returns true if the client supports chunked messages.
- Returns
- true if the client supports chunked messages
| void staticlib::pion::http_response_writer::write |
( |
sl::io::span< const char > |
data | ) |
|
|
inline |
Write payload content.
- Parameters
-
| data | to append to the payload content |
| void staticlib::pion::http_response_writer::write_nocopy |
( |
sl::io::span< const char > |
data | ) |
|
|
inline |
Write payload content; the data written is not copied, and therefore must persist until the message has finished sending.
- Parameters
-
| data | the data to append to the payload content |
The documentation for this class was generated from the following file: