DDraceNetwork Docs
CHttpRequest Class Reference

#include <http.h>

Inheritance diagram for CHttpRequest:
[legend]
Collaboration diagram for CHttpRequest:
[legend]

Public Member Functions

 CHttpRequest (const char *pUrl)
 
virtual ~CHttpRequest ()
 
void Timeout (CTimeout Timeout)
 
void MaxResponseSize (int64_t MaxResponseSize)
 
void IfModifiedSince (int64_t IfModifiedSince)
 
void LogProgress (HTTPLOG LogProgress)
 
void IpResolve (IPRESOLVE IpResolve)
 
void FailOnErrorStatus (bool FailOnErrorStatus)
 
void WriteToFile (IStorage *pStorage, const char *pDest, int StorageType)
 
void ExpectSha256 (const SHA256_DIGEST &Sha256)
 
void Head ()
 
void Post (const unsigned char *pData, size_t DataLength)
 
void PostJson (const char *pJson)
 
void Header (const char *pNameColonValue)
 
void HeaderString (const char *pName, const char *pValue)
 
void HeaderInt (const char *pName, int Value)
 
const char * Dest ()
 
double Current () const
 
double Size () const
 
int Progress () const
 
EHttpState State () const
 
bool Done () const
 
void Abort ()
 
void Wait ()
 
void Result (unsigned char **ppResult, size_t *pResultLength) const
 
json_valueResultJson () const
 
const SHA256_DIGESTResultSha256 () const
 
int StatusCode () const
 
std::optional< int64_t > ResultAgeSeconds () const
 
std::optional< int64_t > ResultLastModified () const
 

Protected Member Functions

virtual void OnProgress ()
 
virtual void OnCompletion (EHttpState State)
 

Private Types

enum class  REQUEST { GET = 0 , HEAD , POST , POST_JSON }
 

Private Member Functions

bool BeforeInit ()
 
bool ConfigureHandle (void *pHandle)
 
void OnCompletionInternal (void *pHandle, unsigned int Result)
 
size_t OnHeader (char *pHeader, size_t HeaderSize)
 
size_t OnData (char *pData, size_t DataSize)
 

Static Private Member Functions

static constexpr const char * GetRequestType (REQUEST Type)
 
static int ProgressCallback (void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr)
 
static size_t HeaderCallback (char *pData, size_t Size, size_t Number, void *pUser)
 
static size_t WriteCallback (char *pData, size_t Size, size_t Number, void *pUser)
 

Private Attributes

char m_aUrl [256] = {0}
 
void * m_pHeaders = nullptr
 
unsigned char * m_pBody = nullptr
 
size_t m_BodyLength = 0
 
CTimeout m_Timeout = CTimeout{0, 0, 0, 0}
 
int64_t m_MaxResponseSize = -1
 
int64_t m_IfModifiedSince = -1
 
REQUEST m_Type = REQUEST::GET
 
SHA256_DIGEST m_ActualSha256 = SHA256_ZEROED
 
SHA256_CTX m_ActualSha256Ctx
 
SHA256_DIGEST m_ExpectedSha256 = SHA256_ZEROED
 
bool m_WriteToFile = false
 
uint64_t m_ResponseLength = 0
 
size_t m_BufferSize = 0
 
unsigned char * m_pBuffer = nullptr
 
IOHANDLE m_File = nullptr
 
char m_aDestAbsolute [IO_MAX_PATH_LENGTH] = {0}
 
char m_aDest [IO_MAX_PATH_LENGTH] = {0}
 
std::atomic< double > m_Size {0.0}
 
std::atomic< double > m_Current {0.0}
 
std::atomic< int > m_Progress {0}
 
HTTPLOG m_LogProgress = HTTPLOG::ALL
 
IPRESOLVE m_IpResolve = IPRESOLVE::WHATEVER
 
bool m_FailOnErrorStatus = true
 
char m_aErr [256]
 
std::atomic< EHttpStatem_State {EHttpState::QUEUED}
 
std::atomic< bool > m_Abort {false}
 
std::mutex m_WaitMutex
 
std::condition_variable m_WaitCondition
 
int m_StatusCode = 0
 
bool m_HeadersEnded = false
 
std::optional< int64_t > m_ResultDate = {}
 
