ゴミ箱
Public Types | Public Member Functions | Public Attributes | List of all members
boost::beast::http::message< isRequest, Body, Fields > Struct Template Reference

#include <type_traits.hpp>

Inheritance diagram for boost::beast::http::message< isRequest, Body, Fields >:
boost::beast::http::header< isRequest, Fields >

Public Types

using header_type = header< isRequest, Fields >
 The base class used to hold the header portion of the message. More...
 
using body_type = Body
 

Public Member Functions

 message ()=default
 Constructor. More...
 
 message (message &&)=default
 Constructor. More...
 
 message (message const &)=default
 Constructor. More...
 
messageoperator= (message &&)=default
 Assignment. More...
 
messageoperator= (message const &)=default
 Assignment. More...
 
template<class... BodyArgs>
 message (header_type &&h, BodyArgs &&...body_args)
 
template<class... BodyArgs>
 message (header_type const &h, BodyArgs &&...body_args)
 
template<class Version , class = typename std::enable_if<isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (verb method, string_view target, Version version)
 
template<class Version , class BodyArg , class = typename std::enable_if<isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (verb method, string_view target, Version version, BodyArg &&body_arg)
 
template<class Version , class BodyArg , class FieldsArg , class = typename std::enable_if<isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (verb method, string_view target, Version version, BodyArg &&body_arg, FieldsArg &&fields_arg)
 
template<class Version , class = typename std::enable_if<! isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (status result, Version version)
 
template<class Version , class BodyArg , class = typename std::enable_if<! isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (status result, Version version, BodyArg &&body_arg)
 
template<class Version , class BodyArg , class FieldsArg , class = typename std::enable_if<! isRequest && std::is_convertible<Version, unsigned>::value>::type>
 message (status result, Version version, BodyArg &&body_arg, FieldsArg &&fields_arg)
 
 message (std::piecewise_construct_t)
 
template<class... BodyArgs>
 message (std::piecewise_construct_t, std::tuple< BodyArgs... > body_args)
 
template<class... BodyArgs, class... FieldsArgs>
 message (std::piecewise_construct_t, std::tuple< BodyArgs... > body_args, std::tuple< FieldsArgs... > fields_args)
 
header_type const & base () const
 Returns the header portion of the message. More...
 
header_typebase ()
 Returns the header portion of the message. More...
 
bool chunked () const
 Returns true if the chunked Transfer-Encoding is specified. More...
 
void chunked (bool value)
 
void content_length (boost::optional< std::uint64_t > const &value)
 
bool keep_alive () const
 
void keep_alive (bool value)
 
boost::optional< std::uint64_t > payload_size () const
 
void prepare_payload ()
 

Public Attributes

Body::value_type body
 A value representing the body. More...
 

Detailed Description

template<bool isRequest, class Body, class Fields = fields>
struct boost::beast::http::message< isRequest, Body, Fields >

A container for a complete HTTP message.

This container is derived from the Fields template type. To understand all of the members of this class it is necessary to view the declaration for the Fields type. When using the default fields container, those declarations are in fields.

A message can be a request or response, depending on the isRequest template argument value. Requests and responses have different types; functions may be overloaded based on the type if desired.

The Body template argument type determines the model used to read or write the content body of the message.

Newly constructed messages objects have version set to HTTP/1.1. Newly constructed response objects also have result code set to status::ok.

Template Parameters
isRequesttrue if this represents a request, or false if this represents a response. Some class data members are conditionally present depending on this value.
BodyA type meeting the requirements of Body.
FieldsThe type of container used to hold the field value pairs.

Member Typedef Documentation

template<bool isRequest, class Body, class Fields = fields>
using boost::beast::http::message< isRequest, Body, Fields >::body_type = Body

The type providing the body traits.

The message::body member will be of type body_type::value_type.

template<bool isRequest, class Body, class Fields = fields>
using boost::beast::http::message< isRequest, Body, Fields >::header_type = header<isRequest, Fields>

The base class used to hold the header portion of the message.

Constructor & Destructor Documentation

template<bool isRequest, class Body, class Fields = fields>
boost::beast::http::message< isRequest, Body, Fields >::message ( )
default

