25 public std::map<AString, AString>,
60 void Parse(
const char * a_Data,
size_t a_Size);
108 virtual void OnPartData (
const char * a_Data,
size_t a_Size)
override;
bool Finish(void)
Notifies that there's no more data incoming and the parser should finish its parsing.
void ParseFormUrlEncoded(void)
Parses m_IncomingData as form-urlencoded data (fpkURL or fpkFormUrlEncoded kinds)
std::unique_ptr< cMultipartParser > m_MultipartParser
The parser for the multipart data, if used.
eKind m_Kind
The kind of the parser (decided in the constructor, used in Parse()
virtual void OnPartHeader(const AString &a_Key, const AString &a_Value) override
Called when a complete header line is received for a part.
virtual void OnPartStart(void) override
Called when a new part starts.
bool m_IsCurrentPartFile
True if the currently parsed part in multipart data is a file.
AString m_CurrentPartFileName
Filename of the current parsed part in multipart data (for file uploads)
AString m_CurrentPartName
Name of the currently parsed part in multipart data.
virtual void OnPartEnd(void) override
Called when the current part ends.
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.
void BeginMultipart(const cHTTPIncomingRequest &a_Request)
Sets up the object for parsing a fpkMultipart request.
bool m_FileHasBeenAnnounced
Set to true after m_Callbacks.OnFileStart() has been called, reset to false on PartEnd.
bool m_IsValid
True if the information received so far is a valid form; set to false on first problem.
static bool HasFormData(const cHTTPIncomingRequest &a_Request)
Returns true if the headers suggest the request has form data parseable by this class.
@ fpkURL
The form has been transmitted as parameters to a GET request.
@ fpkFormUrlEncoded
The form has been POSTed or PUT, with Content-Type of "application/x-www-form-urlencoded".
@ fpkMultipart
The form has been POSTed or PUT, with Content-Type of "multipart/form-data".
virtual void OnPartData(const char *a_Data, size_t a_Size) override
Called when body for a part is received.
cCallbacks & m_Callbacks
The callbacks to call for incoming file data.
AString m_IncomingData
Buffer for the incoming data until it's parsed.
void Parse(const char *a_Data, size_t a_Size)
Adds more data into the parser, as the request body is received.
virtual void OnFileEnd(cHTTPFormParser &a_Parser)=0
Called when the current file part has ended in the form data.
virtual void OnFileData(cHTTPFormParser &a_Parser, const char *a_Data, size_t a_Size)=0
Called when more file data has come for the current file in the form data.
virtual void OnFileStart(cHTTPFormParser &a_Parser, const AString &a_FileName)=0
Called when a new file part is encountered in the form data.
Provides storage for an incoming HTTP request.