...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 : private basic_parser_base
Name |
Description |
---|---|
true if this parser parses requests, false for responses. |
Name |
Description |
---|---|
Copy constructor. |
|
Set the limit on the payload body. |
|
Returns true if the last value for Transfer-Encoding is "chunked". |
|
Returns the optional value of Content-Length if known. |
|
Returns the remaining content length if known. |
|
Returns true if the eager parse option is set. Set the eager parse option. |
|
Returns true if the parser has received at least one byte of input. |
|
Set a limit on the total size of the header. |
|
Returns true if the message is complete. |
|
Returns true if a the parser has produced the full header. |
|
Returns true if the message has keep-alive connection semantics. |
|
Returns true if the message semantics require an end of file. |
|
Copy assignment. |
|
Write a buffer sequence to the parser. |
|
Inform the parser that the end of stream was reached. |
|
Returns true if the skip parse option is set. Set the skip parse option. |
|
Returns true if the message is an upgrade message. |
|
Destructor. |
Name |
Description |
---|---|
Default constructor. Move 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 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 basic_flat_buffer
with HTTP algorithms
such as http::read
, http::read_some
, http::async_read
, and http::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 http::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.
Convenience header <boost/beast/http.hpp>