If anyone using HTTPService will suffer with that changes let me know. More
suggestion are welcome. One thing which stay and it is mysterious to me is
line [1] - Does it make any sense ?

[1]
https://github.com/apache/royale-asjs/blob/133608f8c79dc2b9745724c22ac80fcea9decaad/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as#L604


pon., 13 maj 2019 o 13:11 <[email protected]> napisaƂ(a):

> This is an automated email from the ASF dual-hosted git repository.
>
> piotrz pushed a commit to branch develop
> in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
>
>
> The following commit(s) were added to refs/heads/develop by this push:
>      new 133608f  HTTPService: Change type of the contentData to Object
> 133608f is described below
>
> commit 133608f8c79dc2b9745724c22ac80fcea9decaad
> Author: Piotr Zarzycki <[email protected]>
> AuthorDate: Mon May 13 13:11:41 2019 +0200
>
>     HTTPService: Change type of the contentData to Object
>
>     - Introduced changes expands ability to send trough the service
> different type of data than only String. We are wrapping XMLHttpRequest
> which allows send trough the method send: Document, Blob, BufferSource,
> FormData, URLSearchParams, ReadableStream, or USVString object.
>     - Using getter methods instead setter for timeout, method, contentData
> ---
>  .../royale/org/apache/royale/net/HTTPService.as    | 65
> ++++++++++++++--------
>  1 file changed, 41 insertions(+), 24 deletions(-)
>
> diff --git
> a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as
> b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as
> index dab6700..797e68b 100644
> ---
> a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as
> +++
> b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/HTTPService.as
> @@ -147,7 +147,7 @@ package org.apache.royale.net
>                         }
>                 }
>
> -               private var _contentData:String;
> +               private var _contentData:Object;
>
>          /**
>           *  The text to send to the server, if any.
> @@ -157,7 +157,7 @@ package org.apache.royale.net
>           *  @playerversion AIR 2.6
>           *  @productversion Royale 0.0
>           */
> -               public function get contentData():String
> +               public function get contentData():Object
>                 {
>                         return _contentData;
>                 }
> @@ -165,7 +165,7 @@ package org.apache.royale.net
>          /**
>           *  @private
>           */
> -               public function set contentData(value:String):void
> +               public function set contentData(value:Object):void
>                 {
>                         if (_contentData != value)
>                         {
> @@ -575,12 +575,18 @@ package org.apache.royale.net
>                      if (method == HTTPConstants.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);
> @@ -589,6 +595,7 @@ package org.apache.royale.net
>                  urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS,
> statusHandler);
>                  urlLoader.load(request);
>              }
> +
>              COMPILE::JS
>              {
>                  var element:XMLHttpRequest = this.element as
> XMLHttpRequest;
> @@ -596,27 +603,34 @@ package org.apache.royale.net
>
>                  url = _url;
>
> -                var contentData:String = null;
> -                if (_contentData != null) {
> -                    if (_method == HTTPConstants.GET) {
> -                        if (url.indexOf('?') != -1) {
> -                            url += _contentData;
> -                        } else {
> -                            url += '?' + _contentData;
> +                var currentData:Object = null;
> +                if (contentData != null)
> +                {
> +                    if (method == HTTPConstants.GET)
> +                    {
> +                        if (url.indexOf('?') != -1)
> +                        {
> +                            url += String(contentData);
>                          }
> -                    } else {
> -                        contentData = _contentData;
> +                        else
> +                        {
> +                            url += '?' + String(contentData);
> +                        }
> +                    }
> +                    else
> +                    {
> +                        currentData = contentData;
>                      }
>                  }
>
> -                element.open(_method, _url, true);
> -                element.timeout = _timeout;
> +                element.open(method, url, true);
> +                element.timeout = timeout;
>
>                  var sawContentType:Boolean = false;
> -                if (_headers) {
> -                    var n:int = _headers.length;
> +                if (headers) {
> +                    var n:int = headers.length;
>                      for (var i:int = 0; i < n; i++) {
> -                        var header:HTTPHeader = _headers[i];
> +                        var header:HTTPHeader = headers[i];
>                          if (header.name == HTTPHeader.CONTENT_TYPE) {
>                              sawContentType = true;
>                          }
> @@ -625,15 +639,18 @@ package org.apache.royale.net
>                      }
>                  }
>
> -                if (_method != HTTPConstants.GET &&
> -                    !sawContentType && contentData) {
> -                    element.setRequestHeader(
> -                        HTTPHeader.CONTENT_TYPE, _contentType);
> +                if (method != HTTPConstants.GET &&
> +                    !sawContentType && currentData)
> +                {
> +                    element.setRequestHeader(HTTPHeader.CONTENT_TYPE,
> contentType);
>                  }
>
> -                if (contentData) {
> -                    element.send(contentData);
> -                } else {
> +                if (currentData)
> +                {
> +                    element.send(currentData);
> +                }
> +                else
> +                {
>                      element.send();
>                  }
>
>
>

-- 

Piotr Zarzycki

Patreon: *https://www.patreon.com/piotrzarzycki
<https://www.patreon.com/piotrzarzycki>*

Reply via email to