Skip to content

Commit a6cb0e0

Browse files
author
James Halliday
committed
remove concat-stream for ie<=8
1 parent fdc1a88 commit a6cb0e0

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

lib/request.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
var Stream = require('stream');
22
var Response = require('./response');
3-
var concatStream = require('concat-stream');
43
var Base64 = require('Base64');
54
var util = require('util');
65

76
var Request = module.exports = function (xhr, params) {
87
var self = this;
98
self.writable = true;
109
self.xhr = xhr;
11-
self.body = concatStream()
10+
self.body = [];
1211

1312
self.uri = (params.scheme || 'http') + '://'
1413
+ params.host
@@ -72,7 +71,7 @@ Request.prototype.setHeader = function (key, value) {
7271
};
7372

7473
Request.prototype.write = function (s) {
75-
this.body.write(s);
74+
this.body.push(s);
7675
};
7776

7877
Request.prototype.destroy = function (s) {
@@ -81,9 +80,27 @@ Request.prototype.destroy = function (s) {
8180
};
8281

8382
Request.prototype.end = function (s) {
84-
if (s !== undefined) this.body.write(s);
85-
this.body.end()
86-
this.xhr.send(this.body.getBody());
83+
if (s !== undefined) this.body.push(s);
84+
if (this.body.length === 0) {
85+
this.xhr.send('');
86+
}
87+
else if (typeof this.body[0] === 'string') {
88+
this.xhr.send(this.body.join(''));
89+
}
90+
else if (isArray(this.body[0])) {
91+
var body = [];
92+
for (var i = 0; i < this.body.length; i++) {
93+
body.push.apply(body, this.body[i]);
94+
}
95+
this.xhr.send(body);
96+
}
97+
else {
98+
var body = '';
99+
for (var i = 0; i < this.body.length; i++) {
100+
body += this.body[i].toString();
101+
}
102+
this.xhr.send(body);
103+
}
87104
};
88105

89106
// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"test": "test"
1111
},
1212
"dependencies": {
13-
"concat-stream": "~1.0.0",
1413
"Base64": "~0.1.2"
1514
},
1615
"devDependencies": {

0 commit comments

Comments
 (0)