ESP32 HTTPS Server
httpsserver::HTTPBodyParser Class Referenceabstract

#include <HTTPBodyParser.hpp>

Inheritance diagram for httpsserver::HTTPBodyParser:
Collaboration diagram for httpsserver::HTTPBodyParser:

Public Member Functions

 HTTPBodyParser (HTTPRequest *req)
 
virtual bool nextField ()=0
 
virtual std::string getFieldName ()=0
 
virtual std::string getFieldFilename ()=0
 
virtual std::string getFieldMimeType ()=0
 
virtual size_t read (byte *buffer, size_t bufferSize)=0
 
virtual bool endOfField ()=0
 

Public Attributes

const size_t unknownLength = 0x7ffffffe
 

Protected Attributes

HTTPRequest_request
 

Detailed Description

Superclass for various body parser implementations that can be used to interpret http-specific bodies (like x-www-form-urlencoded or multipart/form-data)

To allow for arbitrary body length, the interface of the body parser provides access to one underlying "field" at a time. A field may be a value of the urlencoded string or a part of a multipart message.

Using next() proceeds to the next field.

Member Function Documentation

◆ endOfField()

virtual bool httpsserver::HTTPBodyParser::endOfField ( )
pure virtual

Returns true when all field data has been read

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

◆ getFieldFilename()

virtual std::string httpsserver::HTTPBodyParser::getFieldFilename ( )
pure virtual

Returns the filename of the current field or an empty string

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

◆ getFieldMimeType()

virtual std::string httpsserver::HTTPBodyParser::getFieldMimeType ( )
pure virtual

Returns the mime type of the current field.

Note: This value is set by the client. It can be altered maliciously. Do NOT rely on it for anything that affects the security of your device or other clients connected to it!

Not every BodyParser might provide this value, usually it's set to something like text/plain then

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

◆ getFieldName()

virtual std::string httpsserver::HTTPBodyParser::getFieldName ( )
pure virtual

Returns the name of the current field

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

◆ nextField()

virtual bool httpsserver::HTTPBodyParser::nextField ( )
pure virtual

Proceeds to the next field of the body

If a field has not been read completely, the remaining content is discarded.

Returns true iff proceeding to the next field succeeded (ie there was a next field)

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

◆ read()

virtual size_t httpsserver::HTTPBodyParser::read ( byte *  buffer,
size_t  bufferSize 
)
pure virtual

Reads a maximum of bufferSize bytes into buffer and returns the actual amount of bytes that have been read

Implemented in httpsserver::HTTPURLEncodedBodyParser, and httpsserver::HTTPMultipartBodyParser.

Member Data Documentation

◆ _request

HTTPRequest* httpsserver::HTTPBodyParser::_request
protected

The underlying request


The documentation for this class was generated from the following file: