aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/caldav/xhr.js28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/caldav/xhr.js b/lib/caldav/xhr.js
index 230f656..d49186b 100644
--- a/lib/caldav/xhr.js
+++ b/lib/caldav/xhr.js
@@ -86,7 +86,6 @@
} else {
xhr = new this.xhrClass();
}
-
// This hack is in place due to some platform
// bug in gecko when using mozSystem xhr
// the credentials only seem to work as expected
@@ -101,6 +100,12 @@
));
}
+ var useMozChunkedText = false;
+ if (this.globalXhrOptions && this.globalXhrOptions.useMozChunkedText) {
+ useMozChunkedText = true;
+ xhr.responseType = 'moz-chunked-text';
+ }
+
for (header in this.headers) {
if (Object.hasOwnProperty.call(this.headers, header)) {
xhr.setRequestHeader(header, this.headers[header]);
@@ -114,13 +119,20 @@
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);
+
+ if (useMozChunkedText) {
+ xhr.onprogress = function onChunkedProgress(event) {
+ this.ondata(xhr.responseText);
+ }.bind(this);
+ } else {
+ 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() {