identt
Public Member Functions | Public Attributes | Friends | List of all members
identt::http::HttpServerBase< socket_type >::Response Class Reference

Response class where the content of the response is sent to client when the object is about to be destroyed. More...

#include <HttpServerBase.hpp>

Inheritance diagram for identt::http::HttpServerBase< socket_type >::Response:

Public Member Functions

std::size_t size () noexcept
 
void send (const std::function< void(const error_code &)> &callback=nullptr) noexcept
 Send the content of the response stream to client. More...
 
void write (const char_type *ptr, std::streamsize n)
 Write directly to stream buffer using std::ostream::write.
 
void write (StatusCode status_code=StatusCode::success_ok, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap())
 Convenience function for writing status line, potential header fields, and empty content.
 
void write (StatusCode status_code, string_view content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap())
 Convenience function for writing status line, header fields, and content.
 
void write (StatusCode status_code, std::istream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap())
 Convenience function for writing status line, header fields, and content.
 
void write (string_view content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap())
 Convenience function for writing success status line, header fields, and content.
 
void write (std::istream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap())
 Convenience function for writing success status line, header fields, and content.
 
void write (const CaseInsensitiveMultimap &header)
 Convenience function for writing success status line, and header fields.
 

Public Attributes

bool close_connection_after_response = false
 If set to true, force server to close the connection after the response have been sent. More...
 

Friends

class HttpServerBase< socket_type >
 
class HttpServer< socket_type >
 

Detailed Description

template<class socket_type>
class identt::http::HttpServerBase< socket_type >::Response

Response class where the content of the response is sent to client when the object is about to be destroyed.

Member Function Documentation

§ send()

template<class socket_type>
void identt::http::HttpServerBase< socket_type >::Response::send ( const std::function< void(const error_code &)> &  callback = nullptr)
inlinenoexcept

Send the content of the response stream to client.

The callback is called when the send has completed.

Use this function if you need to recursively send parts of a longer message, or when using server-sent events.

Member Data Documentation

§ close_connection_after_response

template<class socket_type>
bool identt::http::HttpServerBase< socket_type >::Response::close_connection_after_response = false

If set to true, force server to close the connection after the response have been sent.

This is useful when implementing a HTTP/1.0-server sending content without specifying the content length.


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