当前位置: 首页>>代码示例>>C++>>正文


C++ CURLRaii类代码示例

本文整理汇总了C++中CURLRaii的典型用法代码示例。如果您正苦于以下问题:C++ CURLRaii类的具体用法?C++ CURLRaii怎么用?C++ CURLRaii使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CURLRaii类的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;
}
开发者ID:Alamantus,项目名称:Ejecta-X,代码行数:8,代码来源:EJBindingHttpRequest.cpp

示例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;
}
开发者ID:FenneX,项目名称:FenneXTestProject,代码行数:9,代码来源:HttpClient.cpp

示例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;
}
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:10,代码来源:HttpClient.cpp

示例4: 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;
}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:10,代码来源:HttpClient.cpp

示例5: 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;
    }
开发者ID:RajeevRShephertz,项目名称:App42Cocos2dXSampple,代码行数:51,代码来源:App42HttpClient.cpp

示例6: 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;
}
开发者ID:Alamantus,项目名称:Ejecta-X,代码行数:10,代码来源:EJBindingHttpRequest.cpp

示例7: 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;
}
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:11,代码来源:HttpClient.cpp

示例8: 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;
}
开发者ID:FenneX,项目名称:FenneXTestProject,代码行数:11,代码来源:HttpClient.cpp

示例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;
}
开发者ID:FenneX,项目名称:FenneXTestProject,代码行数:22,代码来源:HttpClient.cpp


注:本文中的CURLRaii类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。