Skip to content

Commit

Permalink
node 0.11 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Aug 28, 2013
1 parent bd3a9cc commit 4400330
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 3 additions & 2 deletions lib/payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ exports.read = function (request, next) {
var clientTimeoutId = null;

if (clientTimeout) {
clientTimeout -= Date.now() - request._timestamp;
clientTimeout -= (Date.now() - request._timestamp);

clientTimeoutId = setTimeout(function () {

finish(Boom.clientTimeout('Client is taking too long to send request'));
}, clientTimeout);
}, clientTimeout < 0 ? 0 : clientTimeout);
}

// Return only once from events
Expand Down
4 changes: 0 additions & 4 deletions lib/response/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ internals.Stream.prototype._transmit = function (request, callback) {
});

self._preview.end();

if (self._stream.destroy) {
self._stream.destroy();
}
}
};

Expand Down
8 changes: 3 additions & 5 deletions test/integration/clientTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,17 @@ describe('Client Timeout', function () {
method: 'POST'
};


var req = Http.request(options, function (res) {

expect(res.statusCode).to.equal(408);
expect(timer.elapsed()).to.be.at.least(49);
done();
});

req.on('error', function (err) { // Will error out, so don't allow error to escape test

});
req.on('error', function (err) { }); // Will error out, so don't allow error to escape test

req.write('\n');
req.write('{}\n');
var now = Date.now();
setTimeout(function () {

req.end();
Expand Down

0 comments on commit 4400330

Please sign in to comment.