cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Redirect [2]

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 26 Apr 2008 22:22:28 -0700

On Sun, Apr 27, 2008 at 12:48:10AM +0900, Nakayama Kazuhiko wrote:
> 1/
> From http header, I want to get a string.
> I want to receive this data..
> Location: ........http://redirect address_URL(2).........
>
> 2/
> first, I access a URL(1).
> This address will return a 'Location' address URL(2) for next direct.
>
> 1) Access to URL(1)
> 2) if ( Login success ) { I will receive redirect address URL(2) }
> 3) if ( Login faild ) { I will receive a XML }

If you enable location following, curl will automatically load any redirected
pages. In both cases you will receive the data for the final page loaded,
whether redirected or not. If you are not interested in the contents of
the redirected page, you can disable location following and just look at
the returned HTTP error code. A code in the 3xx range means you were
redirected, and a code in the 2xx range means no redirection.

> I want to do programing like this.
> Here is part of my code.
>
> curl_easy_setopt( easyhandle, CURLOPT_FOLLOWLOCATION,1 );
> curl_easy_setopt( easyhandle, CURLOPT_URL, URL_1 );
> curl_easy_setopt( easyhandle, CURLOPT_PORT, 8000 );
> curl_easy_setopt( easyhandle, CURLOPT_WRITEFUNCTION, xmlfun );
> curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, &xml );
> res = curl_easy_perform( easyhandle );

If you are asking how to do this with libcurl, you should be asking it
on the curl-library mailing list instead.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-04-27