Updated ApacheURLLoader component to properly announce events.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/df3dcd66 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/df3dcd66 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/df3dcd66 Branch: refs/heads/develop Commit: df3dcd66e076c62d710fd97e994c1f03d7ed398d Parents: 281223a Author: quetwo <[email protected]> Authored: Sun May 31 17:21:12 2015 -0400 Committer: quetwo <[email protected]> Committed: Sun May 31 17:21:12 2015 -0400 ---------------------------------------------------------------------- .../flex/packageflexsdk/util/ApacheURLLoader.as | 64 ++++++-------------- 1 file changed, 20 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/df3dcd66/installer/src/org/apache/flex/packageflexsdk/util/ApacheURLLoader.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/util/ApacheURLLoader.as b/installer/src/org/apache/flex/packageflexsdk/util/ApacheURLLoader.as index 3893821..07a85c4 100644 --- a/installer/src/org/apache/flex/packageflexsdk/util/ApacheURLLoader.as +++ b/installer/src/org/apache/flex/packageflexsdk/util/ApacheURLLoader.as @@ -30,6 +30,7 @@ package org.apache.flex.packageflexsdk.util import flash.events.ErrorEvent; import flash.events.Event; + import flash.events.HTTPStatusEvent; import flash.events.IOErrorEvent; import flash.events.SecurityErrorEvent; import flash.net.URLLoader; @@ -37,9 +38,7 @@ package org.apache.flex.packageflexsdk.util import flash.utils.ByteArray; import org.httpclient.HttpClient; - import org.httpclient.events.HttpDataEvent; import org.httpclient.events.HttpDataListener; - import org.httpclient.events.HttpErrorEvent; import org.httpclient.events.HttpRequestEvent; import org.httpclient.events.HttpResponseEvent; import org.httpclient.events.HttpStatusEvent; @@ -62,48 +61,45 @@ package org.apache.flex.packageflexsdk.util } else { - trace(request.url); var httpsClient:HttpClient = new HttpClient(); var httpsClientListener:HttpDataListener = new HttpDataListener(); httpsClientListener.onConnect = function(event:HttpRequestEvent):void { - trace("connect"); + var e:Event = new Event(Event.OPEN); + dispatchEvent(e); }; httpsClientListener.onComplete = function(event:HttpResponseEvent):void { - trace("complete."); + var e:HTTPStatusEvent = new HTTPStatusEvent(HTTPStatusEvent.HTTP_RESPONSE_STATUS); + // we are unable to emulate the full event since the built-in event handlers for status and + // many others are marked as private on the set functions. + dispatchEvent(e); }; - httpsClientListener.onClose = function(event:Event):void + httpsClientListener.onDataComplete = function(event:HttpResponseEvent, incomingData:ByteArray):void { - trace("close."); - }; - - httpsClientListener.onDataComplete = function(event:HttpResponseEvent, data:ByteArray):void - { - trace("onDataComplete"); + data = new ByteArray(); + data.writeBytes(incomingData); + data.position=0; + var e:Event = new Event(Event.COMPLETE); + dispatchEvent(e); }; httpsClientListener.onStatus = function(event:HttpStatusEvent):void { - trace("onStatus"); + var e:HTTPStatusEvent = new HTTPStatusEvent(HTTPStatusEvent.HTTP_STATUS); + // we are unable to emulate the full event since the built-in event handlers for status and + // many others are marked as private on the set functions. + dispatchEvent(e); }; httpsClientListener.onError = function(event:ErrorEvent):void { - trace("http error"); - }; - - httpsClientListener.onData = function(event:HttpDataEvent):void - { - trace("data event."); - }; - - httpsClientListener.onRequest = function(event:HttpRequestEvent):void - { - trace("request event"); + var e:IOErrorEvent = new IOErrorEvent(IOErrorEvent.NETWORK_ERROR); + e.text = event.text; + dispatchEvent(e); }; // ProgressEvent is not available in this manner. @@ -116,11 +112,6 @@ package org.apache.flex.packageflexsdk.util } - private function httpsDataArrived(event:HttpDataEvent):void - { - this.httpsData.writeBytes(event.bytes); - } - private function httpsSecurityError(event:SecurityErrorEvent):void { dispatchEvent(event.clone()); @@ -131,21 +122,6 @@ package org.apache.flex.packageflexsdk.util dispatchEvent(event.clone()); } - private function httpsCompleteEvent(event:HttpResponseEvent):void - { - this.data = new ByteArray(); - this.data.writeBytes(this.httpsData); - this.data.position=0; - var e:Event = new Event(Event.COMPLETE); - dispatchEvent(e); - } - - private function httpsErrorEvent(event:HttpErrorEvent):void - { - var e:IOErrorEvent = new IOErrorEvent(IOErrorEvent.NETWORK_ERROR); - e.text = event.text; - dispatchEvent(e); - } } }
