Copy link to clipboard
Copied
hi, guys
I am unable to locate a redirect url while the request server response a 302 redirect code.
var url:String = "http://a.com/"; (response a 302 code and redirect to http://b.vom/)
var req:URLRequest = new URLRequest(url);
var dispatcher:URLLoader = new URLLoader(req);
dispatcher.addEventListener(Event.COMPLETE, handlefunction);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
function handlefunction(event:Event):void
{
trace(req.url);
// the console outputs "http://a.com/"
// it should be "http://b.com/"
// but the event.currentTarget.data is ok . e.g. ok.htm
}
function httpStatusHandler(event:HTTPStatusEvent):void
{
trace("httpStatusHandler: " + event);
//the console outputs: httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=200 responseURL=null]
//responseURL is null
}
there some relative links in the data ,so I must get the redirect url .
I got 404 from http://a.com/ok.htm , but i want http://b.com/ok.htm
thanks.
Copy link to clipboard
Copied
Default value of followRedirects is true. If you want to handle them yourself, set it to false, get the code and make sure to continue the new request with the data provided:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now