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

User controlled response output builder. More...

#include <message_builders.hpp>

Inheritance diagram for restinio::response_builder_t< user_controlled_output_t >:
restinio::base_response_builder_t< 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_tset_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_tset_body (writable_item_t body) &
 Set body (part). More...
 
self_type_t && set_body (writable_item_t body) &&
 Set body (part). More...
 
self_type_tappend_body (writable_item_t body_part) &
 Append body. More...
 
self_type_t && append_body (writable_item_t body_part) &&
 Append body. More...
 
self_type_tflush (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 &&)=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_toperator= (const base_response_builder_t &)=delete
 
base_response_builder_toperator= (base_response_builder_t &&)=default
 
virtual ~base_response_builder_t ()
 
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 > & append_header_date_field (std::time_t t)
 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_theader () noexcept
 Accessors for header. More...
 
const http_response_header_theader () const noexcept
 

Private Member Functions

void send_ready_data (impl::connection_handle_t conn, response_parts_attr_t response_parts_attr, write_status_cb_t wscb)
 
self_type_tset_body_impl (writable_item_t &body, std::size_t body_size)
 
self_type_tappend_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

template<>
class restinio::response_builder_t< user_controlled_output_t >

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 413 of file message_builders.hpp.

Member Typedef Documentation

◆ base_type_t

Definition at line 418 of file message_builders.hpp.

◆ self_type_t

Definition at line 420 of file message_builders.hpp.

Constructor & Destructor Documentation

◆ response_builder_t()

Member Function Documentation

◆ append_body() [1/2]

Append body.

Definition at line 459 of file message_builders.hpp.

◆ append_body() [2/2]

Append body.

Definition at line 471 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)
inlineprivate

Definition at line 589 of file message_builders.hpp.

◆ done()

Complete response.

Definition at line 503 of file message_builders.hpp.

◆ flush() [1/2]

Flush ready outgoing data.

Schedules for sending currently ready data.

Definition at line 481 of file message_builders.hpp.

◆ flush() [2/2]

Flush ready outgoing data.

Definition at line 496 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 ( )
inlineprivate

Definition at line 598 of file message_builders.hpp.

◆ send_ready_data()

void restinio::response_builder_t< user_controlled_output_t >::send_ready_data ( impl::connection_handle_t  conn,
response_parts_attr_t  response_parts_attr,
write_status_cb_t  wscb 
)
inlineprivate

Definition at line 522 of file message_builders.hpp.

◆ set_body() [1/2]

Set body (part).

Definition at line 444 of file message_builders.hpp.

◆ set_body() [2/2]

Set body (part).

Definition at line 452 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 
)
inlineprivate

Definition at line 568 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 429 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 437 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 609 of file message_builders.hpp.

◆ m_response_parts

Body accumulator.

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

Definition at line 625 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 618 of file message_builders.hpp.


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