flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-asjs] [refs/heads/core_js_to_as] - clean compile of Network.swc
Date Fri, 13 Nov 2015 21:03:17 GMT
clean compile of Network.swc


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/05c9b632
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/05c9b632
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/05c9b632

Branch: refs/heads/core_js_to_as
Commit: 05c9b632345427098a4d4c740f3e4d585965f993
Parents: a2aff21
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 13 12:03:51 2015 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Nov 13 13:03:05 2015 -0800

----------------------------------------------------------------------
 .../src/org/apache/flex/net/BinaryUploader.as   | 276 ++++++++++++++-----
 .../as/src/org/apache/flex/net/HTTPService.as   | 266 +++++++++++++-----
 .../src/org/apache/flex/net/HTTPServiceBase.as  |  47 ++++
 frameworks/projects/Network/build.xml           |  96 ++++---
 .../projects/Network/compile-asjs-config.xml    |  82 ++++++
 frameworks/projects/Network/compile-config.xml  |   4 +-
 .../src/org/apache/flex/net/BinaryUploader.js   |   2 +-
 7 files changed, 596 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as b/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as
index 8e4b756..89e4f70 100644
--- a/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as
+++ b/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as
@@ -18,13 +18,20 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.net
 {
-	import flash.events.HTTPStatusEvent;
-	import flash.events.IOErrorEvent;
-	import flash.net.URLLoader;
-	import flash.net.URLRequest;
-	import flash.net.URLRequestHeader;
-	import flash.net.URLRequestMethod;
-	
+    COMPILE::AS3
+    {
+        import flash.events.HTTPStatusEvent;
+        import flash.events.IOErrorEvent;
+        import flash.net.URLLoader;
+        import flash.net.URLRequest;
+        import flash.net.URLRequestHeader;
+        import flash.net.URLRequestMethod;            
+    }
+	COMPILE::JS
+    {
+        import org.apache.flex.core.WrappedHTMLElement;
+    }
+    
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.events.Event;
@@ -92,7 +99,7 @@ package org.apache.flex.net
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */
-	public class BinaryUploader extends EventDispatcher implements IStrand, IBead
+	public class BinaryUploader extends HTTPServiceBase implements IStrand, IBead
 	{
         /**
          *  The GET request method.
@@ -102,7 +109,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_GET:String = URLRequestMethod.GET;
+		public static const HTTP_METHOD_GET:String = "GET";
 
         /**
          *  The POST request method.
@@ -112,7 +119,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_POST:String = URLRequestMethod.POST;
+		public static const HTTP_METHOD_POST:String = "POST";
 
         /**
          *  The PUT request method.
@@ -122,7 +129,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-        public static const HTTP_METHOD_PUT:String = URLRequestMethod.PUT;
+        public static const HTTP_METHOD_PUT:String = "PUT";
 
         /**
          *  The DELETE request method.
@@ -132,7 +139,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-        public static const HTTP_METHOD_DELETE:String = URLRequestMethod.DELETE;
+        public static const HTTP_METHOD_DELETE:String = "DELETE";
 		
         /**
          *  Constructor.
@@ -145,6 +152,10 @@ package org.apache.flex.net
 		public function BinaryUploader()
 		{
 			super();
+            COMPILE::JS
+            {
+                element = new XMLHttpRequest() as WrappedHTMLElement;
+            }
 		}
 		
 		private var _contentType:String = "application/octet-stream";
@@ -275,21 +286,51 @@ package org.apache.flex.net
          */        
 		public function get responseHeaders():Array
 		{
-			if (_responseHeaders && _responseHeaders.length > 0)
-			{
-				if (_responseHeaders[0] is URLRequestHeader)
-				{
-					var n:int = _responseHeaders.length;
-					for (var i:int = 0; i < n; i++)
-					{
-						var old:URLRequestHeader = _responseHeaders[i];
-						var nu:HTTPHeader = new HTTPHeader(old.name, old.value);
-						_responseHeaders[i] = nu;
-					}
-				}
-			}
-			return _responseHeaders;
-		}
+            COMPILE::AS3
+            {
+                if (_responseHeaders && _responseHeaders.length > 0)
+                {
+                    if (_responseHeaders[0] is URLRequestHeader)
+                    {
+                        var n:int = _responseHeaders.length;
+                        for (var i:int = 0; i < n; i++)
+                        {
+                            var old:URLRequestHeader = _responseHeaders[i];
+                            var nu:HTTPHeader = new HTTPHeader(old.name, old.value);
+                            _responseHeaders[i] = nu;
+                        }
+                    }
+                }
+            }
+            COMPILE::JS
+            {
+                var allHeaders:String;
+                var c:int;
+                var hdr:String;
+                var i:int;
+                var n:int;
+                var part1:String;
+                var part2:String;
+                var element:XMLHttpRequest = this.element as XMLHttpRequest;
+                
+                if (typeof _responseHeaders === 'undefined') 
+                {
+                    allHeaders = element.getAllResponseHeaders();
+                    _responseHeaders = allHeaders.split('\n');
+                    n = _responseHeaders.length;
+                    for (i = 0; i < n; i++) 
+                    {
+                        hdr = _responseHeaders[i];
+                        c = hdr.indexOf(':');
+                        part1 = hdr.substring(0, c);
+                        part2 = hdr.substring(c + 2);
+                        _responseHeaders[i] =
+                            new HTTPHeader(part1, part2);
+                    }
+                }
+            }
+            return _responseHeaders;
+   		}
 		
 		private var _responseURL:String;
 
@@ -432,6 +473,7 @@ package org.apache.flex.net
          */        
 		public var beads:Array;
 		
+        COMPILE::AS3
 		private var _beads:Vector.<IBead>;
 
         /**
@@ -441,7 +483,8 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
-         */        
+         */       
+        COMPILE::AS3
 		public function addBead(bead:IBead):void
 		{
 			if (!_beads)
@@ -457,7 +500,8 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
-         */        
+         */     
+        COMPILE::AS3
 		public function getBeadByType(classOrInterface:Class):IBead
 		{
 			for each (var bead:IBead in _beads)
@@ -475,7 +519,8 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
-         */        
+         */  
+        COMPILE::AS3
 		public function removeBead(value:IBead):IBead	
 		{
 			var n:int = _beads.length;
@@ -491,6 +536,7 @@ package org.apache.flex.net
 			return null;
 		}
 
+        COMPILE::AS3
         private var urlLoader:URLLoader;
         
         /**
@@ -504,48 +550,103 @@ package org.apache.flex.net
          */        
         public function send():void
         {
-            if (!urlLoader)
-                urlLoader = new URLLoader();
-			var request:URLRequest = new URLRequest(url);
-			request.method = method;
-			if ("idleTimeout" in request)
-			{
-				request["idleTimeout"] = timeout;
-			}
-			var sawContentType:Boolean;
-			if (headers)
-			{
-				for each (var header:HTTPHeader in headers)
-				{
-					var urlHeader:URLRequestHeader = new URLRequestHeader(header.name, header.value);
-					request.requestHeaders.push(urlHeader);
-					if (header.name == HTTPHeader.CONTENT_TYPE)
-						sawContentType = true;
-				}
-			}
-			if (method != HTTP_METHOD_GET && !sawContentType)
-			{
-				urlHeader = new URLRequestHeader(HTTPHeader.CONTENT_TYPE, contentType);
-				request.requestHeaders.push(urlHeader);
-			}
-			if (binaryData)
-			{
-				if (method == HTTP_METHOD_GET)
-				{
-					if (url.indexOf("?") != -1)
-						url += binaryData.data.toString();
-					else
-						url += "?" + binaryData.data.toString();
-				}
-				else
-					request.data = binaryData.data;
-			}
-			urlLoader.addEventListener(flash.events.Event.COMPLETE, completeHandler);
-			urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
-			if (HTTPStatusEvent.HTTP_RESPONSE_STATUS) // only on AIR
-				urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusHandler);
-			urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler);
-            urlLoader.load(request);
+            COMPILE::AS3
+            {
+                if (!urlLoader)
+                    urlLoader = new URLLoader();
+                var request:URLRequest = new URLRequest(url);
+                request.method = method;
+                if ("idleTimeout" in request)
+                {
+                    request["idleTimeout"] = timeout;
+                }
+                var sawContentType:Boolean;
+                if (headers)
+                {
+                    for each (var header:HTTPHeader in headers)
+                    {
+                        var urlHeader:URLRequestHeader = new URLRequestHeader(header.name,
header.value);
+                        request.requestHeaders.push(urlHeader);
+                        if (header.name == HTTPHeader.CONTENT_TYPE)
+                            sawContentType = true;
+                    }
+                }
+                if (method != HTTP_METHOD_GET && !sawContentType)
+                {
+                    urlHeader = new URLRequestHeader(HTTPHeader.CONTENT_TYPE, contentType);
+                    request.requestHeaders.push(urlHeader);
+                }
+                if (binaryData)
+                {
+                    if (method == HTTP_METHOD_GET)
+                    {
+                        if (url.indexOf("?") != -1)
+                            url += binaryData.data.toString();
+                        else
+                            url += "?" + binaryData.data.toString();
+                    }
+                    else
+                        request.data = binaryData.data;
+                }
+                urlLoader.addEventListener(flash.events.Event.COMPLETE, completeHandler);
+                urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
+                if (HTTPStatusEvent.HTTP_RESPONSE_STATUS) // only on AIR
+                    urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusHandler);
+                urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler);
+                urlLoader.load(request);
+                
+            }
+            COMPILE::JS
+            {
+                var element:XMLHttpRequest = this.element as XMLHttpRequest;
+                element.onreadystatechange = progressHandler;
+                
+                url = _url;
+                
+                var binaryData:String = null;
+                if (_binaryData != null) {
+                    if (_method === HTTP_METHOD_GET) {
+                        if (url.indexOf('?') !== -1) {
+                            url += _binaryData.data;
+                        } else {
+                            url += '?' + _binaryData.data;
+                        }
+                    } else {
+                        binaryData = _binaryData.data.toString();
+                    }
+                }
+                
+                element.open(_method, _url, true);
+                element.timeout = _timeout;
+                
+                var sawContentType:Boolean = false;
+                if (_headers) {
+                    var n:int = _headers.length;
+                    for (var i:int = 0; i < n; i++) {
+                        var header:HTTPHeader = _headers[i];
+                        if (header.name === HTTPHeader.CONTENT_TYPE) {
+                            sawContentType = true;
+                        }
+                        
+                        element.setRequestHeader(header.name, header.value);
+                    }
+                }
+                
+                if (_method !== HTTP_METHOD_GET &&
+                    !sawContentType && binaryData) {
+                    element.setRequestHeader(
+                        HTTPHeader.CONTENT_TYPE, _contentType);
+                }
+                
+                if (binaryData) {
+                    element.setRequestHeader('Content-length', binaryData.length.toString());
+                    element.setRequestHeader('Connection', 'close');
+                    element.send(binaryData);
+                } else {
+                    element.send();
+                }
+
+            }
         }
         
         /**
@@ -556,6 +657,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */        
+        COMPILE::AS3
 		protected function statusHandler(event:HTTPStatusEvent):void
 		{
 			_status = event.status;
@@ -573,7 +675,8 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
-         */        
+         */  
+        COMPILE::AS3
 		protected function ioErrorHandler(event:IOErrorEvent):void
 		{
 			dispatchEvent(new Event(event.type));
@@ -587,12 +690,29 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */        
+        COMPILE::AS3
         protected function completeHandler(event:flash.events.Event):void
         {
             dispatchEvent(new Event(event.type));
         }
         
         /**
+         * @flexjsignorecoercion XMLHttpRequest
+         */
+        COMPILE::JS
+        protected function progressHandler():void
+        {
+            var element:XMLHttpRequest = this.element as XMLHttpRequest;
+            if (element.readyState === 2) {
+                _status = element.status;
+                dispatchEvent('httpResponseStatus');
+                dispatchEvent('httpStatus');
+            } else if (element.readyState === 4) {
+                dispatchEvent('complete');
+            }
+        }
+        
+        /**
          *  Sometimes, after the upload, the server returns useful
          *  information which will be available after the COMPLETE event.
          *  
@@ -600,10 +720,18 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion XMLHttpRequest
          */        
         public function get data():*
         {
-            return urlLoader.data;
+            COMPILE::AS3
+            {
+                return urlLoader.data;                    
+            }
+            COMPILE::JS
+            {
+                return (element as XMLHttpRequest).responseText;
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as b/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as
index b0d4f2f..0597d80 100644
--- a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as
+++ b/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as
@@ -18,12 +18,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.net
 {
-	import flash.events.HTTPStatusEvent;
-	import flash.events.IOErrorEvent;
-	import flash.net.URLLoader;
-	import flash.net.URLRequest;
-	import flash.net.URLRequestHeader;
-	import flash.net.URLRequestMethod;
+    COMPILE::AS3
+    {
+        import flash.events.HTTPStatusEvent;
+        import flash.events.IOErrorEvent;
+        import flash.net.URLLoader;
+        import flash.net.URLRequest;
+        import flash.net.URLRequestHeader;
+        import flash.net.URLRequestMethod;        
+    }
+    COMPILE::JS
+    {
+        import org.apache.flex.core.WrappedHTMLElement;
+    }
 	
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IStrand;
@@ -93,7 +100,7 @@ package org.apache.flex.net
      *  @playerversion AIR 2.6
      *  @productversion FlexJS 0.0
      */
-	public class HTTPService extends EventDispatcher implements IStrand, IBead
+	public class HTTPService extends HTTPServiceBase implements IStrand, IBead
 	{
         /**
          *  @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_GET
@@ -103,7 +110,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_GET:String = URLRequestMethod.GET;
+		public static const HTTP_METHOD_GET:String = "GET";
         
         /**
          *  @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_POST
@@ -113,7 +120,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_POST:String = URLRequestMethod.POST;
+		public static const HTTP_METHOD_POST:String = "POST";
         
         /**
          *  @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_PUT
@@ -123,7 +130,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_PUT:String = URLRequestMethod.PUT;
+		public static const HTTP_METHOD_PUT:String = "PUT";
 
         /**
          *  @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_DELETE
@@ -133,7 +140,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
-		public static const HTTP_METHOD_DELETE:String = URLRequestMethod.DELETE;
+		public static const HTTP_METHOD_DELETE:String = "DELETE";
 		
         /**
          *  Dispatched when the request is complete.
@@ -188,10 +195,16 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement;
          */
 		public function HTTPService()
 		{
 			super();
+            
+            COMPILE::JS
+            {
+                element = new XMLHttpRequest() as WrappedHTMLElement;
+            }
 		}
 		
 		private var _contentType:String = "application/x-www-form-urlencoded";
@@ -313,22 +326,52 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion XMLHttpRequest
          */
 		public function get responseHeaders():Array
 		{
-			if (_responseHeaders && _responseHeaders.length > 0)
-			{
-				if (_responseHeaders[0] is URLRequestHeader)
-				{
-					var n:int = _responseHeaders.length;
-					for (var i:int = 0; i < n; i++)
-					{
-						var old:URLRequestHeader = _responseHeaders[i];
-						var nu:HTTPHeader = new HTTPHeader(old.name, old.value);
-						_responseHeaders[i] = nu;
-					}
-				}
-			}
+            COMPILE::AS3
+            {
+                if (_responseHeaders && _responseHeaders.length > 0)
+                {
+                    if (_responseHeaders[0] is URLRequestHeader)
+                    {
+                        var n:int = _responseHeaders.length;
+                        for (var i:int = 0; i < n; i++)
+                        {
+                            var old:URLRequestHeader = _responseHeaders[i];
+                            var nu:HTTPHeader = new HTTPHeader(old.name, old.value);
+                            _responseHeaders[i] = nu;
+                        }
+                    }
+                }                    
+            }
+            COMPILE::JS
+            {
+                var allHeaders:String;
+                var c:int;
+                var hdr:String;
+                var i:int;
+                var n:int;
+                var part1:String;
+                var part2:String;
+                var element:XMLHttpRequest = this.element as XMLHttpRequest;
+                
+                if (typeof _responseHeaders === 'undefined') {
+                    allHeaders = element.getAllResponseHeaders();
+                    _responseHeaders = allHeaders.split('\n');
+                    n = _responseHeaders.length;
+                    for (i = 0; i < n; i++) {
+                        hdr = _responseHeaders[i];
+                        c = hdr.indexOf(':');
+                        part1 = hdr.substring(0, c);
+                        part2 = hdr.substring(c + 2);
+                        _responseHeaders[i] =
+                            new HTTPHeader(part1, part2);
+                    }
+                }
+
+            }
 			return _responseHeaders;
 		}
 		
@@ -475,6 +518,7 @@ package org.apache.flex.net
          */
 		public var beads:Array;
 		
+        COMPILE::AS3
 		private var _beads:Vector.<IBead>;
         
         /**
@@ -485,6 +529,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
 		public function addBead(bead:IBead):void
 		{
 			if (!_beads)
@@ -501,6 +546,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
 		public function getBeadByType(classOrInterface:Class):IBead
 		{
 			for each (var bead:IBead in _beads)
@@ -519,6 +565,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
 		public function removeBead(value:IBead):IBead	
 		{
 			var n:int = _beads.length;
@@ -534,6 +581,7 @@ package org.apache.flex.net
 			return null;
 		}
 
+        COMPILE::AS3
         private var urlLoader:URLLoader;
         
         /**
@@ -543,57 +591,112 @@ package org.apache.flex.net
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion XMLHttpRequest
          */
         public function send():void
         {
             if (_beads == null)
             {
                 for each (var bead:IBead in beads)
-                addBead(bead);
+                    addBead(bead);
             }
             
-            if (!urlLoader)
-                urlLoader = new URLLoader();
-			var request:URLRequest = new URLRequest(url);
-			request.method = method;
-			if ("idleTimeout" in request)
-			{
-				request["idleTimeout"] = timeout;
-			}
-			var sawContentType:Boolean;
-			if (headers)
-			{
-				for each (var header:HTTPHeader in headers)
-				{
-					var urlHeader:URLRequestHeader = new URLRequestHeader(header.name, header.value);
-					request.requestHeaders.push(urlHeader);
-					if (header.name == HTTPHeader.CONTENT_TYPE)
-						sawContentType = true;
-				}
-			}
-			if (method != HTTP_METHOD_GET && !sawContentType && contentData != null)
-			{
-				urlHeader = new URLRequestHeader(HTTPHeader.CONTENT_TYPE, contentType);
-				request.requestHeaders.push(urlHeader);
-			}
-			if (contentData)
-			{
-				if (method == HTTP_METHOD_GET)
-				{
-					if (url.indexOf("?") != -1)
-						url += contentData;
-					else
-						url += "?" + contentData;
-				}
-				else
-					request.data = contentData;
-			}
-			urlLoader.addEventListener(flash.events.Event.COMPLETE, completeHandler);
-			urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
-			if (HTTPStatusEvent.HTTP_RESPONSE_STATUS) // only on AIR
-				urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusHandler);
-			urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler);
-            urlLoader.load(request);
+            COMPILE::AS3
+            {
+                if (!urlLoader)
+                    urlLoader = new URLLoader();
+                var request:URLRequest = new URLRequest(url);
+                request.method = method;
+                if ("idleTimeout" in request)
+                {
+                    request["idleTimeout"] = timeout;
+                }
+                var sawContentType:Boolean;
+                if (headers)
+                {
+                    for each (var header:HTTPHeader in headers)
+                    {
+                        var urlHeader:URLRequestHeader = new URLRequestHeader(header.name,
header.value);
+                        request.requestHeaders.push(urlHeader);
+                        if (header.name == HTTPHeader.CONTENT_TYPE)
+                            sawContentType = true;
+                    }
+                }
+                if (method != HTTP_METHOD_GET && !sawContentType && contentData
!= null)
+                {
+                    urlHeader = new URLRequestHeader(HTTPHeader.CONTENT_TYPE, contentType);
+                    request.requestHeaders.push(urlHeader);
+                }
+                if (contentData)
+                {
+                    if (method == HTTP_METHOD_GET)
+                    {
+                        if (url.indexOf("?") != -1)
+                            url += contentData;
+                        else
+                            url += "?" + contentData;
+                    }
+                    else
+                        request.data = contentData;
+                }
+                urlLoader.addEventListener(flash.events.Event.COMPLETE, completeHandler);
+                urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
+                if (HTTPStatusEvent.HTTP_RESPONSE_STATUS) // only on AIR
+                    urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusHandler);
+                urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler);
+                urlLoader.load(request);
+            }
+            COMPILE::JS
+            {
+                var element:XMLHttpRequest = this.element as XMLHttpRequest;
+                element.onreadystatechange = progressHandler;
+                
+                url = _url;
+                
+                var contentData:String = null;
+                if (_contentData != null) {
+                    if (_method === HTTP_METHOD_GET) {
+                        if (url.indexOf('?') !== -1) {
+                            url += _contentData;
+                        } else {
+                            url += '?' + _contentData;
+                        }
+                    } else {
+                        contentData = _contentData;
+                    }
+                }
+                
+                element.open(_method, _url, true);
+                element.timeout = _timeout;
+                
+                var sawContentType:Boolean = false;
+                if (_headers) {
+                    var n:int = _headers.length;
+                    for (var i:int = 0; i < n; i++) {
+                        var header:HTTPHeader = _headers[i];
+                        if (header.name === HTTPHeader.CONTENT_TYPE) {
+                            sawContentType = true;
+                        }
+                        
+                        element.setRequestHeader(header.name, header.value);
+                    }
+                }
+                
+                if (_method !== HTTP_METHOD_GET &&
+                    !sawContentType && contentData) {
+                    element.setRequestHeader(
+                        HTTPHeader.CONTENT_TYPE, _contentType);
+                }
+                
+                if (contentData) {
+                    element.setRequestHeader('Content-length', contentData.length.toString());
+                    element.setRequestHeader('Connection', 'close');
+                    element.send(contentData);
+                } else {
+                    element.send();
+                }
+
+            }
         }
         
         /**
@@ -604,6 +707,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
 		protected function statusHandler(event:HTTPStatusEvent):void
 		{
 			_status = event.status;
@@ -622,6 +726,7 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
 		protected function ioErrorHandler(event:IOErrorEvent):void
 		{
 			dispatchEvent(new Event(event.type));
@@ -635,22 +740,47 @@ package org.apache.flex.net
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
          */
+        COMPILE::AS3
         protected function completeHandler(event:flash.events.Event):void
         {
             dispatchEvent(new Event(event.type));
         }
         
         /**
+         * @flexjsignorecoercion XMLHttpRequest
+         */
+        COMPILE::JS
+        protected function progressHandler():void
+        {
+            var element:XMLHttpRequest = this.element as XMLHttpRequest;
+            if (element.readyState === 2) {
+                _status = element.status;
+                dispatchEvent('httpResponseStatus');
+                dispatchEvent('httpStatus');
+            } else if (element.readyState === 4) {
+                dispatchEvent('complete');
+            }
+        }
+
+        /**
          *  The text returned from the server.
          *  
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
          *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion XMLHttpRequest
          */
         public function get data():String
         {
-            return urlLoader.data;
+            COMPILE::AS3
+            {
+                return urlLoader.data;                    
+            }
+            COMPILE::JS
+            {
+                return (element as XMLHttpRequest).responseText;
+            }
         }
         
         

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPServiceBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPServiceBase.as b/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPServiceBase.as
new file mode 100644
index 0000000..4cd73df
--- /dev/null
+++ b/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPServiceBase.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.net
+{
+    COMPILE::AS3
+    {
+        import org.apache.flex.events.EventDispatcher;            
+    }
+    COMPILE::JS
+    {
+        import org.apache.flex.core.HTMLElementWrapper;
+    }
+    
+    /**
+     *  The data class for HTTP headers in HTTP server communications.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+    COMPILE::AS3
+	public class HTTPServiceBase extends EventDispatcher
+	{
+    }
+
+    COMPILE::JS
+    public class HTTPServiceBase extends HTMLElementWrapper
+    {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/build.xml b/frameworks/projects/Network/build.xml
index 5f4a532..e76a6ef 100644
--- a/frameworks/projects/Network/build.xml
+++ b/frameworks/projects/Network/build.xml
@@ -34,10 +34,10 @@
         <os family="windows"/>
     </condition>
     
-    <target name="main" depends="clean,compile,test" description="Clean build of Collections.swc">
+    <target name="main" depends="clean,compile,test" description="Clean build of Network.swc">
     </target>
     
-    <target name="all" depends="main,compile-asjs,lint-js,test-js" description="Full build
of Binding.swc">
+    <target name="all" depends="clean,compile-asjs,compile-extern-swc,copy-js,compile"
description="Full build of Network.swc">
     </target>
     
     <target name="test" unless="is.jenkins">
@@ -95,46 +95,78 @@
             <load-config filename="compile-config.xml" />
             <arg value="+playerglobal.version=${playerglobal.version}" />
             <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
+            <arg value="-define=COMPILE::AS3,true" />
+            <arg value="-define=COMPILE::JS,false" />
         </compc>
     </target>
 
-    <target name="compile-asjs" >
-        <!-- nothing to cross-compile yet -->
+    <target name="compile-asjs">
+        <echo message="Cross-compiling Network"/>
+        <echo message="FALCONJX_HOME: ${FALCONJX_HOME}"/>
+        <java jar="${FALCONJX_HOME}/lib/compc.jar" fork="true" >
+            <jvmarg value="-Xmx384m" />
+            <jvmarg value="-Dsun.io.useCanonCaches=false" />
+            <jvmarg value="-Dflexcompiler=${FALCONJX_HOME}/../compiler" />
+            <jvmarg value="-Dflexlib=${FLEXJS_HOME}/frameworks" />
+            <arg value="+flexlib=${FLEX_HOME}/frameworks" />
+            <arg value="-js-output-type=FLEXJS" />
+            <arg value="-keep-asdoc" /><!-- allows compiler to see @flexjsignorecoercion
annotations -->
+            <arg value="-output=${basedir}/js/out" />
+            <arg value="-load-config=${basedir}/compile-asjs-config.xml" />
+            <arg value="+playerglobal.version=${playerglobal.version}" />
+            <arg value="+env.PLAYERGLOBAL_HOME=${env.PLAYERGLOBAL_HOME}" />
+            <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
+            <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc"
/>
+            <!-- this is not on external-library path otherwise goog.requires are not
generated -->
+            <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc"
/>
+            <arg value="-define=COMPILE::AS3,false" />
+            <arg value="-define=COMPILE::JS,true" />
+        </java>
+    </target>
+
+    <target name="compile-extern-swc" description="Compiles .as files into .swc used for
cross-compiling other projects">
+        <echo message="Compiling externs/Network.swc"/>
+        <echo message="FLEX_HOME: ${FLEX_HOME}"/>
+        <echo message="FALCON_HOME: ${FALCON_HOME}"/>
+        <!-- make JS output folder now so include-file doesn't error -->
+        <mkdir dir="${FLEXJS_HOME}/frameworks/externs"/>
+        
+        <!-- Load the <compc> task. We can't do this at the <project> level
-->
+        <!-- because targets that run before flexTasks.jar gets built would fail. -->
+        <taskdef resource="flexTasks.tasks" classpathref="lib.path"/>
+        <!--
+         Link in the classes (and their dependencies) for the MXML tags
+         listed in this project's manifest.xml.
+         Also link the additional classes (and their dependencies)
+         listed in CoreClasses.as,
+         because these aren't referenced by the manifest classes.
+         Keep the standard metadata when compiling.
+         Include the appropriate CSS files and assets in the SWC.
+         Don't include any resources in the SWC.
+         Write a bundle list of referenced resource bundles
+         into the file bundles.properties in this directory.
+         -->
+        <compc fork="true"
+            output="${FLEXJS_HOME}/frameworks/externs/Core.swc">
+            <jvmarg line="${compc.jvm.args}"/>
+            <load-config filename="compile-asjs-config.xml" />
+            <arg value="+playerglobal.version=${playerglobal.version}" />
+            <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
+            <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc"
/>
+            <!-- this is not on external-library path otherwise goog.requires are not
generated -->
+            <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc"
/>
+            <arg value="-define=COMPILE::AS3,false" />
+            <arg value="-define=COMPILE::JS,true" />
+        </compc>
     </target>
 
-    <target name="lint-js" depends="gjslint, jshint, copy-js" />
+
     <target name="copy-js" >
         <copy todir="${FLEXJS_HOME}/frameworks/js/FlexJS/libs">
-            <fileset dir="${basedir}/js/src">
+            <fileset dir="${basedir}/js/out">
                 <include name="**/**" />
             </fileset>
         </copy>
     </target>
     
-    <target name="gjslint" unless="no.lint">
-        <echo>running gjslint</echo>
-        <exec executable="${gjslint}" dir="${basedir}" failonerror="true">
-            <arg value="--strict" />
-            <arg value="--disable" />
-            <arg value="006,100,214,300" />
-            <!-- 006: wrong indentation -->
-            <!-- 100: cannot have non-primitive value -->
-            <!-- 214: @fileoverview tag missing description -->
-            <!-- 300: missing newline at end of file -->
-            <arg value="--max_line_length" />
-            <arg value="120" />
-            <arg value="-r" />
-            <arg value="${basedir}/js/src" />
-        </exec>
-    </target>
-
-    <target name="jshint" unless="no.lint">
-        <echo>running jshint</echo>
-        <exec executable="${jshint}" dir="${basedir}" failonerror="true">
-            <arg value="--config" />
-            <arg value="${FLEX_HOME}/frameworks/js/jshint.properties" />
-            <arg value="${basedir}/js/src" />
-        </exec>
-    </target>
-
 </project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/compile-asjs-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/compile-asjs-config.xml b/frameworks/projects/Network/compile-asjs-config.xml
new file mode 100644
index 0000000..a61da6f
--- /dev/null
+++ b/frameworks/projects/Network/compile-asjs-config.xml
@@ -0,0 +1,82 @@
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<flex-config>
+
+    <compiler>
+        <accessible>false</accessible>
+        
+        <external-library-path>
+        </external-library-path>
+        
+		<mxml>
+			<children-as-data>true</children-as-data>
+		</mxml>
+		<binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event>
+		<binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind>
+		<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
+        <keep-as3-metadata>
+          <name>Bindable</name>
+          <name>Managed</name>
+          <name>ChangeEvent</name>
+          <name>NonCommittingChangeEvent</name>
+          <name>Transient</name>
+        </keep-as3-metadata>
+	  
+        <locale/>
+        
+        <library-path>
+            <!-- asjscompc won't 'link' these classes in, but will list their requires
+                 if these swcs are on the external-library-path then their requires
+                 will not be listed -->
+            <path-element>../../externs/Core.swc</path-element>
+        </library-path>
+        
+        <namespaces>
+            <namespace>
+                <uri>library://ns.apache.org/flexjs/basic</uri>
+                <manifest>basic-manifest.xml</manifest>
+            </namespace>
+        </namespaces>
+        
+        <source-path>
+            <path-element>as/src</path-element>
+        </source-path>
+        
+        <warn-no-constructor>false</warn-no-constructor>
+    </compiler>
+    
+    <include-file>
+    </include-file>
+
+    <include-sources>
+    </include-sources>
+    
+    <include-classes>
+        <class>NetworkClasses</class>
+    </include-classes>
+    
+    <include-namespaces>
+        <uri>library://ns.apache.org/flexjs/basic</uri>
+    </include-namespaces>
+        
+    <target-player>${playerglobal.version}</target-player>
+	
+
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/compile-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/compile-config.xml b/frameworks/projects/Network/compile-config.xml
index f62a960..ed9e3e8 100644
--- a/frameworks/projects/Network/compile-config.xml
+++ b/frameworks/projects/Network/compile-config.xml
@@ -60,8 +60,8 @@
     </compiler>
     
     <include-file>
-        <name>js/src/*</name>
-        <path>js/src/*</path>
+        <name>js/out/*</name>
+        <path>js/out/*</path>
     </include-file>
 
     <include-classes>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/05c9b632/frameworks/projects/Network/js/src/org/apache/flex/net/BinaryUploader.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/js/src/org/apache/flex/net/BinaryUploader.js b/frameworks/projects/Network/js/src/org/apache/flex/net/BinaryUploader.js
index 48e92c4..cd00950 100644
--- a/frameworks/projects/Network/js/src/org/apache/flex/net/BinaryUploader.js
+++ b/frameworks/projects/Network/js/src/org/apache/flex/net/BinaryUploader.js
@@ -293,7 +293,7 @@ org.apache.flex.net.BinaryUploader.prototype.send = function() {
         url += '?' + this.binaryData_.data;
       }
     } else {
-      binaryData = this.binaryData_.data;
+      binaryData = this.binaryData_.data.toString();
     }
   }
 


Mime
View raw message