FYI, this commit makes network requests as easy as:
HttpRequestTask.execute(url,function(task:HttpRequestTask):void{
if(task.completed){
// do completed stuff with task.httpResult
} else {
//handle error
}
});
Or if you need a POST request with parameters:
HttpRequestTask.execute(url,function(task:HttpRequestTask):void{
if(task.completed){
// do completed stuff with task.httpResult
} else {
//handle error
}
},HTTPConstants.POST,params);
for a JSON POST request:
HttpRequestTask.execute(url,function(task:HttpRequestTask):void{
if(task.completed){
// do completed stuff with task.httpResult
} else {
//handle error
}
},HTTPConstants.POST,json,HTTPHeader.APPLICATION_JSON);
HTH,
Harbs
> On Aug 13, 2023, at 11:00 AM, [email protected] wrote:
>
> This is an automated email from the ASF dual-hosted git repository.
>
> harbs 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 527ab9a1ce Added execute method for HttpRequestTask
> 527ab9a1ce is described below
>
> commit 527ab9a1cea74ecdb7f06d4aa82b37e55dcd9526
> Author: Harbs <[email protected]>
> AuthorDate: Sun Aug 13 10:59:56 2023 +0300
>
> Added execute method for HttpRequestTask
> ---
> .../royale/org/apache/royale/utils/async/HttpRequestTask.as | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git
> a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpRequestTask.as
>
> b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpRequestTask.as
> index 98b7b7abb2..6aca4c6478 100644
> ---
> a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpRequestTask.as
> +++
> b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpRequestTask.as
> @@ -136,6 +136,16 @@ package org.apache.royale.utils.async
> {
> fail();
> }
> -
> + public static function execute(url:String, callback:Function,
> method:String = HTTPConstants.GET, parameters:Object = null,
> contentType:String = HTTPConstants.FORM_URL_ENCODED, requestHeaders:Array =
> null):void
> + {
> + var task:HttpRequestTask = new HttpRequestTask();
> + task.url = url;
> + task.contentType = contentType;
> + task.method = method;
> + task.requestHeaders = requestHeaders;
> + task.parameters = parameters;
> + task.done(callback);
> + task.run();
> + }
> }
> }
> \ No newline at end of file
>