Skip to content

Commit

Permalink
Merge pull request #1176 from spumko/v2.0
Browse files Browse the repository at this point in the history
Unify stream and buffer responses
  • Loading branch information
Eran Hammer committed Nov 24, 2013
2 parents 4c1e598 + 17d625b commit 54df471
Show file tree
Hide file tree
Showing 7 changed files with 401 additions and 369 deletions.
19 changes: 13 additions & 6 deletions lib/payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,17 @@ internals.parse = function (payload, mime, headers, options, callback) {
else {
form.on('file', function (name, file) {

file.name = file.originalFilename; // For backwards compatibility with formidable
file.type = file.headers && file.headers['content-type'];
delete file.ws;
set(name, file);
var item = {
name: file.originalFilename, // For backwards compatibility with formidable
type: file.headers && file.headers['content-type'],
fieldName: file.fieldName,
originalFilename: file.originalFilename,
path: file.path,
headers: file.headers,
size: file.size
};

set(name, item);
});
}

Expand Down Expand Up @@ -309,14 +316,14 @@ internals.Replay = function (headers, payload) {

Stream.Readable.call(this);
this.headers = headers;
this.__payload = payload;
this._payload = payload;
};

Utils.inherits(internals.Replay, Stream.Readable);


internals.Replay.prototype._read = function (size) {

this.push(this.__payload);
this.push(this._payload);
this.push(null);
};
Loading

0 comments on commit 54df471

Please sign in to comment.