Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
XFILE::CCurlFile Class Reference

#include <CurlFile.h>

Inheritance diagram for XFILE::CCurlFile:
XFILE::IFile XFILE::CDAVFile

Classes

class  CReadState
 

Public Member Functions

 CCurlFile ()
 
 ~CCurlFile () override
 
bool Open (const CURL &url) override
 
bool OpenForWrite (const CURL &url, bool bOverWrite=false) override
 
bool ReOpen (const CURL &url) override
 
bool Exists (const CURL &url) override
 
int64_t Seek (int64_t iFilePosition, int iWhence=SEEK_SET) override
 
int64_t GetPosition () override
 
int64_t GetLength () override
 
int Stat (const CURL &url, struct __stat64 *buffer) override
 
void Close () override
 
bool ReadString (char *szLine, int iLineLength) override
 
ssize_t Read (void *lpBuf, size_t uiBufSize) override
 
ssize_t Write (const void *lpBuf, size_t uiBufSize) override
 
const std::string GetProperty (XFILE::FileProperty type, const std::string &name="") const override
 
const std::vector< std::string > GetPropertyValues (XFILE::FileProperty type, const std::string &name="") const override
 
int IoControl (EIoControl request, void *param) override
 
double GetDownloadSpeed () override
 
bool Post (const std::string &strURL, const std::string &strPostData, std::string &strHTML)
 
bool Get (const std::string &strURL, std::string &strHTML)
 
bool ReadData (std::string &strHTML)
 
bool Download (const std::string &strURL, const std::string &strFileName, unsigned int *pdwSize=NULL)
 
bool IsInternet ()
 
void Cancel ()
 
void Reset ()
 
void SetUserAgent (const std::string &sUserAgent)
 
void SetProxy (const std::string &type, const std::string &host, uint16_t port, const std::string &user, const std::string &password)
 
void SetCustomRequest (const std::string &request)
 
void SetAcceptEncoding (const std::string &encoding)
 
void SetAcceptCharset (const std::string &charset)
 
void SetTimeout (int connecttimeout)
 
void SetLowSpeedTime (int lowspeedtime)
 
void SetPostData (const std::string &postdata)
 
void SetReferer (const std::string &referer)
 
void SetCookie (const std::string &cookie)
 
void SetMimeType (const std::string &mimetype)
 
void SetRequestHeader (const std::string &header, const std::string &value)
 
void SetRequestHeader (const std::string &header, long value)
 
void ClearRequestHeaders ()
 
void SetBufferSize (unsigned int size)
 
const CHttpHeaderGetHttpHeader () const
 
std::string GetURL (void)
 
std::string GetRedirectURL ()
 
- Public Member Functions inherited from XFILE::IFile
 IFile ()
 
virtual ~IFile ()
 
virtual int Stat (struct __stat64 *buffer)
 
virtual void Flush ()
 
virtual int Truncate (int64_t size)
 
virtual int GetChunkSize ()
 
virtual bool Delete (const CURL &url)
 
virtual bool Rename (const CURL &url, const CURL &urlnew)
 
virtual bool SetHidden (const CURL &url, bool hidden)
 

Static Public Member Functions

static bool GetHttpHeader (const CURL &url, CHttpHeader &headers)
 
static bool GetMimeType (const CURL &url, std::string &content, const std::string &useragent="")
 
static bool GetContentType (const CURL &url, std::string &content, const std::string &useragent="")
 
static bool GetCookies (const CURL &url, std::string &cookies)
 

Protected Types

typedef std::map< std::string, std::string > MAPHTTPHEADERS
 

Protected Member Functions

void ParseAndCorrectUrl (CURL &url)
 
void SetCommonOptions (CReadState *state, bool failOnError=true)
 
void SetRequestHeaders (CReadState *state)
 
void SetCorrectHeaders (CReadState *state)
 
bool Service (const std::string &strURL, std::string &strHTML)
 
std::string GetInfoString (int infoType)
 

Protected Attributes

CReadStatem_state
 
CReadStatem_oldState
 
unsigned int m_bufferSize
 
int64_t m_writeOffset = 0
 
std::string m_url
 
std::string m_userAgent
 
ProxyType m_proxytype = PROXY_HTTP
 
std::string m_proxyhost
 
uint16_t m_proxyport = 3128
 
std::string m_proxyuser
 
std::string m_proxypassword
 
std::string m_customrequest
 
std::string m_acceptencoding
 