std::optional< int64_t > m_ResultLastModified = {}
 

Friends

class CHttp
 

Member Enumeration Documentation

◆ REQUEST

enum class CHttpRequest::REQUEST
strongprivate
Enumerator
GET 
HEAD 
POST 
POST_JSON 

Constructor & Destructor Documentation

◆ CHttpRequest()

CHttpRequest::CHttpRequest ( const char *  pUrl)

◆ ~CHttpRequest()

CHttpRequest::~CHttpRequest ( )
virtual

Member Function Documentation

◆ Abort()

void CHttpRequest::Abort ( )
inline

◆ BeforeInit()

bool CHttpRequest::BeforeInit ( )
private

◆ ConfigureHandle()

bool CHttpRequest::ConfigureHandle ( void *  pHandle)
private

◆ Current()

double CHttpRequest::Current ( ) const
inline

◆ Dest()

const char * CHttpRequest::Dest ( )
inline

◆ Done()

bool CHttpRequest::Done ( ) const
inline

◆ ExpectSha256()

void CHttpRequest::ExpectSha256 ( const SHA256_DIGEST Sha256)
inline

◆ FailOnErrorStatus()

void CHttpRequest::FailOnErrorStatus ( bool  FailOnErrorStatus)
inline

◆ GetRequestType()

static constexpr const char * CHttpRequest::GetRequestType ( REQUEST  Type)
inlinestaticconstexprprivate

◆ Head()

void CHttpRequest::Head ( )
inline

◆ Header()

void CHttpRequest::Header ( const char *  pNameColonValue)

◆ HeaderCallback()

size_t CHttpRequest::HeaderCallback ( char *  pData,
size_t  Size,
size_t  Number,
void *  pUser 
)
staticprivate

◆ HeaderInt()

void CHttpRequest::HeaderInt ( const char *  pName,
int  Value 
)
inline

◆ HeaderString()

void CHttpRequest::HeaderString ( const char *  pName,
const char *  pValue 
)
inline

◆ IfModifiedSince()

void CHttpRequest::IfModifiedSince ( int64_t  IfModifiedSince)
inline

◆ IpResolve()

void CHttpRequest::IpResolve ( IPRESOLVE  IpResolve)
inline

◆ LogProgress()

void CHttpRequest::LogProgress ( HTTPLOG  LogProgress)
inline

◆ MaxResponseSize()

void CHttpRequest::MaxResponseSize ( int64_t  MaxResponseSize)
inline

◆ OnCompletion()

virtual void CHttpRequest::OnCompletion ( EHttpState  State)
inlineprotectedvirtual

Reimplemented in CUpdaterFetchTask.

◆ OnCompletionInternal()

void CHttpRequest::OnCompletionInternal ( void *  pHandle,
unsigned int  Result 
)
private

◆ OnData()

size_t CHttpRequest::OnData ( char *  pData,
size_t  DataSize 
)
private

◆ OnHeader()

size_t CHttpRequest::OnHeader ( char *  pHeader,
size_t  HeaderSize 
)
private

◆ OnProgress()

virtual void CHttpRequest::OnProgress ( )
inlineprotectedvirtual

Reimplemented in CUpdaterFetchTask.

◆ Post()

void CHttpRequest::Post ( const unsigned char *  pData,
size_t  DataLength 
)
inline

◆ PostJson()

void CHttpRequest::PostJson ( const char *  pJson)
inline

◆ Progress()

int CHttpRequest::Progress ( ) const
inline

◆ ProgressCallback()

int CHttpRequest::ProgressCallback ( void *  pUser,
double  DlTotal,
double  DlCurr,
double  UlTotal,
double  UlCurr 
)
staticprivate

◆ Result()

void CHttpRequest::Result ( unsigned char **  ppResult,
size_t *  pResultLength 
) const

◆ ResultAgeSeconds()

std::optional< int64_t > CHttpRequest::ResultAgeSeconds ( ) const

◆ ResultJson()

json_value * CHttpRequest::ResultJson ( ) const

◆ ResultLastModified()

std::optional< int64_t > CHttpRequest::ResultLastModified ( ) const

◆ ResultSha256()

const SHA256_DIGEST & CHttpRequest::ResultSha256 ( ) const

