Discussion:
Getting CURLOPT_HTTPHEADER back to normal?
Casey ODonnell
2004-06-22 17:15:39 UTC
Permalink
I'm setting a custom header:

struct curl_slist *pHeaders = NULL;

pHeaders = curl_slist_append(pHeaders, "Depth: 1");

... // Other setopts

curl_easy_setopt(m_pCURL, CURLOPT_HTTPHEADER, pHeaders);

... // Other setopts

res = curl_easy_perform(m_pCURL);

curl_slist_free_all(pHeaders);

This is all well and good. However, if I want to re-use this same
CURL* handle, I've obviously messed up, because my header has been
de-allocated (not the whole header, just the depth one, and I'm
assuming here too.). However, I don't really want my other calls to
use this header at all. How do I tell LibCURL to just get rid of that
header, and go back to its standard headers?

Thanks for the help.

Casey
Daniel Stenberg
2004-06-22 17:19:54 UTC
Permalink
How do I tell LibCURL to just get rid of that header, and go back to its
standard headers?
Set it to NULL:

curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);
--
Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
Dedicated custom curl help for hire: http://haxx.se/curl.html
Casey ODonnell
2004-06-23 20:03:24 UTC
Permalink
Awesome...

Thank you. I have another question though. Similar in nature. I'm
using MS Windows with the DLL (latest version of LibCURL).

I'm performing one call that uses:

curl_easy_setopt(m_pCURL, CURLOPT_READFUNCTION, wxcurldav_str_read);
curl_easy_setopt(m_pCURL, CURLOPT_READDATA, (void*)&szXmlStr);

Which works fine. My app is uploading some XML to go along with the
request. However, when I perform another call that doesn't need to
send any data, how do I tell the library to ignore the read function
now? The code I've got for the other operations work fine, as long as
I don't re-use my CURL* handle.

I've tried:

curl_easy_setopt(m_pCURL, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(m_pCURL, CURLOPT_READDATA, NULL);

But that causes a crash in NTDLL.DLL inside of fread, so I suspect
that I'm doing something bad. I'm basically trying to restore the
initialized state of my CURL* handle, without loosing the performance
boost I get by keeping it around.

Thanks again. Hope this isn't too newbie-ish.

CKO
Post by Daniel Stenberg
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);
Daniel Stenberg
2004-06-23 20:33:26 UTC
Permalink
However, when I perform another call that doesn't need to send any data, how
do I tell the library to ignore the read function now?
If it doesn't send any data, it won't use the read function.
curl_easy_setopt(m_pCURL, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(m_pCURL, CURLOPT_READDATA, NULL);
But that causes a crash in NTDLL.DLL inside of fread, so I suspect that I'm
doing something bad.
"inside of fread" ? That would indicate that it tried to read something and
when using the default internal read function it reads from the FILE *
you set with CURLOPT_READDATA. In this case a NULL, which I figure fread
doesn't like.
--
Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
Dedicated custom curl help for hire: http://haxx.se/curl.html
Jeff Pohlmeyer
2004-06-24 10:48:30 UTC
Permalink
how do I tell the library to ignore the read function now?
I'm basically trying to restore the initialized state of
my CURL* handle
Maybe try this?
curl_easy_setopt(m_pCURL, CURLOPT_HTTPGET, 1);






__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
Casey ODonnell
2004-06-25 13:56:08 UTC
Permalink
I figured it out. I wasn't setting:

curl_easy_setopt(m_pCURL, CURLOPT_INFILESIZE_LARGE, 0);

So I think it believed that since there was a size there, it ought to
try and read something.

When you set:

curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, "DELETE");

Do you get it back to normal with:

curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, NULL);
or
curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, "");

I assumed the NULL and it seems to be working well.

Cheers.
Casey
Post by Daniel Stenberg
"inside of fread" ? That would indicate that it tried to read
something and when using the default internal read function
it reads from the FILE * you set with
CURLOPT_READDATA. In this case a NULL, which I figure
fread doesn't like.
Daniel Stenberg
2004-06-27 21:15:43 UTC
Permalink
Post by Casey ODonnell
curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, NULL);
or
curl_easy_setopt(m_pCURL, CURLOPT_CUSTOMREQUEST, "");
I assumed the NULL and it seems to be working well.
NULL it is. Adding to docs just now!
--
Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
Dedicated custom curl help for hire: http://haxx.se/curl.html
Loading...