Skip to content

Commit

Permalink
handler for *Array types
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 2, 2013
1 parent f9a2bf6 commit 46e2b84
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ Request.prototype.end = function (s) {
}
this.xhr.send(body);
}
else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
var len = 0;
for (var i = 0; i < this.body.length; i++) {
len += this.body[i].length;
}
var body = new(this.body[0].constructor)(len);
var k = 0;

for (var i = 0; i < this.body.length; i++) {
var b = this.body[i];
for (var j = 0; j < b.length; j++) {
body[k++] = b[j];
}
}
this.xhr.send(body);
}
else {
var body = '';
for (var i = 0; i < this.body.length; i++) {
Expand Down

0 comments on commit 46e2b84

Please sign in to comment.