
/*---------------------------------------------------------------------------*/
/* webserver_webdav_message_handler.h                                        */
/* copyright (c) innovaphone 2016                                            */
/*                                                                           */
/*---------------------------------------------------------------------------*/

// This is the base class used by all webdav related message handlers.
class WebserverWebdavMessageHandler : public WebserverMessageHandler {
private:
    bool needSetTransferInfoV1 = false;
    ulong64 dataSizeV1 = 0;
    ws_webdav_result_t webdavResultV1 = WEBDAV_RESULT_OK;
    void SetTransferInfoV1();

public:
    WebserverWebdavMessageHandler(const char * interfaceName,
                                  msg_handler_type_t handlerType,
                                  UWebserverMessageHandler * baseUser,
                                  byte * extHeaderBuffer,
                                  dword connectionID,
                                  ulong64 dataSize,
                                  IWebserverMessage * const webserverMessageSend,
                                  char * resourceName,
                                  char * reqRegPath,
                                  class ExtendedHeader & extHeader,
                                  class IInstanceLog * const log,
                                  word protocolVersion);

    virtual ~WebserverWebdavMessageHandler();

    virtual bool IsWebdavHandler() { return true; }

    virtual void SetResultCode(ws_webdav_result_t result, ulong64 dataSize);
    virtual void SetStatusCode(dword code, const char* description = nullptr) override;
    virtual void SetTransferInfo(wsr_type_t resourceType, ulong64 dataSize, wsr_flags_t flags, const char* etag = nullptr) override;

    virtual void Send(const void* buffer, size_t len) override;
    virtual void Cancel(wsr_cancel_type_t reason) override;
    virtual void Close() override;
};