Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <HTTPFormParser.h>
Classes | |
class | cCallbacks |
Public Types | |
enum | eKind { fpkURL , fpkFormUrlEncoded , fpkMultipart } |
Public Member Functions | |
cHTTPFormParser (const cHTTPIncomingRequest &a_Request, cCallbacks &a_Callbacks) | |
Creates a parser that is tied to a request and notifies of various events using a callback mechanism. More... | |
cHTTPFormParser (eKind a_Kind, const char *a_Data, size_t a_Size, cCallbacks &a_Callbacks) | |
Creates a parser with the specified content type that reads data from a string. More... | |
bool | Finish (void) |
Notifies that there's no more data incoming and the parser should finish its parsing. More... | |
void | Parse (const char *a_Data, size_t a_Size) |
Adds more data into the parser, as the request body is received. More... | |
Public Member Functions inherited from cMultipartParser::cCallbacks | |
virtual | ~cCallbacks () |
Static Public Member Functions | |
static bool | HasFormData (const cHTTPIncomingRequest &a_Request) |
Returns true if the headers suggest the request has form data parseable by this class. More... | |
Protected Member Functions | |
void | BeginMultipart (const cHTTPIncomingRequest &a_Request) |
Sets up the object for parsing a fpkMultipart request. More... | |
virtual void | OnPartData (const char *a_Data, size_t a_Size) override |
Called when body for a part is received. More... | |
virtual void | OnPartEnd (void) override |
Called when the current part ends. More... | |
virtual void | OnPartHeader (const AString &a_Key, const AString &a_Value) override |
Called when a complete header line is received for a part. More... | |
virtual void | OnPartStart (void) override |
Called when a new part starts. More... | |
void | ParseFormUrlEncoded (void) |
Parses m_IncomingData as form-urlencoded data (fpkURL or fpkFormUrlEncoded kinds) More... | |
Protected Attributes | |
cCallbacks & | m_Callbacks |
The callbacks to call for incoming file data. More... | |
AString | m_CurrentPartFileName |
Filename of the current parsed part in multipart data (for file uploads) More... | |
AString | m_CurrentPartName |
Name of the currently parsed part in multipart data. More... | |
bool | m_FileHasBeenAnnounced |
Set to true after m_Callbacks.OnFileStart() has been called, reset to false on PartEnd. More... | |
AString | m_IncomingData |
Buffer for the incoming data until it's parsed. More... | |
bool | m_IsCurrentPartFile |
True if the currently parsed part in multipart data is a file. More... | |
bool | m_IsValid |
True if the information received so far is a valid form; set to false on first problem. More... | |
eKind | m_Kind |
The kind of the parser (decided in the constructor, used in Parse() More... | |
std::unique_ptr< cMultipartParser > | m_MultipartParser |
The parser for the multipart data, if used. More... | |
Definition at line 24 of file HTTPFormParser.h.
Definition at line 29 of file HTTPFormParser.h.
cHTTPFormParser::cHTTPFormParser | ( | const cHTTPIncomingRequest & | a_Request, |
cCallbacks & | a_Callbacks | ||
) |
Creates a parser that is tied to a request and notifies of various events using a callback mechanism.
Definition at line 15 of file HTTPFormParser.cpp.
cHTTPFormParser::cHTTPFormParser | ( | eKind | a_Kind, |
const char * | a_Data, | ||
size_t | a_Size, | ||
cCallbacks & | a_Callbacks | ||
) |
Creates a parser with the specified content type that reads data from a string.
Definition at line 56 of file HTTPFormParser.cpp.
|
protected |
Sets up the object for parsing a fpkMultipart request.
Definition at line 140 of file HTTPFormParser.cpp.
bool cHTTPFormParser::Finish | ( | void | ) |
Notifies that there's no more data incoming and the parser should finish its parsing.
Returns true if parsing successful.
Definition at line 99 of file HTTPFormParser.cpp.
|
static |
Returns true if the headers suggest the request has form data parseable by this class.
Definition at line 123 of file HTTPFormParser.cpp.
|
overrideprotectedvirtual |
Called when body for a part is received.
Implements cMultipartParser::cCallbacks.
Definition at line 253 of file HTTPFormParser.cpp.
|
overrideprotectedvirtual |
Called when the current part ends.
Implements cMultipartParser::cCallbacks.
Definition at line 289 of file HTTPFormParser.cpp.
|
overrideprotectedvirtual |
Called when a complete header line is received for a part.
Implements cMultipartParser::cCallbacks.
Definition at line 208 of file HTTPFormParser.cpp.
|
overrideprotectedvirtual |
Called when a new part starts.
Implements cMultipartParser::cCallbacks.
Definition at line 196 of file HTTPFormParser.cpp.
void cHTTPFormParser::Parse | ( | const char * | a_Data, |
size_t | a_Size | ||
) |
Adds more data into the parser, as the request body is received.
Definition at line 70 of file HTTPFormParser.cpp.
|
protected |
Parses m_IncomingData as form-urlencoded data (fpkURL or fpkFormUrlEncoded kinds)
Definition at line 150 of file HTTPFormParser.cpp.
|
protected |
The callbacks to call for incoming file data.
Definition at line 72 of file HTTPFormParser.h.
|
protected |
Filename of the current parsed part in multipart data (for file uploads)
Definition at line 93 of file HTTPFormParser.h.
|
protected |
Name of the currently parsed part in multipart data.
Definition at line 87 of file HTTPFormParser.h.
|
protected |
Set to true after m_Callbacks.OnFileStart() has been called, reset to false on PartEnd.
Definition at line 96 of file HTTPFormParser.h.
|
protected |
Buffer for the incoming data until it's parsed.
Definition at line 78 of file HTTPFormParser.h.
|
protected |
True if the currently parsed part in multipart data is a file.
Definition at line 90 of file HTTPFormParser.h.
|
protected |
True if the information received so far is a valid form; set to false on first problem.
Further parsing is skipped when false.
Definition at line 81 of file HTTPFormParser.h.
|
protected |
The kind of the parser (decided in the constructor, used in Parse()
Definition at line 75 of file HTTPFormParser.h.
|
protected |
The parser for the multipart data, if used.
Definition at line 84 of file HTTPFormParser.h.