【发布时间】:2015-02-16 06:25:41
【问题描述】:
我目前正在开发一个关于 CURL 的程序。我编写了以下代码来添加自定义标题:-
struct curl_slist *chunk = NULL;
chunk = curl_slist_append(chunk, "Another: yes");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
上面的代码没问题,但是如果我把代码改成下面的,我发现发送的header中没有Another: yes:
void add_header(CURL *c, struct curl_slist *h){
h = curl_slist_append(h, "Another: yes");
}
struct curl_slist *chunk = NULL;
add_header(curl, chunk);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
我的第二段代码有什么问题?
【问题讨论】: