#ifndef WEBCLIENT_H
#define WEBCLIENT_H

#include "WEBServer.h"
#include "TCPClient.h"

class WEBClient : public TCPClient
{
  template <typename T>
	friend class WEBServer;
	public:
		WEBClient(WiFiClient client, uint8_t id, uint16_t maxResourceBuffer = 256, uint16_t maxBodyBuffer = 256, uint16_t dataBufferSize = 512);
		virtual ~WEBClient();
	protected:
    WEBServer<WEBClient>::WEBClientState _WEBClientState = WEBServer<WEBClient>::WEBClientState::ACCEPTED;
	private:
    WEBServer<WEBClient>::HttpRequestData _httpRequestData;
    WEBServer<WEBClient>::HttpParserStatus _httpParserState = WEBServer<WEBClient>::HttpParserStatus::PARSE_HTTP_VERB;
    size_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();
};

#endif //WEBCLIENT_H
