Skip to main content
Participant
January 11, 2013
Question

how to locate a redirect url while the request server response a 302 redirect code?

  • January 11, 2013
  • 1 reply
  • 1100 views

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.

This topic has been closed for replies.

1 reply

sinious
Legend
January 11, 2013

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:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#followRedirects