std::string m_acceptCharset
 
std::string m_ftpauth
 
std::string m_ftpport
 
std::string m_binary
 
std::string m_postdata
 
std::string m_referer
 
std::string m_cookie
 
std::string m_username
 
std::string m_password
 
std::string m_httpauth
 
std::string m_cipherlist
 
bool m_ftppasvip
 
int m_connecttimeout
 
int m_redirectlimit
 
int m_lowspeedtime
 
bool m_opened
 
bool m_forWrite
 
bool m_inError
 
bool m_seekable
 
bool m_multisession
 
bool m_skipshout
 
bool m_postdataset
 
bool m_allowRetry
 
bool m_verifyPeer = true
 
bool m_failOnError = true
 
curl_slist * m_dnsCacheList = nullptr
 
CRingBuffer m_buffer
 
char * m_overflowBuffer
 
unsigned int m_overflowSize = 0
 
int m_stillRunning
 
MAPHTTPHEADERS m_requestheaders
 
long m_httpresponse
 

Member Typedef Documentation

◆ MAPHTTPHEADERS

typedef std::map<std::string, std::string> XFILE::CCurlFile::MAPHTTPHEADERS
protected

Constructor & Destructor Documentation

◆ CCurlFile()

CCurlFile::CCurlFile ( )

◆ ~CCurlFile()

CCurlFile::~CCurlFile ( )
override

Member Function Documentation

◆ Cancel()

void CCurlFile::Cancel ( )

◆ ClearRequestHeaders()

void CCurlFile::ClearRequestHeaders ( )

◆ Close()

void CCurlFile::Close ( )
overridevirtual

Implements XFILE::IFile.

◆ Download()

bool CCurlFile::Download ( const std::string & strURL,
const std::string & strFileName,
unsigned int * pdwSize = NULL )

◆ Exists()

bool CCurlFile::Exists ( const CURL & url)
overridevirtual

Implements XFILE::IFile.

◆ Get()

bool CCurlFile::Get ( const std::string & strURL,
std::string & strHTML )

◆ GetContentType()

bool CCurlFile::GetContentType ( const CURL & url,
std::string & content,
const std::string & useragent = "" )
static

◆ GetCookies()

bool CCurlFile::GetCookies ( const CURL & url,
std::string & cookies )
static

◆ GetDownloadSpeed()

double CCurlFile::GetDownloadSpeed ( )
overridevirtual

Reimplemented from XFILE::IFile.

◆ GetHttpHeader() [1/2]

const CHttpHeader & XFILE::CCurlFile::GetHttpHeader ( ) const
inline

◆ GetHttpHeader() [2/2]

bool CCurlFile::GetHttpHeader ( const CURL & url,
CHttpHeader & headers )
static

◆ GetInfoString()

std::string CCurlFile::GetInfoString ( int infoType)
protected

◆ GetLength()

int64_t CCurlFile::GetLength ( )
overridevirtual

Implements XFILE::IFile.

◆ GetMimeType()

bool CCurlFile::GetMimeType ( const CURL & url,
std::string & content,
const std::string & useragent = "" )
static

◆ GetPosition()

int64_t CCurlFile::GetPosition ( )
overridevirtual

Implements XFILE::IFile.

◆ GetProperty()

const std::string CCurlFile::GetProperty ( XFILE::FileProperty type,
const std::string & name = "" ) const
overridevirtual

Reimplemented from XFILE::IFile.

◆ GetPropertyValues()

const std::vector< std::string > CCurlFile::GetPropertyValues ( XFILE::FileProperty type,
const std::string & name = "" ) const
overridevirtual

Reimplemented from XFILE::IFile.

◆ GetRedirectURL()

std::string CCurlFile::GetRedirectURL ( )

◆ GetURL()

std::string CCurlFile::GetURL ( void )

◆ IoControl()

int CCurlFile::IoControl ( EIoControl request,
void * param )
overridevirtual

Reimplemented from XFILE::IFile.

◆ IsInternet()

bool CCurlFile::IsInternet ( )

◆ Open()

bool CCurlFile::Open ( const CURL & url)
overridevirtual

Implements XFILE::IFile.

◆ OpenForWrite()

bool CCurlFile::OpenForWrite ( const CURL & url,
bool bOverWrite = false )
overridevirtual

Reimplemented from XFILE::IFile.

◆ ParseAndCorrectUrl()

