...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A parser for decoding HTTP/1 wire format messages.
Defined in header <boost/beast/http/basic_parser.hpp>
template< bool isRequest> class basic_parser
Name |
Description |
---|---|
|
Name |
Description |
---|---|
basic_parser [constructor] |
Copy constructor. |
Set the limit on the payload body. |
|
Returns |
|
Returns the optional value of Content-Length if known. |
|
Returns the remaining content length if known. |
|
Returns |
|
Returns |
|
Set a limit on the total size of the header. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Copy assignment. |
|
Write a buffer sequence to the parser. |
|
Inform the parser that the end of stream was reached. |
|
Returns |
|
Returns |
|
~basic_parser [destructor] |
Destructor. |
Name |
Description |
---|---|
basic_parser [constructor] |
Default constructor. |
Called each time additional data is received representing the content body. |
|
Called once before the body is processed. |
|
Called each time additional data is received representing part of a body chunk. |
|
Called each time a new chunk header of a chunk encoded body is received. |
|
Called once for each complete field in the HTTP header. |
|
Called once when the complete message is received. |
|
Called once after the complete HTTP header is received. |
|
Called after receiving the request-line. |
|
Called after receiving the status-line. |
|
Move assignment. |
This parser is designed to efficiently parse messages in the HTTP/1 wire
format. It allocates no memory when input is presented as a single contiguous
buffer, and uses minimal state. It will handle chunked encoding and it understands
the semantics of the Connection, Content-Length, and Upgrade fields. The
parser is optimized for the case where the input buffer sequence consists
of a single contiguous buffer. The beast::basic_flat_buffer
class is provided,
which guarantees that the input sequence of the stream buffer will be represented
by exactly one contiguous buffer. To ensure the optimum performance of the
parser, use beast::basic_flat_buffer
with HTTP algorithms
such as read
, read_some
, async_read
, and async_read_some
. Alternatively,
the caller may use custom techniques to ensure that the structured portion
of the HTTP message (header or chunk header) is contained in a linear buffer.
The interface to the parser uses virtual member functions. To use this class,
derive your type from basic_parser
. When bytes are presented,
the implementation will make a series of zero or more calls to virtual functions,
which the derived class must implement.
Every virtual function must be provided by the derived class, or else a compilation
error will be generated. The implementation will make sure that ec
is clear before each virtual function
is invoked. If a virtual function sets an error, it is propagated out of
the parser to the caller.
Type |
Description |
---|---|
|
A |
If the parser encounters a field value with obs-fold longer than 4 kilobytes in length, an error is generated.