◆ Size()

double CHttpRequest::Size ( ) const
inline

◆ State()

EHttpState CHttpRequest::State ( ) const
inline

◆ StatusCode()

int CHttpRequest::StatusCode ( ) const

◆ Timeout()

void CHttpRequest::Timeout ( CTimeout  Timeout)
inline

◆ Wait()

void CHttpRequest::Wait ( )

◆ WriteCallback()

size_t CHttpRequest::WriteCallback ( char *  pData,
size_t  Size,
size_t  Number,
void *  pUser 
)
staticprivate

◆ WriteToFile()

void CHttpRequest::WriteToFile ( IStorage pStorage,
const char *  pDest,
int  StorageType 
)

Friends And Related Function Documentation

◆ CHttp

friend class CHttp
friend

Member Data Documentation

◆ m_Abort

std::atomic<bool> CHttpRequest::m_Abort {false}
private

◆ m_ActualSha256

SHA256_DIGEST CHttpRequest::m_ActualSha256 = SHA256_ZEROED
private

◆ m_ActualSha256Ctx

SHA256_CTX CHttpRequest::m_ActualSha256Ctx
private

◆ m_aDest

char CHttpRequest::m_aDest[IO_MAX_PATH_LENGTH] = {0}
private

◆ m_aDestAbsolute

char CHttpRequest::m_aDestAbsolute[IO_MAX_PATH_LENGTH] = {0}
private

◆ m_aErr

char CHttpRequest::m_aErr[256]
private

◆ m_aUrl

char CHttpRequest::m_aUrl[256] = {0}
private

◆ m_BodyLength

size_t CHttpRequest::m_BodyLength = 0
private

◆ m_BufferSize

size_t CHttpRequest::m_BufferSize = 0
private

◆ m_Current

std::atomic<double> CHttpRequest::m_Current {0.0}
private

◆ m_ExpectedSha256

SHA256_DIGEST CHttpRequest::m_ExpectedSha256 = SHA256_ZEROED
private

◆ m_FailOnErrorStatus

bool CHttpRequest::m_FailOnErrorStatus = true
private

◆ m_File

IOHANDLE CHttpRequest::m_File = nullptr
private

◆ m_HeadersEnded

bool CHttpRequest::m_HeadersEnded = false
private

◆ m_IfModifiedSince

int64_t CHttpRequest::m_IfModifiedSince = -1
private

◆ m_IpResolve

IPRESOLVE CHttpRequest::m_IpResolve = IPRESOLVE::WHATEVER
private

◆ m_LogProgress

HTTPLOG CHttpRequest::m_LogProgress = HTTPLOG::ALL
private

◆ m_MaxResponseSize

int64_t CHttpRequest::m_MaxResponseSize = -1
private

◆ m_pBody

unsigned char* CHttpRequest::m_pBody = nullptr
private

◆ m_pBuffer

unsigned char* CHttpRequest::m_pBuffer = nullptr
private

◆ m_pHeaders

void* CHttpRequest::m_pHeaders = nullptr
private

◆ m_Progress

std::atomic<int> CHttpRequest::m_Progress {0}
private

◆ m_ResponseLength

uint64_t CHttpRequest::m_ResponseLength = 0
private

◆ m_ResultDate

std::optional<int64_t> CHttpRequest::m_ResultDate = {}
private

◆ m_ResultLastModified

std::optional<int64_t> CHttpRequest::m_ResultLastModified = {}
private

◆ m_Size

std::atomic<double> CHttpRequest::m_Size {0.0}
private

◆ m_State

std::atomic<EHttpState> CHttpRequest::m_State {EHttpState::QUEUED}
private

◆ m_StatusCode

int CHttpRequest::m_StatusCode = 0
private

◆ m_Timeout

CTimeout CHttpRequest::m_Timeout = CTimeout{0, 0, 0, 0}
private

◆ m_Type

REQUEST CHttpRequest::m_Type = REQUEST::GET
private

◆ m_WaitCondition

std::condition_variable CHttpRequest::m_WaitCondition
private

◆ m_WaitMutex

std::mutex CHttpRequest::m_WaitMutex
private

◆ m_WriteToFile

bool CHttpRequest::m_WriteToFile = false
private

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