Constructor.

template<bool isRequest, class Body, class Fields = fields>
boost::beast::http::message< isRequest, Body, Fields >::message ( message< isRequest, Body, Fields > &&  )
default

Constructor.

template<bool isRequest, class Body, class Fields = fields>
boost::beast::http::message< isRequest, Body, Fields >::message ( message< isRequest, Body, Fields > const &  )
default

Constructor.

template<bool isRequest, class Body , class Fields >
template<class... BodyArgs>
boost::beast::http::message< isRequest, Body, Fields >::message ( header_type &&  h,
BodyArgs &&...  body_args 
)
explicit

Constructor

Parameters
hThe header to move construct from.
body_argsOptional arguments forwarded to the body constructor.
template<bool isRequest, class Body , class Fields >
template<class... BodyArgs>
boost::beast::http::message< isRequest, Body, Fields >::message ( header_type const &  h,
BodyArgs &&...  body_args 
)
explicit

Constructor.

Parameters
hThe header to copy construct from.
body_argsOptional arguments forwarded to the body constructor.
template<bool isRequest, class Body , class Fields >
template<class Version, class >
boost::beast::http::message< isRequest, Body, Fields >::message ( verb  method,
string_view  target,
Version  version 
)

Constructor

Parameters
methodThe request-method to use
targetThe request-target.
versionThe HTTP-version
Note
This function is only available when isRequest == true.
template<bool isRequest, class Body , class Fields >
template<class Version, class BodyArg , class >
boost::beast::http::message< isRequest, Body, Fields >::message ( verb  method,
string_view  target,
Version  version,
BodyArg &&  body_arg 
)

Constructor

Parameters
methodThe request-method to use
targetThe request-target.
versionThe HTTP-version
body_argAn argument forwarded to the body constructor.
Note
This function is only available when isRequest == true.
template<bool isRequest, class Body , class Fields >
template<class Version, class BodyArg , class FieldsArg , class >
boost::beast::http::message< isRequest, Body, Fields >::message ( verb  method,
string_view  target,
Version  version,
BodyArg &&  body_arg,
FieldsArg &&  fields_arg 
)

Constructor

Parameters
methodThe request-method to use
targetThe request-target.
versionThe HTTP-version
body_argAn argument forwarded to the body constructor.
fields_argAn argument forwarded to the Fields constructor.
Note
This function is only available when isRequest == true.
template<bool isRequest, class Body , class Fields >
template<class Version, class >
boost::beast::http::message< isRequest, Body, Fields >::message ( status  result,
Version  version 
)

Constructor

Parameters
resultThe status-code for the response
versionThe HTTP-version
Note
This member is only available when isRequest == false.
template<bool isRequest, class Body , class Fields >
template<class Version, class BodyArg , class >
boost::beast::http::message< isRequest, Body, Fields >::message ( status  result,
Version  version,
BodyArg &&  body_arg 
)

Constructor

Parameters
resultThe status-code for the response
versionThe HTTP-version
body_argAn argument forwarded to the body constructor.
Note
This member is only available when isRequest == false.
template<bool isRequest, class Body , class Fields >
template<class Version, class BodyArg , class FieldsArg , class >
boost::beast::http::message< isRequest, Body, Fields >::message ( status  result,
Version  version,
BodyArg &&  body_arg,
FieldsArg &&  fields_arg 
)

Constructor

Parameters
resultThe status-code for the response
versionThe HTTP-version
body_argAn argument forwarded to the body constructor.
fields_argAn argument forwarded to the Fields base class constructor.
Note
This member is only available when isRequest == false.
template<bool isRequest, class Body , class Fields >
boost::beast::http::message< isRequest, Body, Fields >::message ( std::piecewise_construct_t  )
explicit

Constructor

The header and body are default-constructed.

template<bool isRequest, class Body , class Fields >
template<class... BodyArgs>
boost::beast::http::message< isRequest, Body, Fields >::message ( std::piecewise_construct_t  ,
std::tuple< BodyArgs... >  body_args 
)

Construct a message.

