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

#include <type_traits.hpp>

Inheritance diagram for boost::beast::http::parser< isRequest, Body, Allocator >:
boost::beast::http::basic_parser< isRequest, parser< isRequest, Body, Allocator > > boost::beast::http::detail::basic_parser_base

Public Types

using value_type = message< isRequest, Body, basic_fields< Allocator >>
 The type of message returned by the parser. More...
 
- Public Types inherited from boost::beast::http::basic_parser< isRequest, parser< isRequest, Body, Allocator > >
using is_request = std::integral_constant< bool, isRequest >
 true if this parser parses requests, false for responses. More...
 

Public Member Functions

 ~parser ()=default
 Destructor. More...
 
 parser ()
 Constructor. More...
 
 parser (parser const &)=delete
 Constructor. More...
 
parseroperator= (parser const &)=delete
 Assignment. More...
 
 parser (parser &&other)=default
 
template<class Arg1 , class... ArgN, class = typename std::enable_if< ! detail::is_parser<typename std::decay<Arg1>::type>::value>::type>
 parser (Arg1 &&arg1, ArgN &&...argn)
 
template<class OtherBody , class... Args, class = typename std::enable_if< ! std::is_same<Body, OtherBody>::value>::type>
 parser (parser< isRequest, OtherBody, Allocator > &&parser, Args &&...args)
 
value_type const & get () const
 
value_typeget ()
 
value_type release ()
 
template<class Callback >
void on_chunk_header (Callback &cb)
 
template<class Callback >
void on_chunk_body (Callback &cb)
 
- Public Member Functions inherited from boost::beast::http::basic_parser< isRequest, parser< isRequest, Body, Allocator > >
 basic_parser (basic_parser const &)=delete
 Constructor. More...
 
 basic_parser ()
 Constructor. More...
 
 basic_parser (basic_parser< isRequest, OtherDerived > &&)
 
 ~basic_parser ()
 Destructor. More...
 
basic_parseroperator= (basic_parser const &)=delete
 Constructor. More...
 
basic_parserbase ()
 
basic_parser const & base () const
 
bool got_some () const
 Returns true if the parser has received at least one byte of input. More...
 
bool is_done () const
 
bool is_header_done () const
 
bool is_upgrade () const
 
bool is_chunked () const
 
bool is_keep_alive () const
 
boost::optional< std::uint64_t > content_length () const
 
bool need_eof () const
 
void body_limit (std::uint64_t v)
 
void header_limit (std::uint32_t v)
 
bool eager () const
 Returns true if the eager parse option is set. More...
 
void eager (bool v)
 
bool skip ()
 Returns true if the skip parse option is set. More...
 
void skip (bool v)
 
std::size_t put (ConstBufferSequence const &buffers, error_code &ec)
 
std::size_t put (boost::asio::const_buffers_1 const &buffer, error_code &ec)
 
void put_eof (error_code &ec)
 

Friends

template<bool , class , class >
class parser
 
class basic_parser< isRequest, parser >
 

Detailed Description

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
class boost::beast::http::parser< isRequest, Body, Allocator >

An HTTP/1 parser for producing a message.

This class uses the basic HTTP/1 wire format parser to convert a series of octets into a message using the basic_fields container to represent the fields.

Template Parameters
isRequestIndicates whether a request or response will be parsed.
BodyThe type used to represent the body. This must meet the requirements of Body.
AllocatorThe type of allocator used with the basic_fields container.
Note
A new instance of the parser is required for each message.

Member Typedef Documentation

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
using boost::beast::http::parser< isRequest, Body, Allocator >::value_type = message<isRequest, Body, basic_fields<Allocator>>

The type of message returned by the parser.

Constructor & Destructor Documentation

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
boost::beast::http::parser< isRequest, Body, Allocator >::~parser ( )
default

Destructor.

template<bool isRequest, class Body , class Allocator >
boost::beast::http::parser< isRequest, Body, Allocator >::parser ( )

Constructor.

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
boost::beast::http::parser< isRequest, Body, Allocator >::parser ( parser< isRequest, Body, Allocator > const &  )
delete

Constructor.

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
boost::beast::http::parser< isRequest, Body, Allocator >::parser ( parser< isRequest, Body, Allocator > &&  other)
default

Constructor

After the move, the only valid operation on the moved-from object is destruction.

template<bool isRequest, class Body , class Allocator >
template<class Arg1 , class... ArgN, class >
boost::beast::http::parser< isRequest, Body, Allocator >::parser ( Arg1 &&  arg1,
ArgN &&...  argn 
)
explicit

