fastdo
0.6.16
首页
命名空间
类
文件
文件列表
文件成员
eiennet_curl.hpp
浏览该文件的文档.
1
#ifndef __CURL_HPP__
2
#define __CURL_HPP__
3
4
// curl.h的一些类型
5
typedef
void
CURL
;
6
struct
curl_slist;
7
struct
curl_httppost;
8
9
namespace
eiennet
10
{
11
13
class
EIENNET_DLL
CUrlError
:
public
winux::Error
14
{
15
public
:
16
CUrlError
(
int
errNo,
winux::AnsiString
const
& errStr ) :
winux
::Error( errNo, errStr ) { }
17
};
18
20
class
EIENNET_DLL
CUrlLib
21
{
22
public
:
23
static
char
const
* GetVersion();
24
25
CUrlLib
();
26
~
CUrlLib
();
27
DISABLE_OBJECT_COPY
(
CUrlLib
)
28
};
29
31
class
EIENNET_DLL
SList
32
{
33
public
:
34
SList
();
35
virtual
~
SList
();
36
void
free();
37
void
append(
char
const
* s );
38
void
append(
winux::AnsiString
const
& str );
39
40
operator
struct
curl_slist * ()
const
{
return
_slist; }
41
private
:
42
struct
curl_slist * _slist;
43
44
DISABLE_OBJECT_COPY
(
SList
)
45
};
46
48
class
EIENNET_DLL
PostMultipart
49
{
50
public
:
51
PostMultipart
();
52
virtual
~
PostMultipart
();
53
void
free();
55
void
addVar(
winux::AnsiString
const
& name,
winux::AnsiString
const
& value );
57
void
addFile(
winux::AnsiString
const
& name,
winux::AnsiString
const
& filename,
winux::AnsiString
const
& showfilename =
""
);
59
void
addFile(
winux::AnsiString
const
& name,
char
const
* data,
long
size,
winux::AnsiString
const
& showfilename );
60
61
operator
struct
curl_httppost * ()
const
{
return
_first; }
62
63
private
:
64
struct
curl_httppost * _first;
65
struct
curl_httppost * _last;
66
67
DISABLE_OBJECT_COPY
(
PostMultipart
)
68
};
69
71
class
EIENNET_DLL
CUrl
72
{
73
public
:
75
CUrl
(
bool
isInit =
true
);
76
CUrl
(
CUrl
const
& other );
77
virtual
~
CUrl
();
78
80
CUrl
& operator = (
CUrl
const
& other );
81
83
void
init();
84
86
void
cleanup();
87
89
bool
perform();
90
92
void
reset();
93
94
// set options ------------------------------------------------
98
void
setHttpGet(
bool
b =
true
);
99
104
void
setHttpPost(
bool
b =
true
);
105
107
void
setUrl(
winux::AnsiString
const
& url );
108
110
void
setTimeout(
winux::ulong
timeout );
111
113
void
setErrorBuffer(
char
* errBuf );
114
116
void
setNoProgress(
bool
b );
117
119
void
setUsername(
winux::AnsiString
const
& username );
120
122
void
setPassword(
winux::AnsiString
const
& password );
123
125
void
setPostFields(
winux::AnsiString
const
& data );
126
128
void
setPostFieldSize(
long
size );
129
131
void
setPostMultipart(
PostMultipart
const
& data );
132
134
void
setHttpHeader(
SList
const
& headers );
135
137
void
setVerbose(
bool
b );
138
140
void
setCookieJar(
winux::AnsiString
const
& filename );
141
145
void
setSslVerifyPeer(
bool
b );
146
150
void
setSslVerifyHost(
bool
b );
151
152
// set handlers -----------------------------------------------
153
typedef
size_t (* WriteFunction)(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
155
void
setWriteHandler( WriteFunction handler );
157
void
setWriteHandlerData(
void
* data );
158
159
typedef
size_t (* ReadFunction)(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
161
void
setReadHandler( ReadFunction handler );
163
void
setReadHandlerData(
void
* data );
164
165
typedef
size_t (* HeaderFunction)(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
167
void
setHeaderHandler( HeaderFunction handler );
169
void
setHeaderHandlerData(
void
* data );
170
171
typedef
int (* ProgressFunction)(
void
* data,
double
dltotal,
double
dlnow,
double
ultotal,
double
ulnow );
173
void
setProgressHandler( ProgressFunction handler );
175
void
setProgressHandlerData(
void
* data );
176
177
// get curlinfo after call perform() --------------------------
179
winux::AnsiString
getContentType()
const
;
180
181
// attributes -------------------------------------------------
182
operator
CURL
* ()
const
{
return
_curl; }
183
185
int
errNo
()
const
{
return
_errNo; }
186
188
char
const
* errNoStr()
const
;
189
191
char
const
* error()
const
;
192
193
protected
:
194
// '写'回调函数,回调函数将转到成员虚函数进行响应
195
static
size_t
WriteCallback(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
196
// 当发生'写'动作
197
virtual
size_t
OnWrite(
char
* buf,
size_t
itemSize,
size_t
count );
198
199
// '读'回调函数
200
static
size_t
ReadCallback(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
201
// 当发生'读'动作
202
virtual
size_t
OnRead(
char
* buf,
size_t
itemSize,
size_t
count );
203
204
// '头部'数据回调函数
205
static
size_t
HeaderCallback(
char
* buf,
size_t
itemSize,
size_t
count,
void
* data );
206
// 当'头部'数据到
207
virtual
size_t
OnHeader(
char
* buf,
size_t
itemSize,
size_t
count );
208
209
// '进度'回调函数
210
static
int
ProgressCallback(
void
* data,
double
dltotal,
double
dlnow,
double
ultotal,
double
ulnow );
211
// 当'下载进度'操作
212
virtual
int
OnDownloadProgress(
double
dltotal,
double
dlnow );
213
// 当'上传进度'操作
214
virtual
int
OnUploadProgress(
double
ultotal,
double
ulnow );
215
216
protected
:
217
CURL
*
_curl
;
218
int
_errNo
;
219
winux::AnsiString
_errBuf
;
220
};
221
222
223
}
// namespace eiennet
224
225
#endif // __CURL_HPP__
winux::AnsiString
XString< char > AnsiString
Definition:
utilities.hpp:257
eiennet::CUrlLib
curl库初始化
Definition:
eiennet_curl.hpp:20
eiennet::SList
libcurl的字符串链表
Definition:
eiennet_curl.hpp:31
eiennet::CUrl::_curl
CURL * _curl
Definition:
eiennet_curl.hpp:217
DISABLE_OBJECT_COPY
#define DISABLE_OBJECT_COPY(clsname)
Definition:
utilities.hpp:85
CURL
void CURL
Definition:
eiennet_curl.hpp:5
EIENNET_DLL
#define EIENNET_DLL
Definition:
eiennet_base.hpp:21
eiennet::CUrl::_errBuf
winux::AnsiString _errBuf
Definition:
eiennet_curl.hpp:219
eiennet
网络通信库
Definition:
eiennet_async.hpp:3
eiennet::PostMultipart
http post请求以“multipart/formdata”方式发送数据的支持类
Definition:
eiennet_curl.hpp:48
eiennet::CUrlError::CUrlError
CUrlError(int errNo, winux::AnsiString const &errStr)
Definition:
eiennet_curl.hpp:16
winux::Error
错误类
Definition:
utilities.hpp:838
eiennet::CUrl::errNo
int errNo() const
执行后得到的错误码(CURLcode)
Definition:
eiennet_curl.hpp:185
eiennet::CUrlError
curl错误
Definition:
eiennet_curl.hpp:13
winux::ulong
unsigned long ulong
Definition:
utilities.hpp:216
eiennet::CUrl::_errNo
int _errNo
CURLcode.
Definition:
eiennet_curl.hpp:218
eiennet::CUrl
libcurl低层封装,主要提供了CURL句柄资源管理功能
Definition:
eiennet_curl.hpp:71
winux
跨平台基础功能库
Definition:
archives.hpp:7
dist
x64
include
eiennet_curl.hpp
生成于 2024年 十二月 24日 星期二 01:35:06 , 为 fastdo使用
1.8.11