cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURLOPT_WRITEFUNCTION - cannot make it working...

From: Paolo Piacentini <paolopiace_at_hotmail.com>
Date: Tue, 7 Jun 2011 15:04:46 -0700

Unlike I initially though, I need to save the header in a file. As I experienced, the line
 
curl_easy_setopt(sessionA, CURLOPT_WRITEHEADER, HeaderFile);
 
corrupts the initialization of the data structure the user gives to CURLOPT_WRITEDATA in order to have the write-back function writing in it.
 
The evidence of that happening is visible by running the "getinmemory.c" program I modified slightly and posted on June 4th here: http://curl.haxx.se/mail/lib-2011-06/0028.html
 
If I run it without that incriminated line, it works fine. If I add that line, it goes in segmentation fault.
 
Is there a specific reason for this behavior? How can I have the header saved on file?
 
Thank You...
 

Date: Sun, 5 Jun 2011 09:58:34 -0700

BS>> curl_easy_setopt(sessionA, CURLOPT_WRITEDATA, NULLFILE);
BS>> curl_easy_setopt(sessionA, CURLOPT_WRITEHEADER, HeaderFile);
BS>> I had better luck without this stuff. Perhaps you don't want to do CURLOPT_WRITEDATA twice.
 
Brad... Your hint was precious. I checked, tested an retested:
 
It's the CURLOPT_WRITEHEADER that corrupts the initialization of the user data_struct. If I comment that line, the getinmemory.c works just fine. NO segmentation fault!
 
The first CURLOPT_WRITEDATA to /dev/null does not make any trouble. And I need it.
 
As second thought, I may not need to store the header and just remove that line.
 
I want to thank all of you guys.
                                               

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-08