boost::burl::parser
A parser for HTTP/1 messages.
Synopsis
Declared in <boost/burl/parser.hpp>
class parser;
Description
The parser performs no I/O. Received bytes are handed to it through prepare and commit, and each parsing operation reports http::error::need_data when it requires more. Driving the parser over a stream is the job of message_reader.
The parser uses a single block of memory allocated during construction and never exceeds it. The space is reused across messages, one at a time, and holds:
-
raw octets received from the stream,
-
the message header, with O(1) access to the start line,
-
all or part of the message body, and
-
decoded output when a
decoderis installed.
Operations
The body can be retrieved three ways, which differ in where the octets end up:
-
bodyreturns the whole body in place, without copying, -
read_somecopies into caller‐supplied memory, or lets an installed decoder write into it directly, and -
pullborrows the parser's own buffers, whichconsumethen releases.
Errors
Every parsing operation reports through an error_code out parameter:
-
http::error::need_data— fillprepare, callcommit, and try again. Reported only whilepreparehas room. -
http::error::in_place_overflow— more input is required but no writable space remains. -
http::error::incomplete— more input is required butcommit_eofwas called. -
http::error::end_of_stream— the stream closed cleanly before the message began.
An operation reports either transferred octets or an error, never both.
Member Functions
Name |
Description |
Return the complete body in place. |
|
Return the unconsumed octets in the buffer. |
|
Report octets received into the buffer. |
|
Report octets received into caller memory. |
|
Report the end of the stream. |
|
Release body octets returned by |
|
Return the octets which may be received directly. |
|
Return true if the entire message has arrived. |
|
Return true if the header has been parsed. |
|
Return true if octets are buffered past the message. |
|
Parse the message header. |
|
Return the buffer region for receiving octets. |
|
Return available body octets in place. |
|
Copy body octets into caller‐supplied memory. |
|
Prepare for a new stream. |
|
Set the maximum body size. |
|
Install a content decoder. |
Protected Member Functions
Name |
Description |
|
Constructors |
|
Destructor |
|
Assignment operators |
See Also
message_reader, request_parser, response_parser.
Created with MrDocs