HTTPRequest thread fix

This commit is contained in:
Joshua Granick
2017-03-20 14:59:58 -07:00
parent 4e29928801
commit e6d9c7aab3

View File

@@ -100,7 +100,7 @@ class NativeHTTPRequest {
if (path == null #if (sys && !android) || !FileSystem.exists (path) #end) { if (path == null #if (sys && !android) || !FileSystem.exists (path) #end) {
promise.error ("Cannot load file: " + path); worker.sendError ("Cannot load file: " + path);
} else { } else {
@@ -108,16 +108,26 @@ class NativeHTTPRequest {
if (bytes != null) { if (bytes != null) {
promise.complete (bytes); worker.sendComplete (bytes);
} else { } else {
promise.error ("Cannot load file: " + path); worker.sendError ("Cannot load file: " + path);
} }
} }
});
worker.onComplete.add (function (result) {
promise.complete (result);
});
worker.onError.add (function (message) {
promise.error (message);
}); });
worker.run (); worker.run ();