Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <HTTPMessageParser.h>
Classes | |
class | cCallbacks |
Public Member Functions | |
cHTTPMessageParser (cCallbacks &a_Callbacks) | |
Creates a new parser instance that will use the specified callbacks for reporting. More... | |
void | Finish (void) |
Called when the server indicates no more data will be sent (HTTP 1.0 socket closed). More... | |
bool | IsFinished (void) const |
Returns true if the entire response has been already parsed. More... | |
size_t | Parse (const char *a_Data, size_t a_Size) |
Parses the incoming data and calls the appropriate callbacks. More... | |
void | Reset (void) |
Resets the parser to the initial state, so that a new request can be parsed. More... | |
Protected Member Functions | |
void | HeadersFinished (void) |
Called internally when the headers-parsing has just finished. More... | |
virtual void | OnBodyData (const void *a_Data, size_t a_Size) override |
Called for each chunk of the incoming body data. More... | |
virtual void | OnBodyFinished (void) override |
Called when the entire body has been reported by OnBodyData(). More... | |
virtual void | OnError (const AString &a_ErrorDescription) override |
Called when an error has occured while parsing. More... | |
virtual void | OnHeaderLine (const AString &a_Key, const AString &a_Value) override |
Called when a full header line is parsed. More... | |
size_t | ParseBody (const char *a_Data, size_t a_Size) |
Parses the message body. More... | |
size_t | ParseFirstLine (void) |
Parses the first line out of m_Buffer. More... | |
Protected Member Functions inherited from cEnvelopeParser::cCallbacks | |
virtual | ~cCallbacks () |
Protected Member Functions inherited from cTransferEncodingParser::cCallbacks | |
virtual | ~cCallbacks () |
Protected Attributes | |
AString | m_Buffer |
Buffer for the incoming data until the status line is parsed. More... | |
cCallbacks & | m_Callbacks |
The callbacks used for reporting. More... | |
size_t | m_ContentLength |
The content length, parsed from the headers, if available. More... | |
cEnvelopeParser | m_EnvelopeParser |
Parser for the envelope data (headers) More... | |
AString | m_FirstLine |
The complete first line of the response. More... | |
bool | m_HasHadError |
Set to true if an error has been encountered by the parser. More... | |
bool | m_IsFinished |
True if the response has been fully parsed. More... | |
AString | m_TransferEncoding |
The transfer encoding to be used by the parser. More... | |
cTransferEncodingParserPtr | m_TransferEncodingParser |
The specific parser for the transfer encoding used by this response. More... | |
Definition at line 20 of file HTTPMessageParser.h.
cHTTPMessageParser::cHTTPMessageParser | ( | cHTTPMessageParser::cCallbacks & | a_Callbacks | ) |
Creates a new parser instance that will use the specified callbacks for reporting.
Definition at line 14 of file HTTPMessageParser.cpp.
void cHTTPMessageParser::Finish | ( | void | ) |
Called when the server indicates no more data will be sent (HTTP 1.0 socket closed).
Finishes all parsing and calls apropriate callbacks (error if incomplete response).
|
protected |
Called internally when the headers-parsing has just finished.
Definition at line 159 of file HTTPMessageParser.cpp.
|
inline |
Returns true if the entire response has been already parsed.
Definition at line 63 of file HTTPMessageParser.h.
|
overrideprotectedvirtual |
Called for each chunk of the incoming body data.
Implements cTransferEncodingParser::cCallbacks.
Definition at line 207 of file HTTPMessageParser.cpp.
|
overrideprotectedvirtual |
Called when the entire body has been reported by OnBodyData().
Implements cTransferEncodingParser::cCallbacks.
Definition at line 216 of file HTTPMessageParser.cpp.
|
overrideprotectedvirtual |
Called when an error has occured while parsing.
Implements cTransferEncodingParser::cCallbacks.
Definition at line 197 of file HTTPMessageParser.cpp.
|
overrideprotectedvirtual |
Called when a full header line is parsed.
Implements cEnvelopeParser::cCallbacks.
Definition at line 174 of file HTTPMessageParser.cpp.
size_t cHTTPMessageParser::Parse | ( | const char * | a_Data, |
size_t | a_Size | ||
) |
Parses the incoming data and calls the appropriate callbacks.
Returns the number of bytes consumed or AString::npos number for error.
Definition at line 25 of file HTTPMessageParser.cpp.
|
protected |
Parses the message body.
Processes transfer encoding and calls the callbacks for body data. Returns the number of bytes consumed or AString::npos number for error.
Definition at line 141 of file HTTPMessageParser.cpp.
|
protected |
Parses the first line out of m_Buffer.
Removes the first line from m_Buffer, if appropriate. Returns the number of bytes consumed out of m_Buffer, or AString::npos number for error.
Definition at line 123 of file HTTPMessageParser.cpp.
void cHTTPMessageParser::Reset | ( | void | ) |
Resets the parser to the initial state, so that a new request can be parsed.
Definition at line 107 of file HTTPMessageParser.cpp.
|
protected |
Buffer for the incoming data until the status line is parsed.
Definition at line 84 of file HTTPMessageParser.h.
|
protected |
The callbacks used for reporting.
Definition at line 72 of file HTTPMessageParser.h.
|
protected |
The content length, parsed from the headers, if available.
Unused for chunked encoding. Filled while parsing headers, used when headers are finished.
Definition at line 99 of file HTTPMessageParser.h.
|
protected |
Parser for the envelope data (headers)
Definition at line 87 of file HTTPMessageParser.h.
|
protected |
The complete first line of the response.
Empty if not parsed yet.
Definition at line 81 of file HTTPMessageParser.h.
|
protected |
Set to true if an error has been encountered by the parser.
Definition at line 75 of file HTTPMessageParser.h.
|
protected |
True if the response has been fully parsed.
Definition at line 78 of file HTTPMessageParser.h.
|
protected |
The transfer encoding to be used by the parser.
Filled while parsing headers, used when headers are finished.
Definition at line 94 of file HTTPMessageParser.h.
|
protected |
The specific parser for the transfer encoding used by this response.
Definition at line 90 of file HTTPMessageParser.h.