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

#include <serializer.hpp>

Public Types

using value_type = typename std::conditional< std::is_constructible< typename Body::reader, message< isRequest, Body, Fields > & >::value &&!std::is_constructible< typename Body::reader, message< isRequest, Body, Fields > const & >::value, message< isRequest, Body, Fields >, message< isRequest, Body, Fields > const >::type
 

Public Member Functions

 serializer (serializer &&)=default
 Constructor. More...
 
 serializer (serializer const &)=default
 Constructor. More...
 
serializeroperator= (serializer const &)=delete
 Assignment. More...
 
 serializer (value_type &msg)
 
value_typeget ()
 Returns the message being serialized. More...
 
std::size_t limit ()
 Returns the serialized buffer size limit. More...
 
void limit (std::size_t limit)
 
bool split ()
 
void split (bool v)
 
bool is_header_done ()
 
bool is_done ()
 
bool chunked ()
 
bool keep_alive ()
 
template<class Visit >
void next (error_code &ec, Visit &&visit)
 
void consume (std::size_t n)
 
reader & reader_impl ()
 

Detailed Description

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

Provides buffer oriented HTTP message serialization functionality.

An object of this type is used to serialize a complete HTTP message into a sequence of octets. To use this class, construct an instance with the message to be serialized.

The implementation will automatically perform chunk encoding if the contents of the message indicate that chunk encoding is required. If the semantics of the message indicate that the connection should be closed after the message is sent, the function keep_alive will return false.

Chunked output produced by the serializer never contains chunk extensions or trailers, and the location of chunk boundaries is not specified. If callers require chunk extensions, trailers, or control over the exact contents of each chunk they should use the serializer to write just the message header, and then assume control over serializing the chunked payload by using the chunk buffer sequence types chunk_body, chunk_crlf, chunk_header, and chunk_last.

Template Parameters
isRequesttrue if the message is a request.
BodyThe body type of the message.
FieldsThe type of fields in the message.

Member Typedef Documentation

template<bool isRequest, class Body , class Fields = fields>
using boost::beast::http::serializer< isRequest, Body, Fields >::value_type = typename std::conditional< std::is_constructible<typename Body::reader, message<isRequest, Body, Fields>&>::value && ! std::is_constructible<typename Body::reader, message<isRequest, Body, Fields> const&>::value, message<isRequest, Body, Fields>, message<isRequest, Body, Fields> const>::type

The type of message this serializer uses

This may be const or non-const depending on the implementation of the corresponding BodyReader.

Constructor & Destructor Documentation

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

Constructor.

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

Constructor.

template<bool isRequest, class Body , class Fields >
boost::beast::http::serializer< isRequest, Body, Fields >::serializer ( value_type msg)
explicit

Constructor

The implementation guarantees that the message passed on construction will not be accessed until the first call to next. This allows the message to be lazily created. For example, if the header is filled in before serialization.

Parameters
msgA reference to the message to serialize, which must remain valid for the lifetime of the serializer. Depending on the type of Body used, this may or may not be a const reference.
Note
This function participates in overload resolution only if Body::reader is constructible from a const message reference.

Member Function Documentation

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

Return true if the serializer will apply chunk-encoding.

This function may only be called if is_header_done would return true.

template<bool isRequest, class Body , class Fields >
void boost::beast::http::serializer< isRequest, Body, Fields >::consume ( std::size_t  n)

Consume buffer octets in the serialization.

This function should be called after one or more octets contained in the buffers provided in the prior call to next have been used.

After a call to consume, callers should check the return value of is_done to determine if the entire message has been serialized.

Parameters
nThe number of octets to consume. This number must be greater than zero and no greater than the number of octets in the buffers provided in the prior call to next.
template<bool isRequest, class Body , class Fields = fields>
value_type& boost::beast::http::serializer< isRequest, Body, Fields >::get ( )
inline

Returns the message being serialized.

template<bool isRequest, class Body , class Fields = fields>
bool boost::beast::http::serializer< isRequest, Body, Fields >::is_done ( )
inline

Return true if serialization is complete.

The operation is complete when all octets corresponding to the serialized representation of the message have been successfully retrieved.

template<bool isRequest, class Body , class Fields = fields>
bool boost::beast::http::serializer< isRequest, Body, Fields >::is_header_done ( )
inline

Return true if serialization of the header is complete.

This function indicates whether or not all buffers containing serialized header octets have been retrieved.

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

Return true if Connection: keep-alive semantic is indicated.

This function returns true if the semantics of the message indicate that the connection should be kept open after the serialized message has been transmitted. The value depends on the HTTP version of the message, the tokens in the Connection header, and the metadata describing the payload body.

Depending on the payload body, the end of the message may be indicated by connection closuire. In order for the recipient (if any) to receive a complete message, the underlying stream or network connection must be closed when this function returns false.

This function may only be called if is_header_done would return true.

template<bool isRequest, class Body , class Fields = fields>
std::size_t boost::beast::http::serializer< isRequest, Body, Fields >::limit ( )
inline

Returns the serialized buffer size limit.

template<bool isRequest, class Body , class Fields = fields>
void boost::beast::http::serializer< isRequest, Body, Fields >::limit ( std::size_t  limit)
inline

Set the serialized buffer size limit

This function adjusts the limit on the maximum size of the buffers passed to the visitor. The new size limit takes effect in the following call to next.

The default is no buffer size limit.

Parameters
limitThe new buffer size limit. If this number is zero, the size limit is removed.
template<bool isRequest, class Body , class Fields >
template<class Visit >
void boost::beast::http::serializer< isRequest, Body, Fields >::next ( error_code ec,
Visit &&  visit 
)

Returns the next set of buffers in the serialization.

This function will attempt to call the visit function object with a ConstBufferSequence of unspecified type representing the next set of buffers in the serialization of the message represented by this object.

If there are no more buffers in the serialization, the visit function will not be called. In this case, no error will be indicated, and the function is_done will return true.

Parameters
ecSet to the error, if any occurred.
visitThe function to call. The equivalent function signature of this object must be:
template<class ConstBufferSequence>
void visit(error_code&, ConstBufferSequence const&);
The function is not copied, if no error occurs it will be invoked before the call to next returns.
template<bool isRequest, class Body , class Fields = fields>
serializer& boost::beast::http::serializer< isRequest, Body, Fields >::operator= ( serializer< isRequest, Body, Fields > const &  )
delete

Assignment.

template<bool isRequest, class Body , class Fields = fields>
reader& boost::beast::http::serializer< isRequest, Body, Fields >::reader_impl ( )
inline

Provides low-level access to the associated BodyReader

This function provides access to the instance of the reader associated with the body and created by the serializer upon construction. The behavior of accessing this object is defined by the specification of the particular reader and its associated body.

Returns
A reference to the reader.
template<bool isRequest, class Body , class Fields = fields>
bool boost::beast::http::serializer< isRequest, Body, Fields >::split ( )
inline

Returns true if we will pause after writing the complete header.

template<bool isRequest, class Body , class Fields = fields>
void boost::beast::http::serializer< isRequest, Body, Fields >::split ( bool  v)
inline

Set whether the header and body are written separately.

When the split feature is enabled, the implementation will write only the octets corresponding to the serialized header first. If the header has already been written, this function will have no effect on output.


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