Commit c197abf5 authored by Guillaume Royer's avatar Guillaume Royer

fix(xhr2): handle FormData response type

parent 6c781951
// Generated by CoffeeScript 1.12.2
// Generated by CoffeeScript 1.12.7
(function() {
var InvalidStateError, NetworkError, ProgressEvent, SecurityError, SyntaxError, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, http, https, os, url,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
......@@ -323,7 +323,7 @@
'access-control-request-method': true,
connection: true,
'content-length': true,
// cookie: true,
cookie: true,
cookie2: true,
date: true,
dnt: true,
......@@ -341,7 +341,7 @@
};
XMLHttpRequest.prototype._privateHeaders = {
// 'set-cookie': true,
'set-cookie': true,
'set-cookie2': true
};
......@@ -363,6 +363,7 @@
};
XMLHttpRequest.prototype._sendHttp = function(data) {
var that;
if (this._sync) {
throw new Error("Synchronous XHR processing not implemented");
}
......@@ -372,9 +373,11 @@
} else {
data || (data = '');
}
this.upload._setData(data);
this._finalizeHeaders();
this._sendHxxpRequest();
that = this;
this.upload._setData(data, function() {
that._finalizeHeaders();
return that._sendHxxpRequest();
});
return void 0;
};
......@@ -709,11 +712,13 @@
XMLHttpRequest.XMLHttpRequest = XMLHttpRequest;
XMLHttpRequest.FormData = FormData;
SecurityError = (function(superClass) {
extend(SecurityError, superClass);
function SecurityError() {
SecurityError.__super__.constructor.apply(this, arguments);
SecurityError.__super__.constructor.call(this);
}
return SecurityError;
......@@ -726,7 +731,7 @@
extend(InvalidStateError, superClass);
function InvalidStateError() {
InvalidStateError.__super__.constructor.apply(this, arguments);
InvalidStateError.__super__.constructor.call(this);
}
return InvalidStateError;
......@@ -750,7 +755,7 @@
extend(NetworkError, superClass);
function NetworkError() {
NetworkError.__super__.constructor.apply(this, arguments);
NetworkError.__super__.constructor.call(this);
}
return NetworkError;
......@@ -763,7 +768,7 @@
extend(SyntaxError, superClass);
function SyntaxError() {
SyntaxError.__super__.constructor.apply(this, arguments);
SyntaxError.__super__.constructor.call(this);
}
return SyntaxError;
......@@ -813,10 +818,10 @@
return void 0;
};
XMLHttpRequestUpload.prototype._setData = function(data) {
var body, i, j, k, offset, ref, ref1, view;
XMLHttpRequestUpload.prototype._setData = function(data, cb) {
var body, i, j, k, offset, ref, ref1, that, view;
if (typeof data === 'undefined' || data === null) {
return;
return cb();
}
if (typeof data === 'string') {
if (data.length !== 0) {
......@@ -840,10 +845,23 @@
body[i] = view[i + offset];
}
this._body = body;
} else if (data instanceof FormData) {
body = '';
this._contentType = data.getHeaders()['content-type'];
data.on('data', function(data) {
return body += data.toString();
});
that = this;
data.on('end', function() {
that._body = body;
return cb();
});
data.resume();
return;
} else {
throw new Error("Unsupported send() data " + data);
}
return void 0;
return cb();
};
XMLHttpRequestUpload.prototype._finalizeHeaders = function(headers, loweredHeaders) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment