RESTinio

Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
restinio::response_builder_t< user_controlled_output_t > Class Referencefinal

User controlled response output builder. More...

`#include <message_builders.hpp>`

Inheritance diagram for restinio::response_builder_t< user_controlled_output_t >:

## Public Types
using | base_type_t = base_response_builder_t< response_builder_t< user_controlled_output_t > >
using | self_type_t = response_builder_t< user_controlled_output_t >

## Public Member Functions
| response_builder_t (response_builder_t &&)=default
self_type_t & | set_content_length (std::size_t content_length) &
| Manualy set content length. More...
self_type_t && | set_content_length (std::size_t content_length) &&
| Manualy set content length. More...
self_type_t & | set_body (writable_item_t body) &
| Set body (part). More...
self_type_t && | set_body (writable_item_t body) &&
| Set body (part). More...
self_type_t & | append_body (writable_item_t body_part) &
| Append body. More...
self_type_t && | append_body (writable_item_t body_part) &&
| Append body. More...
self_type_t & | flush (write_status_cb_t wscb=write_status_cb_t{}) &
| Flush ready outgoing data. More...
self_type_t && | flush (write_status_cb_t wscb=write_status_cb_t{}) &&
| Flush ready outgoing data. More...
request_handling_status_t | done (write_status_cb_t wscb=write_status_cb_t{})
| Complete response. More...
Public Member Functions inherited from restinio::base_response_builder_t< response_builder_t< user_controlled_output_t > >
| base_response_builder_t (const base_response_builder_t &)=delete
| base_response_builder_t (base_response_builder_t &&) noexcept=default
| base_response_builder_t (http_status_line_t status_line, impl::connection_handle_t connection, request_id_t request_id, bool should_keep_alive)
base_response_builder_t & | operator= (const base_response_builder_t &)=delete
base_response_builder_t & | operator= (base_response_builder_t &&) noexcept=default
virtual | ~base_response_builder_t ()=default
response_builder_t< user_controlled_output_t > & | append_header (std::string field_name, std::string field_value) &
| Add header field. More...
response_builder_t< user_controlled_output_t > && | append_header (std::string field_name, std::string field_value) &&
| Add header field. More...
response_builder_t< user_controlled_output_t > & | append_header (http_header_field_t http_header_field) &
| Add header field. More...
response_builder_t< user_controlled_output_t > && | append_header (http_header_field_t http_header_field) &&
| Add header field. More...
response_builder_t< user_controlled_output_t > & | append_header (http_field_t field_id, std::string field_value) &
| Add header field. More...
response_builder_t< user_controlled_output_t > && | append_header (http_field_t field_id, std::string field_value) &&
| Add header field. More...
response_builder_t< user_controlled_output_t > & | append_header_date_field (std::chrono::system_clock::time_point tp=std::chrono::system_clock::now()) &
| Add header `Date` field. More...
response_builder_t< user_controlled_output_t > && | append_header_date_field (std::chrono::system_clock::time_point tp=std::chrono::system_clock::now()) &&
| Add header `Date` field. More...
response_builder_t< user_controlled_output_t > & | connection_close () &noexcept
| Set connection close. More...
response_builder_t< user_controlled_output_t > && | connection_close () &&noexcept
| Set connection close. More...
response_builder_t< user_controlled_output_t > & | connection_keep_alive () &noexcept
| Set connection keep-alive. More...
response_builder_t< user_controlled_output_t > && | connection_keep_alive () &&noexcept
http_response_header_t & | header () noexcept
| Accessors for header. More...
const http_response_header_t & | header () const noexcept

## Private Member Functions
void | send_ready_data (const impl::connection_handle_t &conn, response_parts_attr_t response_parts_attr, write_status_cb_t wscb)
self_type_t & | set_body_impl (writable_item_t &body, std::size_t body_size)
self_type_t & | append_body_impl (writable_item_t &body_part)
void | if_neccessary_reserve_first_element_for_header ()

## Private Attributes
bool | m_header_was_sent { false }
| Flag used by flush() function. More...
bool | m_should_keep_alive_when_header_was_sent { true }
| Saved keep_alive attr actual at the point a header data was sent. More...
writable_items_container_t | m_response_parts
| Body accumulator. More...

## Additional Inherited Members
Protected Member Functions inherited from restinio::base_response_builder_t< response_builder_t< user_controlled_output_t > >
std::size_t | calculate_status_line_size () const noexcept
void | throw_done_must_be_called_once () const
Protected Attributes inherited from restinio::base_response_builder_t< response_builder_t< user_controlled_output_t > >
http_response_header_t | m_header
impl::connection_handle_t | m_connection
const request_id_t | m_request_id

## Detailed Description

User controlled response output builder.

This type of output allows user to send body divided into parts. But it is up to user to set the correct Content-Length field.

Definition at line 402 of file message_builders.hpp.

## Member Typedef Documentation

## ◆ base_type_t

using restinio::response_builder_t< user_controlled_output_t >::base_type_t = base_response_builder_t< response_builder_t< user_controlled_output_t > >

Definition at line 406 of file message_builders.hpp.

## ◆ self_type_t

using restinio::response_builder_t< user_controlled_output_t >::self_type_t = response_builder_t< user_controlled_output_t >

Definition at line 408 of file message_builders.hpp.

## Constructor & Destructor Documentation

## ◆ response_builder_t()

restinio::response_builder_t< user_controlled_output_t >::response_builder_t | ( | response_builder_t< user_controlled_output_t > && |  | ) |
| default

## Member Function Documentation

## ◆ append_body() [1/2]

self_type_t & restinio::response_builder_t< user_controlled_output_t >::append_body | ( | writable_item_t | body_part | ) | &
| inline

Append body.

Definition at line 448 of file message_builders.hpp.

## ◆ append_body() [2/2]

self_type_t && restinio::response_builder_t< user_controlled_output_t >::append_body | ( | writable_item_t | body_part | ) | &&
| inline

Append body.

Definition at line 460 of file message_builders.hpp.

## ◆ append_body_impl()

self_type_t & restinio::response_builder_t< user_controlled_output_t >::append_body_impl | ( | writable_item_t & | body_part | ) |
| inline private

Definition at line 582 of file message_builders.hpp.

## ◆ done()

request_handling_status_t restinio::response_builder_t< user_controlled_output_t >::done | ( | write_status_cb_t | wscb = `write_status_cb_t{}` | ) |
| inline

Complete response.

Definition at line 492 of file message_builders.hpp.

## ◆ flush() [1/2]

self_type_t & restinio::response_builder_t< user_controlled_output_t >::flush | ( | write_status_cb_t | wscb = `write_status_cb_t{}` | ) | &
| inline

Flush ready outgoing data.

Schedules for sending currently ready data.

Definition at line 470 of file message_builders.hpp.

## ◆ flush() [2/2]

self_type_t && restinio::response_builder_t< user_controlled_output_t >::flush | ( | write_status_cb_t | wscb = `write_status_cb_t{}` | ) | &&
| inline

Flush ready outgoing data.

Definition at line 485 of file message_builders.hpp.

## ◆ if_neccessary_reserve_first_element_for_header()

void restinio::response_builder_t< user_controlled_output_t >::if_neccessary_reserve_first_element_for_header | ( |  | ) |
| inline private

Definition at line 591 of file message_builders.hpp.

## ◆ send_ready_data()

void restinio::response_builder_t< user_controlled_output_t >::send_ready_data | ( | const impl::connection_handle_t & | conn,
|  | response_parts_attr_t | response_parts_attr,
|  | write_status_cb_t | wscb
| ) |  |
| inline private

Definition at line 515 of file message_builders.hpp.

## ◆ set_body() [1/2]

self_type_t & restinio::response_builder_t< user_controlled_output_t >::set_body | ( | writable_item_t | body | ) | &
| inline

Set body (part).

Definition at line 433 of file message_builders.hpp.

## ◆ set_body() [2/2]

self_type_t && restinio::response_builder_t< user_controlled_output_t >::set_body | ( | writable_item_t | body | ) | &&
| inline

Set body (part).

Definition at line 441 of file message_builders.hpp.

## ◆ set_body_impl()

self_type_t & restinio::response_builder_t< user_controlled_output_t >::set_body_impl | ( | writable_item_t & | body,
|  | std::size_t | body_size
| ) |  |
| inline private

Definition at line 561 of file message_builders.hpp.

## ◆ set_content_length() [1/2]

self_type_t & restinio::response_builder_t< user_controlled_output_t >::set_content_length | ( | std::size_t | content_length | ) | &
| inline

Manualy set content length.

Definition at line 418 of file message_builders.hpp.

## ◆ set_content_length() [2/2]

self_type_t && restinio::response_builder_t< user_controlled_output_t >::set_content_length | ( | std::size_t | content_length | ) | &&
| inline

Manualy set content length.

Definition at line 426 of file message_builders.hpp.

## Member Data Documentation

## ◆ m_header_was_sent

bool restinio::response_builder_t< user_controlled_output_t >::m_header_was_sent { false }
| private

Flag used by flush() function.

Definition at line 602 of file message_builders.hpp.

## ◆ m_response_parts

writable_items_container_t restinio::response_builder_t< user_controlled_output_t >::m_response_parts
| private

Body accumulator.

For this type of output it contains a part of a body. On each flush it is cleared.

Definition at line 618 of file message_builders.hpp.

## ◆ m_should_keep_alive_when_header_was_sent

bool restinio::response_builder_t< user_controlled_output_t >::m_should_keep_alive_when_header_was_sent { true }
| private

Saved keep_alive attr actual at the point a header data was sent.

It is neccessary to guarantee that all parts of response will have the same response-connection-attr (keep-alive or close);

Definition at line 611 of file message_builders.hpp.

The documentation for this class was generated from the following file:

- restinio/message_builders.hpp