ゴミ箱
|
#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... | |
serializer & | operator= (serializer const &)=delete |
Assignment. More... | |
serializer (value_type &msg) | |
value_type & | get () |
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 () |
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.
isRequest | true if the message is a request. |
Body | The body type of the message. |
Fields | The type of fields in the message. |
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.
|
default |
Constructor.
|
default |
Constructor.
|
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.
msg | A 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. |
const
message reference.
|
inline |
Return true
if the serializer will apply chunk-encoding.
This function may only be called if is_header_done would return true
.
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.
n | The 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. |
|
inline |
Returns the message being serialized.
|
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.
|
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.
|
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
.
|
inline |
Returns the serialized buffer size 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.
limit | The new buffer size limit. If this number is zero, the size limit is removed. |
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
.
ec | Set to the error, if any occurred. |
visit | The function to call. The equivalent function signature of this object must be: template<class ConstBufferSequence> |
|
delete |
Assignment.
|
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.
|
inline |
Returns true
if we will pause after writing the complete header.
|
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.