Added new structure to handle partial content requests

This commit is contained in:
anschrammh 2022-04-07 01:18:01 +02:00
parent 5fb02304be
commit bf05086381
2 changed files with 11 additions and 5 deletions

View File

@ -2,7 +2,7 @@
//#define DEBUG_WEBCL
WEBClient::WEBClient(WiFiClient client, uint8_t id, uint16_t maxResourceBuffer, uint16_t maxBodyBuffer, uint16_t dataBufferSize) : TCPClient(client, id, dataBufferSize), _WEBClientState(WEBServer<WEBClient>::WEBClientState::ACCEPTED), _httpParserState(WEBServer<WEBClient>::HttpParserStatus::HTTP_VERB), _fileSentBytes(0), _range(0)
WEBClient::WEBClient(WiFiClient client, uint8_t id, uint16_t maxResourceBuffer, uint16_t maxBodyBuffer, uint16_t dataBufferSize) : TCPClient(client, id, dataBufferSize)
{
#ifdef DEBUG_WEBCL
Serial.println("WEBClient : Standard constructor called");

View File

@ -12,12 +12,18 @@ class WEBClient : public TCPClient
WEBClient(WiFiClient client, uint8_t id, uint16_t maxResourceBuffer = 255, uint16_t maxBodyBuffer = 255, uint16_t dataBufferSize = 511);
virtual ~WEBClient();
protected:
WEBServer<WEBClient>::WEBClientState _WEBClientState;
WEBServer<WEBClient>::WEBClientState _WEBClientState = WEBServer<WEBClient>::WEBClientState::ACCEPTED;
private:
WEBServer<WEBClient>::HttpRequestData _httpRequestData;
WEBServer<WEBClient>::HttpParserStatus _httpParserState;
uint64_t _fileSentBytes;
uint64_t _range; //Used to store the value of the range param for file downloading
WEBServer<WEBClient>::HttpParserStatus _httpParserState = WEBServer<WEBClient>::HttpParserStatus::HTTP_VERB;
uint64_t _fileSentBytes = 0;
struct
{
bool _rangeRequest;
size_t _rangeStart;
size_t _rangeEnd;
} _rangeData = {false, 0, 0}; //Used to store the values of the range param for file downloads and media playback
bool _keepAlive = false;
void clearHttpRequestData();
};