cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: WRITEFUNCTION and redirects

From: Mark Fletcher <markf_at_bloglines.com>
Date: Sun, 03 Aug 2003 14:51:43 -0700

Daniel Stenberg wrote:

>Which libcurl version?
>
>If you're not using 7.10.6, then please get that, try again and let us know if
>you get a different behaviour.
>
>
7.10.6, just upgraded to it from 7.10.5. I can't say for certain that
this was happening in 7.10.5, because I never noticed it then. But it's
definitely happening now.

>If you're using 7.10.6, then can you please provide an example URL and source
>code for this please?
>
>
Here are a few urls:

http://cyberlaw.stanford.edu/lessig/blog/index.rdf
http://dsandler.org/dsandler.rss
http://www.pocketpcthoughts.com/xml

Here's how I initialize the curl handle:

  curl_easy_setopt( data->curl, CURLOPT_URL, site->feedUrlGet() );
  curl_easy_setopt( data->curl, CURLOPT_WRITEDATA, data );
  curl_easy_setopt( data->curl, CURLOPT_WRITEFUNCTION, curlData );
  curl_easy_setopt( data->curl, CURLOPT_HEADERFUNCTION, curlHeader );
  curl_easy_setopt( data->curl, CURLOPT_WRITEHEADER, data );
  curl_easy_setopt( data->curl, CURLOPT_FOLLOWLOCATION, 1 );
  curl_easy_setopt( data->curl, CURLOPT_MAXREDIRS, 5 );
  curl_easy_setopt( data->curl, CURLOPT_FAILONERROR, 1 );
  curl_easy_setopt( data->curl, CURLOPT_DNS_CACHE_TIMEOUT, 0 );
  curl_easy_setopt( data->curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0 );
  curl_easy_setopt( data->curl, CURLOPT_ENCODING, "" );
  curl_easy_setopt( data->curl, CURLOPT_TIMEOUT, 60 );
  curl_easy_setopt( data->curl, CURLOPT_CONNECTTIMEOUT, 60 );
  curl_easy_setopt( data->curl, CURLOPT_USERAGENT, data->useragent.str() );
  curl_easy_setopt( data->curl, CURLOPT_HTTPHEADER, data->headerList );

Seen both through the easy and multi interface.

The way I'm dealing with it now is that I record the HTTP status
received in the header. Then if the WRITEFUNCTION is called when that
status != 200, I skip it. I've seen this happen with the status code
being any number of 3XX.

Thanks,

Mark

--
Mark Fletcher
Bloglines
http://www.bloglines.com
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-03