异步multi没有使用,easy是最常用的。cookie我试了下面4个宏,基本全了。cookie的细节很多,但不是我的重点,就这么笼统的写一下。
CURLOPT_COOKIE
参考
https://curl.haxx.se/libcurl/c/CURLOPT_COOKIE.html
说明
1、第一种自定义cookie,只需调用一次,多次调用以最后一次为准
2、格式必须是NAME=CONTENTS,例如:"name1=content1; name2=content2;"
3、和curl的cookie引擎无关,感觉挺low的
CURLOPT_COOKIELIST
参考
https://curl.haxx.se/libcurl/c/CURLOPT_COOKIELIST.html
说明
1、也是设置发送的http请求中的cookie功能
2、启动curl的cookie引擎,和CURLOPT_COOKIEFILE、CURLOPT_COOKIEJAR是一组
3、支持两种格式:
#type 1
Set-Cookie: cookie1=val1;
#type 2
#this from https://curl.haxx.se/libcurl/c/CURLOPT_COOKIELIST.html
#define SEP "\t" /* Tab separates the fields */
char *my_cookie =
"example.com" /* Hostname */
SEP "FALSE" /* Include subdomains */
SEP "/" /* Path */
SEP "FALSE" /* Secure */
SEP "0" /* Expiry in epoch time format. 0 == Session */
SEP "foo" /* Name */
SEP "bar"; /* Value */
CURLOPT_COOKIEFILE
参考
https://curl.haxx.se/libcurl/c/CURLOPT_COOKIEFILE.html
说明
1、从文件中读取cookie,内容按标准的网景格式就行
#like this:
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
example.com FALSE / FALSE 0 foao baar
example.com FALSE / FALSE 0 foo bar
2、还有“”和“-”这2种默认值,官网上有说明
CURLOPT_COOKIEJAR
参考
https://curl.haxx.se/libcurl/c/CURLOPT_COOKIEJAR.html
说明
1、将服务器发来的cookie保存成文件,上面那个就是调这个宏保存下来的