 |
Kea
1.5.0
|
Go to the documentation of this file.
7 #ifndef HTTP_MESSAGE_PARSER_BASE_H
8 #define HTTP_MESSAGE_PARSER_BASE_H
13 #include <boost/function.hpp>
142 void postBuffer(
const void* buf,
const size_t buf_size);
163 const size_t limit = 0);
169 using StateModel::runModel;
198 boost::function<
void(
const char c)>
218 boost::function<
void(
const std::string&)>
268 const unsigned int event);
288 bool isChar(
const char c)
const;
293 bool isCtl(
const char c)
const;
bool popNextFromBuffer(std::string &next, const size_t limit=1)
Tries to read next byte from buffer.
std::string getBufferAsString(const size_t limit=0) const
Returns parser's input buffer as string.
static const int SM_DERIVED_STATE_MIN
Value at which custom states in a derived class should begin.
bool needData() const
Returns true if the parser needs more data to continue.
static const int HTTP_PARSE_OK_EVT
Parsing HTTP request successful.
static const int HTTP_PARSE_OK_ST
Parsing successfully completed.
void parseEndedHandler()
Handler for HTTP_PARSE_OK_ST and HTTP_PARSE_FAILED_ST.
virtual void onModelFailure(const std::string &explanation)
A method called when parsing fails.
Base class for the HTTP message parsers.
virtual void defineStates()
Defines states of the parser.
virtual void verifyEvents()
Verifies events used by the parser.
This is a base class for exceptions thrown from the DNS library module.
HttpParseError(const char *file, size_t line, const char *what)
bool httpParseOk() const
Returns true if the message has been parsed successfully.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static const int NEED_MORE_DATA_EVT
Unable to proceed with parsing until new data is provided.
Base class for HttpRequest and HttpResponse.
HttpMessage & message_
Reference to the parsed HTTP message.
std::string buffer_
Internal buffer from which parser reads data.
size_t buffer_pos_
Position of the next character to read from the buffer.
void getNextFromBuffer(std::string &bytes, const size_t limit=1)
Retrieves next bytes of data from the buffer.
bool isChar(const char c) const
Checks if specified value is a character.
bool isSpecial(const char c) const
Checks if specified value is a special character.
void parseFailure(const std::string &error_msg)
Transition parser to failure state.
void invalidEventError(const std::string &handler_name, const unsigned int event)
This method is called when invalid event occurred in a particular parser state.
std::string getErrorMessage() const
Returns error message.
static const int SM_DERIVED_EVENT_MIN
Value at which custom events in a derived class should begin.
static const int DATA_READ_OK_EVT
Chunk of data successfully read and parsed.
static std::string logFormatHttpMessage(const std::string &message, const size_t limit=0)
Formats provided HTTP message for logging.
void stateWithReadHandler(const std::string &handler_name, boost::function< void(const char c)> after_read_logic)
Generic parser handler which reads a single byte of data and parses it using specified callback funct...
void poll()
Run the parser as long as the amount of data is sufficient.
HttpMessageParserBase(HttpMessage &message)
Constructor.
bool isCtl(const char c) const
Checks if specified value is a control value.
void stateWithMultiReadHandler(const std::string &handler_name, boost::function< void(const std::string &)> after_read_logic)
Generic parser handler which reads multiple bytes of data and parses it using specified callback func...
virtual void defineEvents()
Define events used by the parser.
static const int MORE_DATA_PROVIDED_EVT
New data provided and parsing should continue.
static const int HTTP_PARSE_FAILED_ST
Parsing failed.
static const int HTTP_PARSE_FAILED_EVT
Parsing HTTP request failed.
Implements a finite state machine.
void postBuffer(const void *buf, const size_t buf_size)
Provides more input data to the parser.
Exception thrown when an error during parsing HTTP message has occurred.
std::string error_message_
Error message set by onModelFailure.