本文整理汇总了C++中CURLRaii::init方法的典型用法代码示例。如果您正苦于以下问题:C++ CURLRaii::init方法的具体用法?C++ CURLRaii::init怎么用?C++ CURLRaii::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CURLRaii
的用法示例。
在下文中一共展示了CURLRaii::init方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processGetTask
// Process Get Request
int processGetTask(EJHttpRequest *request, write_callback callback, void *stream, int32_t *responseCode) {
CURLRaii curl;
bool ok = curl.init(request, callback, stream)
&& curl.setOption(CURLOPT_FOLLOWLOCATION, true)
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例2: processGetTask
//Process Get Request
static int processGetTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer)
{
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream, errorBuffer)
&& curl.setOption(CURLOPT_FOLLOWLOCATION, true)
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例3: processDeleteTask
//Process DELETE Request
static int processDeleteTask(CCHttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream)
{
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream)
&& curl.setOption(CURLOPT_CUSTOMREQUEST, "DELETE")
&& curl.setOption(CURLOPT_FOLLOWLOCATION, true)
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例4: processPutTask
// Process PUT Request
int processPutTask(EJHttpRequest *request, write_callback callback, void *stream, int32_t *responseCode) {
CURLRaii curl;
bool ok = curl.init(request, callback, stream)
&& curl.setOption(CURLOPT_CUSTOMREQUEST, "PUT")
&& curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData())
&& curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize())
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例5: processDeleteTask
//Process DELETE Request
static int processDeleteTask(HttpClient* client, HttpRequest* request, write_callback callback, void* stream, long* responseCode, write_callback headerCallback, void* headerStream, char* errorBuffer)
{
CURLRaii curl;
bool ok = curl.init(client, request, callback, stream, headerCallback, headerStream, errorBuffer)
&& curl.setOption(CURLOPT_CUSTOMREQUEST, "DELETE")
&& curl.setOption(CURLOPT_FOLLOWLOCATION, true)
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例6: processPostTask
//Process POST Request
static int processPostTask(CCHttpRequest *request, write_callback callback, void *stream, int32_t *responseCode, write_callback headerCallback, void *headerStream)
{
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream)
&& curl.setOption(CURLOPT_POST, 1)
&& curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData())
&& curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize())
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例7: processPutTask
//Process PUT Request
static int processPutTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer)
{
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream, errorBuffer)
&& curl.setOption(CURLOPT_CUSTOMREQUEST, "PUT")
&& curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData())
&& curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize())
&& curl.perform(responseCode);
return ok ? 0 : 1;
}
示例8: processPostFileDataTask
static int processPostFileDataTask(App42HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream)
{
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
std::string fileName = request->fileName();
std::string requestName = request->requestName();
std::map<std::string,std::string> postParams = request->postParams();
printf("\nrequestName=%s\n",requestName.c_str());
printf("\nfileName=%s\n",fileName.c_str());
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, requestName.c_str(),
CURLFORM_BUFFER, fileName.c_str(),
CURLFORM_BUFFERPTR, request->getFileData(),
CURLFORM_BUFFERLENGTH, (long)request->getFileDataSize(),
CURLFORM_CONTENTTYPE,"multipart/form-data",
CURLFORM_END);
/* Fill in the filename field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, fileName.c_str(),
CURLFORM_END);
std::map<std::string,std::string>::iterator it;
for(it=postParams.begin(); it!=postParams.end(); ++it)
{
curl_formadd(&formpost,
&lastptr,
CURLFORM_PTRNAME, it->first.c_str(),
CURLFORM_PTRCONTENTS, it->second.c_str(),
CURLFORM_END);
}
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream)
&& curl.setOption(CURLOPT_POST, 1)
&& curl.setOption(CURLOPT_HTTPPOST, formpost)
&& curl.perform(responseCode);
curl_formfree(formpost);
return ok ? 0 : 1;
}
示例9: processPostFileTask
//Process PostFile Request
static int processPostFileTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream, char *errorBuffer)
{
struct curl_httppost *post1;
struct curl_httppost *postend;
post1 = NULL;
postend = NULL;
curl_formadd(&post1, &postend,
CURLFORM_COPYNAME, "files[]",
CURLFORM_FILE, request->getFilePath().c_str(),
CURLFORM_CONTENTTYPE, "application/octet-stream",
CURLFORM_END);
CURLRaii curl;
bool ok = curl.init(request, callback, stream, headerCallback, headerStream, errorBuffer)
&& curl.setOption(CURLOPT_NOPROGRESS, 1L)
&& curl.setOption(CURLOPT_MAXREDIRS, 50L)
&& curl.setOption(CURLOPT_TCP_KEEPALIVE, 1L)
&& curl.setOption(CURLOPT_HTTPPOST, post1)
&& curl.perform(responseCode);
return ok ? 0 : 1;
}