On some server configurations (where the error page is configured on the server but sull returns a HTTP 404 status code to the client) the 'onError' event is not fired. Instead, the content of the Custom Error page is downloaded to a local file.
Example:
//
var EXAMPLE_URL:String = "http://www.iarcmedia.com/invalid/invalid.jpg";
var myHTTP = null;
///
function initApp():Void
{
myHTTP = new mdm.HTTP();
myHTTP.onError = function():Void
{
mdm.Dialogs.prompt("Error occured");
};
//
myHTTP.onBinaryTransferComplete = function(obj:Object):Void
{
mdm.Dialogs.prompt(obj.filename);
};
//
var localPath:String = mdm.Application.path+"local_file.jpg";
myHTTP.getFile(EXAMPLE_URL, "", "", localPath);
}
//
setTimeout(initApp, 500);
|
The correct and expected behavior can be replicated in the following ActionScript 3.0 example:
//
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, function(e:HTTPStatusEvent):void
{
trace("response status: "+e.status);
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function(ioError:IOErrorEvent):void
{/* empty */});
var request:URLRequest = new URLRequest("http://www.iarcmedia.com/invalid/invalid.jpg");
loader.load(request);
|
The above code correctly reports the HTTP error status (and fires IOErrorEvent).