curl-library
RE: curl_slist
Date: Thu, 4 Jul 2002 10:53:24 +0200
> Is this the proper way to use a curl_slist to set a
> single header value?
>
> char *s = (char *)malloc(length+1);
> memset(s, 0x0, length+1);
> {
> struct curl_slist *slist = (struct curl_slist
> *)malloc(sizeof(struct curl_slist));
> slist->data = s;
> slist->next = (void *)0x0;
> curl_easy_setopt(curl_handle,
> CURLOPT_HTTPHEADER, slist);
> }
>
> Curl is responsible for freeing it, right?
I'm pretty sure curl won't free that memory.
Why don't you use the curl_slist... functions ?
This is how I do that:
struct curl_slist *m_headerlist;
m_headerlist = NULL;
.
.
.
m_headerlist = curl_slist_append(m_headerlist, "Accept: */*");
m_headerlist = curl_slist_append(m_headerlist, "User-Agent: whatever");
curl_easy_setopt(m_pCurl, CURLOPT_HTTPHEADER, m_headerlist);
.
// some curl_easy_perform(...) here
.
curl_slist_free_all(m_headerlist);
regards,
-- Hanno L. Kranzhoff NeptuneLabs ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Caffeinated soap. No kidding. http://thinkgeek.com/sfReceived on 2002-07-04