12 #include "utils/HttpHeader.h" 13 #include "utils/RingBuffer.h" 18 typedef void CURL_HANDLE;
40 bool Open(
const CURL& url)
override;
41 bool OpenForWrite(
const CURL& url,
bool bOverWrite =
false)
override;
42 bool ReOpen(
const CURL& url)
override;
43 bool Exists(
const CURL& url)
override;
44 int64_t
Seek(int64_t iFilePosition,
int iWhence=SEEK_SET)
override;
45 int64_t GetPosition()
override;
46 int64_t GetLength()
override;
47 int Stat(
const CURL& url,
struct __stat64* buffer)
override;
48 void Close()
override;
49 bool ReadString(
char *szLine,
int iLineLength)
override {
return m_state->ReadString(szLine, iLineLength); }
50 ssize_t
Read(
void* lpBuf,
size_t uiBufSize)
override {
return m_state->Read(lpBuf, uiBufSize); }
51 ssize_t
Write(
const void* lpBuf,
size_t uiBufSize)
override;
52 const std::string GetProperty(XFILE::FileProperty type,
const std::string &name =
"")
const override;
53 const std::vector<std::string> GetPropertyValues(XFILE::FileProperty type,
const std::string &name =
"")
const override;
54 int IoControl(EIoControl request,
void* param)
override;
55 double GetDownloadSpeed()
override;
57 bool Post(
const std::string& strURL,
const std::string& strPostData, std::string& strHTML);
58 bool Get(
const std::string& strURL, std::string& strHTML);
59 bool ReadData(std::string& strHTML);
60 bool Download(
const std::string& strURL,
const std::string& strFileName,
unsigned int* pdwSize = NULL);
64 void SetUserAgent(
const std::string& sUserAgent) { m_userAgent = sUserAgent; }
65 void SetProxy(
const std::string &type,
const std::string &host, uint16_t port,
66 const std::string &user,
const std::string &password);
67 void SetCustomRequest(
const std::string &request) { m_customrequest = request; }
68 void SetAcceptEncoding(
const std::string& encoding) { m_acceptencoding = encoding; }
69 void SetAcceptCharset(
const std::string& charset) { m_acceptCharset = charset; }
70 void SetTimeout(
int connecttimeout) { m_connecttimeout = connecttimeout; }
71 void SetLowSpeedTime(
int lowspeedtime) { m_lowspeedtime = lowspeedtime; }
72 void SetPostData(
const std::string& postdata) { m_postdata = postdata; }
73 void SetReferer(
const std::string& referer) { m_referer = referer; }
74 void SetCookie(
const std::string& cookie) { m_cookie = cookie; }
75 void SetMimeType(
const std::string& mimetype) { SetRequestHeader(
"Content-Type", mimetype); }
76 void SetRequestHeader(
const std::string& header,
const std::string& value);
77 void SetRequestHeader(
const std::string& header,
long value);
79 void ClearRequestHeaders();
80 void SetBufferSize(
unsigned int size);
82 const CHttpHeader& GetHttpHeader()
const {
return m_state->m_httpheader; }
83 std::string GetURL(
void);
84 std::string GetRedirectURL();
88 static bool GetMimeType(
const CURL &url, std::string &content,
const std::string &useragent=
"");
89 static bool GetContentType(
const CURL &url, std::string &content,
const std::string &useragent =
"");
92 static bool GetCookies(
const CURL &url, std::string &cookies);
99 CURL_HANDLE* m_easyHandle;
100 CURLM* m_multiHandle;
103 unsigned int m_bufferSize;
105 char* m_overflowBuffer;
106 unsigned int m_overflowSize;
121 bool IsHeaderDone(
void) {
return m_httpheader.IsHeaderDone(); }
123 curl_slist* m_curlHeaderList;
124 curl_slist* m_curlAliasList;
126 size_t ReadCallback(
char *buffer,
size_t size,
size_t nitems);
127 size_t WriteCallback(
char *buffer,
size_t size,
size_t nitems);
128 size_t HeaderCallback(
void *ptr,
size_t size,
size_t nmemb);
130 bool Seek(int64_t
pos);
131 ssize_t Read(
void* lpBuf,
size_t uiBufSize);
132 bool ReadString(
char *szLine,
int iLineLength);
133 int8_t FillBuffer(
unsigned int want);
134 void SetReadBuffer(
const void* lpBuf, int64_t uiBufSize);
136 void SetResume(
void);
137 long Connect(
unsigned int size);
143 void SetCommonOptions(
CReadState* state,
bool failOnError =
true);
146 bool Service(
const std::string& strURL, std::string& strHTML);
147 std::string GetInfoString(
int infoType);
152 unsigned int m_bufferSize;
153 int64_t m_writeOffset = 0;
156 std::string m_userAgent;
157 ProxyType m_proxytype = PROXY_HTTP;
158 std::string m_proxyhost;
159 uint16_t m_proxyport = 3128;
160 std::string m_proxyuser;
161 std::string m_proxypassword;
162 std::string m_customrequest;
163 std::string m_acceptencoding;
164 std::string m_acceptCharset;
165 std::string m_ftpauth;
166 std::string m_ftpport;
167 std::string m_binary;
168 std::string m_postdata;
169 std::string m_referer;
170 std::string m_cookie;
171 std::string m_username;
172 std::string m_password;
173 std::string m_httpauth;
174 std::string m_cipherlist;
176 int m_connecttimeout;
187 bool m_verifyPeer =
true;
188 bool m_failOnError =
true;
189 curl_slist* m_dnsCacheList =
nullptr;
192 char* m_overflowBuffer;
193 unsigned int m_overflowSize = 0;
197 typedef std::map<std::string, std::string> MAPHTTPHEADERS;
198 MAPHTTPHEADERS m_requestheaders;
ssize_t Read(void *lpBuf, size_t uiBufSize) override
Attempt to read bufSize bytes from currently opened file into buffer bufPtr.
Definition: CurlFile.h:50
int Stat(const CURL &url, struct __stat64 *buffer) override
Fills struct __stat64 with information about file specified by url.
Definition: CurlFile.cpp:1500
Definition: CurlFile.h:94
void ParseAndCorrectUrl(CURL &url)
Definition: CurlFile.cpp:733
size_t WriteCallback(char *buffer, size_t size, size_t nitems)
Definition: CurlFile.cpp:183
Definition: LibInputPointer.h:13
ssize_t Write(const void *lpBuf, size_t uiBufSize) override
Attempt to write bufSize bytes from buffer bufPtr into currently opened file.
Definition: CurlFile.cpp:1221
Definition: RingBuffer.h:13
Definition: CurlFile.h:24
int64_t Seek(int64_t iFilePosition, int iWhence=SEEK_SET) override
Definition: CurlFile.cpp:1390