void CCurlFile::ParseAndCorrectUrl ( CURL & url)
protected
Todo
create a tokenizer that doesn't skip empty's

◆ Post()

bool CCurlFile::Post ( const std::string & strURL,
const std::string & strPostData,
std::string & strHTML )

◆ Read()

ssize_t XFILE::CCurlFile::Read ( void * bufPtr,
size_t bufSize )
inlineoverridevirtual

Attempt to read bufSize bytes from currently opened file into buffer bufPtr.

Parameters
bufPtrpointer to buffer
bufSizesize of the buffer
Returns
number of successfully read bytes if any bytes were read and stored in buffer, zero if no bytes are available to read (end of file was reached) or undetectable error occur, -1 in case of any explicit error

Implements XFILE::IFile.

◆ ReadData()

bool CCurlFile::ReadData ( std::string & strHTML)

◆ ReadString()

bool XFILE::CCurlFile::ReadString ( char * szLine,
int iLineLength )
inlineoverridevirtual

Reimplemented from XFILE::IFile.

◆ ReOpen()

bool CCurlFile::ReOpen ( const CURL & url)
overridevirtual

Reimplemented from XFILE::IFile.

◆ Reset()

void CCurlFile::Reset ( )

◆ Seek()

int64_t CCurlFile::Seek ( int64_t iFilePosition,
int iWhence = SEEK_SET )
overridevirtual
Todo
daap is gone. is this needed for something else?

Implements XFILE::IFile.

◆ Service()

bool CCurlFile::Service ( const std::string & strURL,
std::string & strHTML )
protected

◆ SetAcceptCharset()

void XFILE::CCurlFile::SetAcceptCharset ( const std::string & charset)
inline

◆ SetAcceptEncoding()

void XFILE::CCurlFile::SetAcceptEncoding ( const std::string & encoding)
inline

◆ SetBufferSize()

void CCurlFile::SetBufferSize ( unsigned int size)

◆ SetCommonOptions()

void CCurlFile::SetCommonOptions ( CReadState * state,
bool failOnError = true )
protected

◆ SetCookie()

void XFILE::CCurlFile::SetCookie ( const std::string & cookie)
inline

◆ SetCorrectHeaders()

void CCurlFile::SetCorrectHeaders ( CReadState * state)
protected

◆ SetCustomRequest()

void XFILE::CCurlFile::SetCustomRequest ( const std::string & request)
inline

◆ SetLowSpeedTime()

void XFILE::CCurlFile::SetLowSpeedTime ( int lowspeedtime)
inline

◆ SetMimeType()

void XFILE::CCurlFile::SetMimeType ( const std::string & mimetype)
inline

◆ SetPostData()

void XFILE::CCurlFile::SetPostData ( const std::string & postdata)
inline

◆ SetProxy()

void CCurlFile::SetProxy ( const std::string & type,
const std::string & host,
uint16_t port,
const std::string & user,
const std::string & password )

◆ SetReferer()

void XFILE::CCurlFile::SetReferer ( const std::string & referer)
inline

◆ SetRequestHeader() [1/2]

void CCurlFile::SetRequestHeader ( const std::string & header,
const std::string & value )

◆ SetRequestHeader() [2/2]

void CCurlFile::SetRequestHeader ( const std::string & header,
long value )

◆ SetRequestHeaders()

void CCurlFile::SetRequestHeaders ( CReadState * state)
protected

◆ SetTimeout()

void XFILE::CCurlFile::SetTimeout ( int connecttimeout)
inline

◆ SetUserAgent()

void XFILE::CCurlFile::SetUserAgent ( const std::string & sUserAgent)
inline

◆ Stat()

int CCurlFile::Stat ( const CURL & url,
struct __stat64 * buffer )
overridevirtual

Fills struct __stat64 with information about file specified by url. For st_mode function will set correctly _S_IFDIR (directory) flag and may set _S_IREAD (read permission), _S_IWRITE (write permission) flags if such information is available. Function may set st_size (file size), st_atime, st_mtime, st_ctime (access, modification, creation times). Any other flags and members of __stat64 that didn't updated with actual file information will be set to zero (st_nlink can be set ether to 1 or zero).

Parameters
urlspecifies requested file
bufferpointer to __stat64 buffer to receive information about file
Returns
zero of success, -1 otherwise.

Implements XFILE::IFile.

◆ Write()

ssize_t CCurlFile::Write ( const void * bufPtr,
size_t bufSize )
overridevirtual

Attempt to write bufSize bytes from buffer bufPtr into currently opened file.

Parameters
bufPtrpointer to buffer
bufSizesize of the buffer
Returns
number of successfully written bytes if any bytes were written, zero if no bytes were written and no detectable error occur, -1 in case of any explicit error

Reimplemented from XFILE::IFile.

Member Data Documentation

◆ m_acceptCharset

std::string XFILE::CCurlFile::m_acceptCharset
protected

◆ m_acceptencoding

std::string XFILE::CCurlFile::m_acceptencoding
protected

◆ m_allowRetry

bool XFILE::CCurlFile::m_allowRetry
protected

◆ m_binary

std::string XFILE::CCurlFile::m_binary
protected

◆ m_buffer

CRingBuffer XFILE::CCurlFile::m_buffer
protected

◆ m_bufferSize

unsigned int XFILE::CCurlFile::m_bufferSize
protected

◆ m_cipherlist

std::string XFILE::CCurlFile::m_cipherlist
protected

◆ m_connecttimeout

int XFILE::CCurlFile::m_connecttimeout
protected

◆ m_cookie

std::string XFILE::CCurlFile::m_cookie
protected

◆ m_customrequest

std::string XFILE::CCurlFile::m_customrequest
protected

◆ m_dnsCacheList

curl_slist* XFILE::CCurlFile::m_dnsCacheList = nullptr
protected

◆ m_failOnError

bool XFILE::CCurlFile::m_failOnError = true
protected

◆ m_forWrite

bool XFILE::CCurlFile::m_forWrite
protected

◆ m_ftpauth

std::string XFILE::CCurlFile::m_ftpauth
protected

◆ m_ftppasvip

bool XFILE::CCurlFile::m_ftppasvip
protected

◆ m_ftpport

std::string XFILE::CCurlFile::m_ftpport
protected

◆ m_httpauth

std::string XFILE::CCurlFile::m_httpauth
protected

◆ m_httpresponse

long XFILE::CCurlFile::m_httpresponse
protected

◆ m_inError

bool XFILE::CCurlFile::m_inError
protected

◆ m_lowspeedtime

int XFILE::CCurlFile::m_lowspeedtime
protected

◆ m_multisession

bool XFILE::CCurlFile::m_multisession
protected

◆ m_oldState

CReadState* XFILE::CCurlFile::m_oldState
protected

◆ m_opened

bool XFILE::CCurlFile::m_opened
protected

◆ m_overflowBuffer

char* XFILE::CCurlFile::m_overflowBuffer
protected

◆ m_overflowSize

unsigned int XFILE::CCurlFile::m_overflowSize = 0
protected

◆ m_password

std::string XFILE::CCurlFile::m_password
protected

◆ m_postdata

std::string XFILE::CCurlFile::m_postdata
protected

◆ m_postdataset

bool XFILE::CCurlFile::m_postdataset
protected

◆ m_proxyhost

std::string XFILE::CCurlFile::m_proxyhost
protected

◆ m_proxypassword

std::string XFILE::CCurlFile::m_proxypassword
protected

◆ m_proxyport

uint16_t XFILE::CCurlFile::m_proxyport = 3128
protected

◆ m_proxytype

ProxyType XFILE::CCurlFile::m_proxytype = PROXY_HTTP
protected

◆ m_proxyuser

std::string XFILE::CCurlFile::m_proxyuser
protected

◆ m_redirectlimit

int XFILE::CCurlFile::m_redirectlimit
protected

◆ m_referer

std::string XFILE::CCurlFile::m_referer
protected

◆ m_requestheaders

MAPHTTPHEADERS XFILE::CCurlFile::m_requestheaders
protected

◆ m_seekable

bool XFILE::CCurlFile::m_seekable
protected

◆ m_skipshout

bool XFILE::CCurlFile::m_skipshout
protected

◆ m_state

CReadState* XFILE::CCurlFile::m_state
protected

◆ m_stillRunning

int XFILE::CCurlFile::m_stillRunning
protected

◆ m_url

std::string XFILE::CCurlFile::m_url
protected

◆ m_userAgent

std::string XFILE::CCurlFile::m_userAgent
protected

◆ m_username

std::string XFILE::CCurlFile::m_username
protected

◆ m_verifyPeer

bool XFILE::CCurlFile::m_verifyPeer = true
protected

◆ m_writeOffset

int64_t XFILE::CCurlFile::m_writeOffset = 0
protected

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