From bf05086381b75cfaf900d9142a599bd6e1d77e9c Mon Sep 17 00:00:00 2001 From: anschrammh Date: Thu, 7 Apr 2022 01:18:01 +0200 Subject: [PATCH] Added new structure to handle partial content requests --- src/app/WEBClient.cpp | 2 +- src/app/WEBClient.h | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/WEBClient.cpp b/src/app/WEBClient.cpp index 13df51a..e8357d1 100644 --- a/src/app/WEBClient.cpp +++ b/src/app/WEBClient.cpp @@ -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::WEBClientState::ACCEPTED), _httpParserState(WEBServer::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"); diff --git a/src/app/WEBClient.h b/src/app/WEBClient.h index 9342099..c2587cc 100644 --- a/src/app/WEBClient.h +++ b/src/app/WEBClient.h @@ -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::WEBClientState _WEBClientState; + WEBServer::WEBClientState _WEBClientState = WEBServer::WEBClientState::ACCEPTED; private: WEBServer::HttpRequestData _httpRequestData; - WEBServer::HttpParserStatus _httpParserState; - uint64_t _fileSentBytes; - uint64_t _range; //Used to store the value of the range param for file downloading + WEBServer::HttpParserStatus _httpParserState = WEBServer::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(); };