curl 笔记, 记录一下,有空再整理一下

1. curL 下载Https 网页的内容 编译的libcurl 需支持ssl

    curl_easy_setopt(handle,CURLOPT_CAINFO,"ca.crt");
    curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER,  1L);
    curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST,  1L);

2. curl 的 easy_init 等函数是thread_safe,只需要保证在每个线程里面初始化curl的库函数即可。
    
    test_curl(){
        curl_easy_init();
        .....
        curl_easy_cleanup();
    }

    boost::thread n1(test_curl);
    boost::thread n2(test_curl);
    boost::thread n3(test_curl);
    boost::thread n4(test_curl);
    boost::thread n5(test_curl);
    ......
    n1.join();
    n2.join();
    .........

--> OK  


3. using of  curl lib
    curl = curl_easy_init
    curl_easy_cleanup(curl);
    curl_easy_reset() -->   reset curl handle to initialize status

4. curl_easy_getinfo
    can get the  content-length of Upload/Download
                current size of Upload/Download

5. curl_easy_duphandle
    it dump a new handler with the same options as the previous one, u also can use it independently, but two handler use the only one options memory.
    u 'd better not use the function if u not enough reason.

6.  curl_slist_append
    struct curl_slist * curl_slist_append(struct curl_slist * list, const char * string)
    save the string into the slist;
    same function as parameters of readv(), sendv()
    
see also:
    curl_slist_free_all(struct curl_slist * list);

7. curl API 分类及关系
    1) curl_easy 系列
    2) curl_multi系列
    3) curl_shared系列
    4) Portable helpFunction
    1) curl_easy 系列 如上
    2) curl_multi
        使用select类似的函数,支持同时处理多个网络通信状态,每一个handle是一个curl_easyhandle
    3) curl_shared ????
        to use the shared data in multi-thread environment

    4)Help Function
        4.1) curl_slist        string list
        4.2) curl_mprintf    printf
        4.3) curl_form   Gen the FormData
        4.4) curl_escape URL Encoding&Decoding
        4.5) curl_getdate
        4.6) curl_getenv


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值