You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/11/19 04:50:29 UTC

[royale-asjs] branch develop updated: COMPLETE event should occur after 'load' native event to allow for update of bytesTotal if it was not computable (Content-Length header missing for example) (This was not previously happening until after 'readystatechange' check)

This is an automated email from the ASF dual-hosted git repository.

gregdove 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 6945702  COMPLETE event should occur after 'load' native event to allow for update of bytesTotal if it was not computable (Content-Length header missing for example) (This was not previously happening until after 'readystatechange' check)
     new fbe12be  Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
6945702 is described below

commit 6945702a752e3f99253fc1d620198f587d7c5e53
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu Nov 19 17:48:27 2020 +1300

    COMPLETE event should occur after 'load' native event to allow for update of bytesTotal if it was not computable (Content-Length header missing for example)
    (This was not previously happening until after 'readystatechange' check)
---
 .../src/main/royale/org/apache/royale/net/URLLoader.as      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
index ab48da6..88b7526 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
@@ -341,10 +341,11 @@ package org.apache.royale.net
                 {
                     dispatchEvent(HTTPConstants.IO_ERROR);
                 }
-                else
+                //otherwise wait for 'load' event to dispatch 'complete' so that bytesLoaded and bytesTotal are accurate
+                /*else
                 {
                     dispatchEvent(HTTPConstants.COMPLETE);
-                }
+                }*/
             }
         }
 
@@ -356,7 +357,13 @@ package org.apache.royale.net
                 bytesTotal = e.lengthComputable ? e.total : 0;
                 //avoid instantiation and dispatch unless we are being listened to
                 if (e.type=='progress' && hasEventListener(org.apache.royale.events.ProgressEvent.PROGRESS))
-                    dispatchEvent(new org.apache.royale.events.ProgressEvent(org.apache.royale.events.ProgressEvent.PROGRESS,false,false,bytesLoaded,bytesTotal ))
+                    dispatchEvent(new org.apache.royale.events.ProgressEvent(org.apache.royale.events.ProgressEvent.PROGRESS,false,false,bytesLoaded,bytesTotal ));
+                if (e.type == 'load') {
+                    if (!e.lengthComputable) {
+                        bytesTotal = bytesLoaded;
+                    }
+                    dispatchEvent(HTTPConstants.COMPLETE);
+                }
             } else {
                 bytesLoaded = 0;
                 bytesTotal = 0;