So I just came up with a solution. I made a new function that will
handle this for you. A little extra overhead due to the one request up
front, but in my case I rarely do this.
/**
* Return the URL that the given URL redirects to (302). If no
redirect
* exists, passed in $url will be returned.
* @param $url
* @return string the url to call
*/
function getRedirectIfExist($url) {
$headers = get_headers($url,1);
return (!empty($headers[0]) && strstr($headers[0],'302') && !empty
($headers['Location']))?$headers['Location']:$url;
}
On Jan 20, 9:59 am, "[email protected]"
<[email protected]> wrote:
> How do you tell the HttpSocket utility to follow redirects? I'm
> calling a web service from my cake app at a well known URL, and they
> are returning a 302 redirect.
>
> Problem is, the return string of the response does not contain the
> response headers, so I cant find out where I need to make another
> request to (a manual work around).
>
> thx in advance.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en