aboutsummaryrefslogtreecommitdiffstats
path: root/lib/caldav
diff options
context:
space:
mode:
Diffstat (limited to 'lib/caldav')
-rw-r--r--lib/caldav/xhr.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/caldav/xhr.js b/lib/caldav/xhr.js
index 4ed7ec6..abeae79 100644
--- a/lib/caldav/xhr.js
+++ b/lib/caldav/xhr.js
@@ -118,10 +118,35 @@
}
}
+
+ var hasProgressEvents = false;
+
+ // check for progress event support.
+ if ('onprogress' in xhr) {
+ hasProgressEvents = true;
+ var last = 0;
+ xhr.onprogress = function onProgress(event) {
+ var chunk = xhr.responseText.substr(last, event.loaded);
+ last = event.loaded;
+ if (this.ondata) {
+ this.ondata(chunk);
+ }
+ }.bind(this);
+ }
+
xhr.onreadystatechange = function onReadyStateChange() {
var data;
if (xhr.readyState === 4) {
data = xhr.responseText;
+
+ // emulate progress events for node...
+ // this really lame we should probably just
+ // use a real http request for node but this
+ // will let us do some testing via node for now.
+ if (!hasProgressEvents && this.ondata) {
+ this.ondata(data);
+ }
+
this.waiting = false;
callback(null, xhr);
}