工作上使用到 libcurl 上傳檔案
剛好同事要在 header 加上 cookie 資訊
當然是使用 curl_easy_setopt - set options for a curl easy handle
設定cookie func
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
結果設定cookie ... 但是header並沒有include...天殺的...怎麼可能...
兩台不同device type,卻有不一樣的結果...一台正常,另一台就像老大似的不給設定...
沒關係...路不轉...自己轉.....
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPHEADER, struct curl_slist *headers);
後來就使用設定 header list方式來處理...就成功啦.
感覺是兩間不一樣廠商,提供的lib版本不同造成..沒有仔細去追究..只能猜想.
EXAMPLE
CURL *curl = curl_easy_init();
struct curl_slist *list = NULL;
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
list = curl_slist_append(list, "Shoesize: 10");
list = curl_slist_append(list, "Accept:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_perform(curl);
curl_slist_free_all(list); /* free the list again */
}
0 意見:
張貼留言