Constructor

Parameters
argsOptional arguments forwarded to the http::header constructor.
Note
This function participates in overload resolution only if the first argument is not a parser.
template<bool isRequest, class Body , class Allocator>
template<class OtherBody , class... Args, class >
boost::beast::http::parser< isRequest, Body, Allocator >::parser ( parser< isRequest, OtherBody, Allocator > &&  parser,
Args &&...  args 
)
explicit

Construct a parser from another parser, changing the Body type.

This constructs a new parser by move constructing the header from another parser with a different body type. The constructed-from parser must not have any parsed body octets or initialized BodyWriter, otherwise an exception is generated.

Example
// Deferred body type commitment
request_parser<empty_body> req0;
...
request_parser<string_body> req{std::move(req0)};

If an exception is thrown, the state of the constructed-from parser is undefined.

Parameters
parserThe other parser to construct from. After this call returns, the constructed-from parser may only be destroyed.
argsOptional arguments forwarded to the message constructor.
Exceptions
std::invalid_argumentThrown when the constructed-from parser has already initialized a body writer.
Note
This function participates in overload resolution only if the other parser uses a different body type.

Member Function Documentation

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
value_type const& boost::beast::http::parser< isRequest, Body, Allocator >::get ( ) const
inline

Returns the parsed message.

Depending on the parser's progress, parts of this object may be incomplete.

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
value_type& boost::beast::http::parser< isRequest, Body, Allocator >::get ( )
inline

Returns the parsed message.

Depending on the parser's progress, parts of this object may be incomplete.

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
template<class Callback >
void boost::beast::http::parser< isRequest, Body, Allocator >::on_chunk_body ( Callback &  cb)
inline

Set a callback to be invoked on chunk body data

The provided function object will be invoked one or more times to provide buffers corresponding to the chunk body for the current chunk. The callback receives the number of octets remaining in this chunk body including the octets in the buffer provided.

The callback must return the number of octets actually consumed. Any octets not consumed will be presented again in a subsequent invocation of the callback. The implementation type-erases the callback without requiring a dynamic allocation. For this reason, the callback object is passed by a non-constant reference.

Example
auto callback =
[](std::uint64_t remain, string_view body, error_code& ec)
{
//...
};
parser.on_chunk_body(callback);
Parameters
cbThe function to set, which must be invocable with this equivalent signature:
std::size_t
std::uint64_t remain, // Octets remaining in this chunk, includes `body`
string_view body, // A buffer holding some or all of the remainder of the chunk body
error_code& ec); // May be set by the callback to indicate an error
template<bool isRequest, class Body, class Allocator = std::allocator<char>>
template<class Callback >
void boost::beast::http::parser< isRequest, Body, Allocator >::on_chunk_header ( Callback &  cb)
inline

Set a callback to be invoked on each chunk header.

The callback will be invoked once for every chunk in the message payload, as well as once for the last chunk. The invocation happens after the chunk header is available but before any body octets have been parsed.

The extensions are provided in raw, validated form, use chunk_extensions::parse to parse the extensions into a structured container for easier access. The implementation type-erases the callback without requiring a dynamic allocation. For this reason, the callback object is passed by a non-constant reference.

Example
auto callback =
[](std::uint64_t size, string_view extensions, error_code& ec)
{
//...
};
parser.on_chunk_header(callback);
Parameters
cbThe function to set, which must be invocable with this equivalent signature:
void
std::uint64_t size, // Size of the chunk, zero for the last chunk
string_view extensions, // The chunk-extensions in raw form
error_code& ec); // May be set by the callback to indicate an error
template<bool isRequest, class Body, class Allocator = std::allocator<char>>
parser& boost::beast::http::parser< isRequest, Body, Allocator >::operator= ( parser< isRequest, Body, Allocator > const &  )
delete

Assignment.

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
value_type boost::beast::http::parser< isRequest, Body, Allocator >::release ( )
inline

Returns ownership of the parsed message.

Ownership is transferred to the caller. Depending on the parser's progress, parts of this object may be incomplete.

Requires

value_type is MoveConstructible

Friends And Related Function Documentation

template<bool isRequest, class Body, class Allocator = std::allocator<char>>
friend class basic_parser< isRequest, parser >
friend
template<bool isRequest, class Body, class Allocator = std::allocator<char>>
template<bool , class , class >
friend class parser
friend

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