cURL / Mailing Lists / curl-library / Single Mail


RE: Can't set headers using CURLOPT_HTTPHEADER

From: Patrick Monnerat <>
Date: Mon, 23 Jan 2012 18:21:36 +0100

Yanov, Andrey wrote:
> curl_slist *headers=NULL; // init to NULL is important
> curl_slist_append(headers, "Accept: text/xml");
> curl_slist_append(headers, "Content-Type: text/xml");
> //curl_slist_append(headers, "charsets: utf-8");
> res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

Use "headers = curl_slist_append(headers, ...);" for each
curl_slist_append() call: this function cannot change the 1st parameter
since it is passed by value. However the proper new list head is
returned by the function.

List admin:
Received on 2012-01-23