cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: help -- how can i get the result when sever returns 302?

From: Michael Wood <esiotrot_at_gmail.com>
Date: Wed, 7 Apr 2010 22:15:21 +0200

Hi

Please don't top post.

On 7 April 2010 15:44, Basil Su <hityourface_at_gmail.com> wrote:
> 2010/4/7 Kamil Dudka <kdudka_at_redhat.com>
>>
>> On Wed April 7 2010 12:12:56 Basil Su wrote:
>> > HI ALL,
>> >    i use libcurl to develop a simple http client. now i can download
>> > normally. but i've got a problem. if the server returns 302, how can i
>> > know? i mean, i only know like this:
[...]
>>
>> I guess you're looking for CURLINFO_RESPONSE_CODE:
>>
>> http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html#CURLINFORESPONSECODE
[...]
> i use libcurl like this:
>
> curl_easy_setopt(_curl, CURLOPT_FOLLOWLOCATION, true);
>
> but it didn't seem to work out.

If you use CURLOPT_FOLLOWLOCATION then curl will automatically
redirect. If you want to see the 302, then you should set
CURLOPT_FOLLOWLOCATION to 0.

If this does not fix it for you then I agree that you should try
setting CURLOPT_VERBOSE so that you can see what's going on.

-- 
Michael Wood <esiotrot_at_gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-07