本文整理汇总了C++中CurlResource::do_callback方法的典型用法代码示例。如果您正苦于以下问题:C++ CurlResource::do_callback方法的具体用法?C++ CurlResource::do_callback怎么用?C++ CurlResource::do_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurlResource
的用法示例。
在下文中一共展示了CurlResource::do_callback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: curl_write_header
static size_t curl_write_header(char *data, size_t size, size_t nmemb,
void *ctx) {
CurlResource *ch = (CurlResource *)ctx;
WriteHandler *t = &ch->m_write_header;
size_t length = size * nmemb;
switch (t->method) {
case PHP_CURL_STDOUT:
// Handle special case write when we're returning the entire transfer
if (ch->m_write.method == PHP_CURL_RETURN && length > 0) {
ch->m_write.buf.append(data, (int)length);
} else {
echo(String(data, length, AttachLiteral));
}
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
case PHP_CURL_USER:
{
Variant ret = ch->do_callback(
t->callback,
CREATE_VECTOR2(Object(ch), String(data, length, CopyString)));
length = ret.toInt64();
}
break;
case PHP_CURL_IGNORE:
return length;
default:
return (size_t)-1;
}
return length;
}
示例2: curl_read
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) {
CurlResource *ch = (CurlResource *)ctx;
ReadHandler *t = &ch->m_read;
int length = -1;
switch (t->method) {
case PHP_CURL_DIRECT:
if (!t->fp.isNull()) {
int data_size = size * nmemb;
String ret = t->fp->read(data_size);
length = ret.size();
if (length) {
memcpy(data, ret.data(), length);
}
}
break;
case PHP_CURL_USER:
{
int data_size = size * nmemb;
Variant ret = ch->do_callback(
t->callback, CREATE_VECTOR3(Object(ch), t->fp->fd(), data_size));
if (ret.isString()) {
String sret = ret.toString();
length = data_size < sret.size() ? data_size : sret.size();
memcpy(data, sret.data(), length);
}
break;
}
}
return length;
}
示例3: curl_write
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) {
CurlResource *ch = (CurlResource *)ctx;
WriteHandler *t = &ch->m_write;
size_t length = size * nmemb;
switch (t->method) {
case PHP_CURL_STDOUT:
echo(String(data, length, AttachLiteral));
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
case PHP_CURL_RETURN:
if (length > 0) {
t->buf.append(data, (int)length);
}
break;
case PHP_CURL_USER:
{
Variant ret = ch->do_callback(
t->callback,
CREATE_VECTOR2(Object(ch), String(data, length, CopyString)));
length = ret.toInt64();
}
break;
}
return length;
}
示例4: curl_write
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) {
CurlResource *ch = (CurlResource *)ctx;
WriteHandler *t = &ch->m_write;
size_t length = size * nmemb;
switch (t->method) {
case PHP_CURL_STDOUT:
g_context->write(data, length);
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, CopyString), length);
case PHP_CURL_RETURN:
if (length > 0) {
t->buf.append(data, (int)length);
}
break;
case PHP_CURL_USER:
{
Variant ret = ch->do_callback(
t->callback,
make_packed_array(Resource(ch), String(data, length, CopyString)));
length = ret.toInt64();
}
break;
}
return length;
}