Parameters
body_argsA tuple forwarded as a parameter pack to the body constructor.
template<bool isRequest, class Body , class Fields >
template<class... BodyArgs, class... FieldsArgs>
boost::beast::http::message< isRequest, Body, Fields >::message ( std::piecewise_construct_t  ,
std::tuple< BodyArgs... >  body_args,
std::tuple< FieldsArgs... >  fields_args 
)

Construct a message.

Parameters
body_argsA tuple forwarded as a parameter pack to the body constructor.
fields_argsA tuple forwarded as a parameter pack to the Fields constructor.

Member Function Documentation

template<bool isRequest, class Body, class Fields = fields>
header_type const& boost::beast::http::message< isRequest, Body, Fields >::base ( ) const
inline

Returns the header portion of the message.

template<bool isRequest, class Body, class Fields = fields>
header_type& boost::beast::http::message< isRequest, Body, Fields >::base ( )
inline

Returns the header portion of the message.

template<bool isRequest, class Body, class Fields = fields>
bool boost::beast::http::message< isRequest, Body, Fields >::chunked ( ) const
inline

Returns true if the chunked Transfer-Encoding is specified.

template<bool isRequest, class Body , class Fields >
void boost::beast::http::message< isRequest, Body, Fields >::chunked ( bool  value)

Set or clear the chunked Transfer-Encoding

This function will set or removed the "chunked" transfer encoding as the last item in the list of encodings in the field.

If the result of removing the chunked token results in an empty string, the field is erased.

The Content-Length field is erased unconditionally.

template<bool isRequest, class Body , class Fields >
void boost::beast::http::message< isRequest, Body, Fields >::content_length ( boost::optional< std::uint64_t > const &  value)

Set or clear the Content-Length field

This function adjusts the Content-Length field as follows:

  • If value specifies a value, the Content-Length field is set to the value. Otherwise
  • The Content-Length field is erased.

If "chunked" token appears as the last item in the Transfer-Encoding field it is unconditionally removed.

Parameters
valueThe value to set for Content-Length.
template<bool isRequest, class Body, class Fields = fields>
bool boost::beast::http::message< isRequest, Body, Fields >::keep_alive ( ) const
inline

Returns true if the message semantics indicate keep-alive

The value depends on the version in the message, which must be set to the final value before this function is called or else the return value is unreliable.

template<bool isRequest, class Body, class Fields = fields>
void boost::beast::http::message< isRequest, Body, Fields >::keep_alive ( bool  value)
inline

Set the keep-alive message semantic option

This function adjusts the Connection field to indicate whether or not the connection should be kept open after the corresponding response. The result depends on the version set on the message, which must be set to the final value before making this call.

Parameters
valuetrue if the connection should persist.
template<bool isRequest, class Body, class Fields = fields>
message& boost::beast::http::message< isRequest, Body, Fields >::operator= ( message< isRequest, Body, Fields > &&  )
default

Assignment.

template<bool isRequest, class Body, class Fields = fields>
message& boost::beast::http::message< isRequest, Body, Fields >::operator= ( message< isRequest, Body, Fields > const &  )
default

Assignment.

template<bool isRequest, class Body , class Fields >
boost::optional< std::uint64_t > boost::beast::http::message< isRequest, Body, Fields >::payload_size ( ) const

Returns the payload size of the body in octets if possible.

This function invokes the Body algorithm to measure the number of octets in the serialized body container. If there is no body, this will return zero. Otherwise, if the body exists but is not known ahead of time, boost::none is returned (usually indicating that a chunked Transfer-Encoding will be used).

Note
The value of the Content-Length field in the message is not inspected.
template<bool isRequest, class Body, class Fields = fields>
void boost::beast::http::message< isRequest, Body, Fields >::prepare_payload ( )
inline

Prepare the message payload fields for the body.

This function will adjust the Content-Length and Transfer-Encoding field values based on the properties of the body.

Example
request<string_body> req{verb::post, "/"};
req.set(field::user_agent, "Beast");
req.body = "Hello, world!";
req.prepare_payload();

Member Data Documentation

template<bool isRequest, class Body, class Fields = fields>
Body::value_type boost::beast::http::message< isRequest, Body, Fields >::body

A value representing the body.


The documentation for this struct was generated from the following files: