new folders for Network
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/0511cc57 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/0511cc57 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/0511cc57 Branch: refs/heads/mavenfolders Commit: 0511cc57060738e8dfd25e2f549b6bfc3153abdd Parents: aa0efcd Author: Alex Harui <[email protected]> Authored: Tue Feb 2 21:44:51 2016 -0800 Committer: Alex Harui <[email protected]> Committed: Tue Feb 2 21:44:51 2016 -0800 ---------------------------------------------------------------------- .../projects/Network/as/src/NetworkClasses.as | 33 - .../src/org/apache/flex/net/BinaryUploader.as | 738 ----------------- .../as/src/org/apache/flex/net/HTTPHeader.as | 79 -- .../as/src/org/apache/flex/net/HTTPService.as | 805 ------------------- .../src/org/apache/flex/net/HTTPServiceBase.as | 47 -- frameworks/projects/Network/basic-manifest.xml | 27 - .../projects/Network/compile-asjs-config.xml | 82 -- frameworks/projects/Network/compile-config.xml | 78 -- .../Network/src/main/flex/NetworkClasses.as | 33 + .../flex/org/apache/flex/net/BinaryUploader.as | 738 +++++++++++++++++ .../main/flex/org/apache/flex/net/HTTPHeader.as | 79 ++ .../flex/org/apache/flex/net/HTTPService.as | 805 +++++++++++++++++++ .../flex/org/apache/flex/net/HTTPServiceBase.as | 47 ++ .../src/main/resources/basic-manifest.xml | 27 + .../src/main/resources/compile-asjs-config.xml | 82 ++ .../src/main/resources/compile-config.xml | 78 ++ 16 files changed, 1889 insertions(+), 1889 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/frameworks/projects/Network/as/src/NetworkClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/as/src/NetworkClasses.as b/frameworks/projects/Network/as/src/NetworkClasses.as deleted file mode 100644 index cf88050..0000000 --- a/frameworks/projects/Network/as/src/NetworkClasses.as +++ /dev/null @@ -1,33 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -{ - -/** - * @private - * This class is used to link additional classes into rpc.swc - * beyond those that are found by dependecy analysis starting - * from the classes specified in manifest.xml. - */ -internal class NetworkClasses -{ -} - -} - http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/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 deleted file mode 100644 index 3f9f697..0000000 --- a/frameworks/projects/Network/as/src/org/apache/flex/net/BinaryUploader.as +++ /dev/null @@ -1,738 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 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; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.utils.BinaryData; - - //-------------------------------------- - // Events - //-------------------------------------- - - /** - * Dispatched when the upload is complete. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="complete", type="org.apache.flex.events.Event")] - - /** - * Dispatched if an error occurs in the upload. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="ioError", type="org.apache.flex.events.Event")] - - /** - * Dispatched when an httpStatus code is received from the server. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="httpStatus", type="org.apache.flex.events.Event")] - - /** - * Dispatched if Adobe AIR is able to detect and return the status - * code for the request. Unlike the httpStatus event, the httpResponseStatus - * event is delivered before any response data. Also, the httpResponseStatus - * event includes values for the responseHeaders and responseURL properties - * (which are undefined for an httpStatus event. Note that the - * httpResponseStatus event (if any) will be sent before - * (and in addition to) any complete or error event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="httpResponseStatus", type="org.apache.flex.events.Event")] - - [DefaultProperty("beads")] - - /** - * The BinaryUploader class is a class designed to upload binary data - * over HTTP. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class BinaryUploader extends HTTPServiceBase implements IStrand, IBead - { - /** - * The GET request method. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_GET:String = "GET"; - - /** - * The POST request method. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_POST:String = "POST"; - - /** - * The PUT request method. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_PUT:String = "PUT"; - - /** - * The DELETE request method. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_DELETE:String = "DELETE"; - - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - */ - public function BinaryUploader() - { - super(); - COMPILE::JS - { - element = new XMLHttpRequest() as WrappedHTMLElement; - } - } - - private var _contentType:String = "application/octet-stream"; - - /** - * The content-type of the binary data. - * @default application/octet-stream - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get contentType():String - { - return _contentType; - } - - /** - * @private - */ - public function set contentType(value:String):void - { - if (_contentType != value) - { - _contentType = value; - dispatchEvent(new Event("contentTypeChanged")); - } - } - - private var _binaryData:BinaryData; - - /** - * The data to be uploaded. Note the type of this - * property is org.apache.flex.utils.BinaryData. - * This class abstracts the way binary data is handled - * in the browser. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get binaryData():BinaryData - { - return _binaryData; - } - - /** - * @private - */ - public function set binaryData(value:BinaryData):void - { - if (_binaryData != value) - { - _binaryData = value; - dispatchEvent(new Event("binaryDataChanged")); - } - } - - private var _headers:Array; - - /** - * The HTTP headers to be sent with the upload. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get headers():Array - { - if (_headers == null) - _headers = []; - return _headers; - } - - /** - * @private - */ - public function set headers(value:Array):void - { - if (_headers != value) - { - _headers = value; - dispatchEvent(new Event("headersChanged")); - } - } - - private var _method:String = HTTP_METHOD_POST; - - /** - * The HTTP method for the upload. - * @default POST - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get method():String - { - return _method; - } - - /** - * @private - */ - public function set method(value:String):void - { - if (_method != value) - { - _method = value; - dispatchEvent(new Event("methodChanged")); - } - } - - private var _responseHeaders:Array; - - /** - * The HTTP headers that were received from the server - * if any. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get responseHeaders():Array - { - 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; - - /** - * The value of the responseURL header, if any. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get responseURL():String - { - return _responseURL; - } - - private var _status:int; - - /** - * The http status code from the server, if any. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get status():int - { - return _status; - } - - private var _url:String; - - /** - * The url of the server. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get url():String - { - return _url; - } - - /** - * @private - */ - public function set url(value:String):void - { - if (_url != value) - { - _url = value; - dispatchEvent(new Event("urlChanged")); - } - } - - private var _timeout:Number = 0; - - /** - * A timeout value for server response. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get timeout():Number - { - return _timeout; - } - - /** - * @private - */ - public function set timeout(value:Number):void - { - if (_timeout != value) - { - _timeout = value; - dispatchEvent(new Event("timeoutChanged")); - } - } - - private var _id:String; - - /** - * @copy org.apache.flex.core.UIBase#id - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get id():String - { - return _id; - } - - /** - * @private - */ - public function set id(value:String):void - { - if (_id != value) - { - _id = value; - dispatchEvent(new Event("idChanged")); - } - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.UIBase#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - for each (var bead:IBead in beads) - addBead(bead); - - dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); - } - - /** - * @copy org.apache.flex.core.UIBase#beads - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var beads:Array; - - COMPILE::AS3 - private var _beads:Vector.<IBead>; - - /** - * @copy org.apache.flex.core.UIBase#addBead() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::AS3 - public function addBead(bead:IBead):void - { - if (!_beads) - _beads = new Vector.<IBead>; - _beads.push(bead); - bead.strand = this; - } - - /** - * @copy org.apache.flex.core.UIBase#getBeadByType() - * - * @langversion 3.0 - * @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) - { - if (bead is classOrInterface) - return bead; - } - return null; - } - - /** - * @copy org.apache.flex.core.UIBase#removeBead() - * - * @langversion 3.0 - * @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; - for (var i:int = 0; i < n; i++) - { - var bead:IBead = _beads[i]; - if (bead == value) - { - _beads.splice(i, 1); - return bead; - } - } - return null; - } - - COMPILE::AS3 - private var urlLoader:URLLoader; - - /** - * Starts the upload to the server. Events - * are dispatched as the upload progresses. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function send():void - { - 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(); - } - - } - } - - /** - * The handler for HTTP_STATUS and/or HTTP_RESPONSE_STATUS events - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::AS3 - protected function statusHandler(event:HTTPStatusEvent):void - { - _status = event.status; - if ("responseHeaders" in event) - _responseHeaders = event.responseHeaders; - if ("responseURL" in event) - _responseURL = event.responseURL; - dispatchEvent(new Event(event.type)); - } - - /** - * The handler for the IO_ERROR event. - * - * @langversion 3.0 - * @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)); - } - - /** - * The handler for the COMPLETE event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @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. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - * @flexjsignorecoercion XMLHttpRequest - */ - public function get 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/0511cc57/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPHeader.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPHeader.as b/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPHeader.as deleted file mode 100644 index 45f08b3..0000000 --- a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPHeader.as +++ /dev/null @@ -1,79 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -{ - /** - * 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 - */ - public class HTTPHeader - { - /** - * The Content-type header. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const CONTENT_TYPE:String = "Content-type"; - - /** - * Constructor. - * - * @param name The name of the header. - * @param value The value for that header. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function HTTPHeader(name:String = null, value:String = null) - { - super(); - this.name = name; - this.value = value; - } - - /** - * The name of the header. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var name:String; - - /** - * The value for the header. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var value:String; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/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 deleted file mode 100644 index 274559a..0000000 --- a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPService.as +++ /dev/null @@ -1,805 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 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; - import org.apache.flex.events.EventDispatcher; - - //-------------------------------------- - // Events - //-------------------------------------- - - /** - * Dispatched when the request is complete. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="complete", type="org.apache.flex.events.Event")] - - /** - * Dispatched if an error occurs in the server communication. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="ioError", type="org.apache.flex.events.Event")] - - /** - * Dispatched when an httpStatus code is received from the server. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="httpStatus", type="org.apache.flex.events.Event")] - - /** - * Dispatched if Adobe AIR is able to detect and return the status - * code for the request. Unlike the httpStatus event, the httpResponseStatus - * event is delivered before any response data. Also, the httpResponseStatus - * event includes values for the responseHeaders and responseURL properties - * (which are undefined for an httpStatus event. Note that the - * httpResponseStatus event (if any) will be sent before - * (and in addition to) any complete or error event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="httpResponseStatus", type="org.apache.flex.events.Event")] - - [DefaultProperty("beads")] - - /** - * The HTTPService class is a class designed to transfer text - * over HTTP. Use BinaryUploader for transferring non-text. - * - * @see org.apache.flex.net.BinaryUploader. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class HTTPService extends HTTPServiceBase implements IStrand, IBead - { - /** - * @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_GET - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_GET:String = "GET"; - - /** - * @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_POST - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_POST:String = "POST"; - - /** - * @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_PUT - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_PUT:String = "PUT"; - - /** - * @copy org.apache.flex.net.BinaryUploader#HTTP_METHOD_DELETE - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const HTTP_METHOD_DELETE:String = "DELETE"; - - /** - * Dispatched when the request is complete. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const EVENT_COMPLETE:String = "complete"; - - /** - * Dispatched if an error occurs in the server communication. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const EVENT_IO_ERROR:String = "ioError"; - - /** - * Dispatched when an httpStatus code is received from the server. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const EVENT_HTTP_STATUS:String = "httpStatus"; - - /** - * Dispatched if Adobe AIR is able to detect and return the status - * code for the request. Unlike the httpStatus event, the httpResponseStatus - * event is delivered before any response data. Also, the httpResponseStatus - * event includes values for the responseHeaders and responseURL properties - * (which are undefined for an httpStatus event. Note that the - * httpResponseStatus event (if any) will be sent before - * (and in addition to) any complete or error event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const EVENT_HTTP_RESPONSE_STATUS:String = "httpResponseStatus"; - - /** - * Constructor. - * - * @langversion 3.0 - * @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"; - - /** - * @copy org.apache.flex.net.BinaryUploader#contentType - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get contentType():String - { - return _contentType; - } - - /** - * @private - */ - public function set contentType(value:String):void - { - if (_contentType != value) - { - _contentType = value; - dispatchEvent(new Event("contentTypeChanged")); - } - } - - private var _contentData:String; - - /** - * The text to send to the server, if any. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get contentData():String - { - return _contentData; - } - - /** - * @private - */ - public function set contentData(value:String):void - { - if (_contentData != value) - { - _contentData = value; - dispatchEvent(new Event("contentDataChanged")); - } - } - - private var _headers:Array; - - /** - * @copy org.apache.flex.net.BinaryUploader#headers - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get headers():Array - { - if (_headers == null) - _headers = []; - return _headers; - } - - /** - * @private - */ - public function set headers(value:Array):void - { - if (_headers != value) - { - _headers = value; - dispatchEvent(new Event("headersChanged")); - } - } - - private var _method:String = HTTP_METHOD_GET; - - /** - * @copy org.apache.flex.net.BinaryUploader#method - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get method():String - { - return _method; - } - - /** - * @private - */ - public function set method(value:String):void - { - if (_method != value) - { - _method = value; - dispatchEvent(new Event("methodChanged")); - } - } - - private var _responseHeaders:Array; - - /** - * @copy org.apache.flex.net.BinaryUploader#responseHeaders - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - * @flexjsignorecoercion XMLHttpRequest - */ - public function get responseHeaders():Array - { - 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; - - /** - * @copy org.apache.flex.net.BinaryUploader#responseURL - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get responseURL():String - { - return _responseURL; - } - - private var _status:int; - - /** - * @copy org.apache.flex.net.BinaryUploader#status - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get status():int - { - return _status; - } - - private var _url:String; - - /** - * @copy org.apache.flex.net.BinaryUploader#url - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get url():String - { - return _url; - } - - /** - * @private - */ - public function set url(value:String):void - { - if (_url != value) - { - _url = value; - dispatchEvent(new Event("urlChanged")); - } - } - - private var _timeout:Number = 0; - - /** - * @copy org.apache.flex.net.BinaryUploader#timeout - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get timeout():Number - { - return _timeout; - } - - /** - * @private - */ - public function set timeout(value:Number):void - { - if (_timeout != value) - { - _timeout = value; - dispatchEvent(new Event("timeoutChanged")); - } - } - - private var _id:String; - - /** - * @copy org.apache.flex.core.UIBase#id - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get id():String - { - return _id; - } - - /** - * @private - */ - public function set id(value:String):void - { - if (_id != value) - { - _id = value; - dispatchEvent(new Event("idChanged")); - } - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.UIBase#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - if (_beads == null) - { - for each (var bead:IBead in beads) - addBead(bead); - } - - dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); - } - - /** - * @copy org.apache.flex.core.UIBase#id - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var beads:Array; - - COMPILE::AS3 - private var _beads:Vector.<IBead>; - - /** - * @copy org.apache.flex.core.UIBase#addBead() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::AS3 - public function addBead(bead:IBead):void - { - if (!_beads) - _beads = new Vector.<IBead>; - _beads.push(bead); - bead.strand = this; - } - - /** - * @copy org.apache.flex.core.UIBase#getBeadByType() - * - * @langversion 3.0 - * @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) - { - if (bead is classOrInterface) - return bead; - } - return null; - } - - /** - * @copy org.apache.flex.core.UIBase#removeBead() - * - * @langversion 3.0 - * @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; - for (var i:int = 0; i < n; i++) - { - var bead:IBead = _beads[i]; - if (bead == value) - { - _beads.splice(i, 1); - return bead; - } - } - return null; - } - - COMPILE::AS3 - private var urlLoader:URLLoader; - - /** - * Sends the headers and contentData to the server. - * - * @langversion 3.0 - * @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); - } - - 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(); - } - - } - } - - /** - * @copy org.apache.flex.net.BinaryUploader#statusHandler() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::AS3 - protected function statusHandler(event:HTTPStatusEvent):void - { - _status = event.status; - if ("responseHeaders" in event) - _responseHeaders = event.responseHeaders; - if ("responseURL" in event) - _responseURL = event.responseURL; - dispatchEvent(new Event(event.type)); - } - - /** - * @copy org.apache.flex.net.BinaryUploader#ioErrorHandler() - * - * @langversion 3.0 - * @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)); - } - - /** - * @copy org.apache.flex.net.BinaryUploader#completeHandler() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @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 - { - COMPILE::AS3 - { - return urlLoader.data; - } - COMPILE::JS - { - return (element as XMLHttpRequest).responseText; - } - } - - - private var _json:Object; - - /** - * A JSON object parsed from the data. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get json():Object - { - if (!_json) - _json = JSON.parse(data); - return _json; - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/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 deleted file mode 100644 index 4cd73df..0000000 --- a/frameworks/projects/Network/as/src/org/apache/flex/net/HTTPServiceBase.as +++ /dev/null @@ -1,47 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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/0511cc57/frameworks/projects/Network/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/basic-manifest.xml b/frameworks/projects/Network/basic-manifest.xml deleted file mode 100644 index 235b09d..0000000 --- a/frameworks/projects/Network/basic-manifest.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0"?> -<!-- - - 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. - ---> - - -<componentPackage> - - <component id="HTTPService" class="org.apache.flex.net.HTTPService"/> - <component id="BinaryUploader" class="org.apache.flex.net.BinaryUploader"/> - -</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/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 deleted file mode 100644 index a61da6f..0000000 --- a/frameworks/projects/Network/compile-asjs-config.xml +++ /dev/null @@ -1,82 +0,0 @@ -<!-- - - 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/0511cc57/frameworks/projects/Network/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/compile-config.xml b/frameworks/projects/Network/compile-config.xml deleted file mode 100644 index ed9e3e8..0000000 --- a/frameworks/projects/Network/compile-config.xml +++ /dev/null @@ -1,78 +0,0 @@ -<!-- - - 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> - <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> - <path-element>../../libs/Core.swc</path-element> - </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/> - - <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> - <name>js/out/*</name> - <path>js/out/*</path> - </include-file> - - <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/0511cc57/frameworks/projects/Network/src/main/flex/NetworkClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/src/main/flex/NetworkClasses.as b/frameworks/projects/Network/src/main/flex/NetworkClasses.as new file mode 100644 index 0000000..cf88050 --- /dev/null +++ b/frameworks/projects/Network/src/main/flex/NetworkClasses.as @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + +/** + * @private + * This class is used to link additional classes into rpc.swc + * beyond those that are found by dependecy analysis starting + * from the classes specified in manifest.xml. + */ +internal class NetworkClasses +{ +} + +} + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0511cc57/frameworks/projects/Network/src/main/flex/org/apache/flex/net/BinaryUploader.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/BinaryUploader.as b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/BinaryUploader.as new file mode 100644 index 0000000..3f9f697 --- /dev/null +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/BinaryUploader.as @@ -0,0 +1,738 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 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; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.utils.BinaryData; + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * Dispatched when the upload is complete. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="complete", type="org.apache.flex.events.Event")] + + /** + * Dispatched if an error occurs in the upload. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="ioError", type="org.apache.flex.events.Event")] + + /** + * Dispatched when an httpStatus code is received from the server. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="httpStatus", type="org.apache.flex.events.Event")] + + /** + * Dispatched if Adobe AIR is able to detect and return the status + * code for the request. Unlike the httpStatus event, the httpResponseStatus + * event is delivered before any response data. Also, the httpResponseStatus + * event includes values for the responseHeaders and responseURL properties + * (which are undefined for an httpStatus event. Note that the + * httpResponseStatus event (if any) will be sent before + * (and in addition to) any complete or error event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="httpResponseStatus", type="org.apache.flex.events.Event")] + + [DefaultProperty("beads")] + + /** + * The BinaryUploader class is a class designed to upload binary data + * over HTTP. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class BinaryUploader extends HTTPServiceBase implements IStrand, IBead + { + /** + * The GET request method. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public static const HTTP_METHOD_GET:String = "GET"; + + /** + * The POST request method. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public static const HTTP_METHOD_POST:String = "POST"; + + /** + * The PUT request method. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public static const HTTP_METHOD_PUT:String = "PUT"; + + /** + * The DELETE request method. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public static const HTTP_METHOD_DELETE:String = "DELETE"; + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + public function BinaryUploader() + { + super(); + COMPILE::JS + { + element = new XMLHttpRequest() as WrappedHTMLElement; + } + } + + private var _contentType:String = "application/octet-stream"; + + /** + * The content-type of the binary data. + * @default application/octet-stream + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get contentType():String + { + return _contentType; + } + + /** + * @private + */ + public function set contentType(value:String):void + { + if (_contentType != value) + { + _contentType = value; + dispatchEvent(new Event("contentTypeChanged")); + } + } + + private var _binaryData:BinaryData; + + /** + * The data to be uploaded. Note the type of this + * property is org.apache.flex.utils.BinaryData. + * This class abstracts the way binary data is handled + * in the browser. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get binaryData():BinaryData + { + return _binaryData; + } + + /** + * @private + */ + public function set binaryData(value:BinaryData):void + { + if (_binaryData != value) + { + _binaryData = value; + dispatchEvent(new Event("binaryDataChanged")); + } + } + + private var _headers:Array; + + /** + * The HTTP headers to be sent with the upload. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get headers():Array + { + if (_headers == null) + _headers = []; + return _headers; + } + + /** + * @private + */ + public function set headers(value:Array):void + { + if (_headers != value) + { + _headers = value; + dispatchEvent(new Event("headersChanged")); + } + } + + private var _method:String = HTTP_METHOD_POST; + + /** + * The HTTP method for the upload. + * @default POST + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get method():String + { + return _method; + } + + /** + * @private + */ + public function set method(value:String):void + { + if (_method != value) + { + _method = value; + dispatchEvent(new Event("methodChanged")); + } + } + + private var _responseHeaders:Array; + + /** + * The HTTP headers that were received from the server + * if any. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get responseHeaders():Array + { + 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; + + /** + * The value of the responseURL header, if any. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get responseURL():String + { + return _responseURL; + } + + private var _status:int; + + /** + * The http status code from the server, if any. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get status():int + { + return _status; + } + + private var _url:String; + + /** + * The url of the server. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get url():String + { + return _url; + } + + /** + * @private + */ + public function set url(value:String):void + { + if (_url != value) + { + _url = value; + dispatchEvent(new Event("urlChanged")); + } + } + + private var _timeout:Number = 0; + + /** + * A timeout value for server response. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get timeout():Number + { + return _timeout; + } + + /** + * @private + */ + public function set timeout(value:Number):void + { + if (_timeout != value) + { + _timeout = value; + dispatchEvent(new Event("timeoutChanged")); + } + } + + private var _id:String; + + /** + * @copy org.apache.flex.core.UIBase#id + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get id():String + { + return _id; + } + + /** + * @private + */ + public function set id(value:String):void + { + if (_id != value) + { + _id = value; + dispatchEvent(new Event("idChanged")); + } + } + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.UIBase#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + for each (var bead:IBead in beads) + addBead(bead); + + dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); + } + + /** + * @copy org.apache.flex.core.UIBase#beads + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var beads:Array; + + COMPILE::AS3 + private var _beads:Vector.<IBead>; + + /** + * @copy org.apache.flex.core.UIBase#addBead() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + public function addBead(bead:IBead):void + { + if (!_beads) + _beads = new Vector.<IBead>; + _beads.push(bead); + bead.strand = this; + } + + /** + * @copy org.apache.flex.core.UIBase#getBeadByType() + * + * @langversion 3.0 + * @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) + { + if (bead is classOrInterface) + return bead; + } + return null; + } + + /** + * @copy org.apache.flex.core.UIBase#removeBead() + * + * @langversion 3.0 + * @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; + for (var i:int = 0; i < n; i++) + { + var bead:IBead = _beads[i]; + if (bead == value) + { + _beads.splice(i, 1); + return bead; + } + } + return null; + } + + COMPILE::AS3 + private var urlLoader:URLLoader; + + /** + * Starts the upload to the server. Events + * are dispatched as the upload progresses. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function send():void + { + 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(); + } + + } + } + + /** + * The handler for HTTP_STATUS and/or HTTP_RESPONSE_STATUS events + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + protected function statusHandler(event:HTTPStatusEvent):void + { + _status = event.status; + if ("responseHeaders" in event) + _responseHeaders = event.responseHeaders; + if ("responseURL" in event) + _responseURL = event.responseURL; + dispatchEvent(new Event(event.type)); + } + + /** + * The handler for the IO_ERROR event. + * + * @langversion 3.0 + * @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)); + } + + /** + * The handler for the COMPLETE event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @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. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion XMLHttpRequest + */ + public function get data():* + { + COMPILE::AS3 + { + return urlLoader.data; + } + COMPILE::JS + { + return (element as XMLHttpRequest).responseText; + } + } + } +} \ No newline at end of file
