Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix bug where http response.readable was never set to false
Browse files Browse the repository at this point in the history
Closes GH-867.
  • Loading branch information
abram authored and ry committed Apr 12, 2011
1 parent 0f47f63 commit 83727a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ var parsers = new FreeList('parsers', 1000, function() {
}
if (!parser.incoming.upgrade) {
// For upgraded connections, also emit this after parser.execute
parser.incoming.readable = false;
parser.incoming.emit('end');
}
};
Expand Down
19 changes: 19 additions & 0 deletions test/simple/test-http-response-readable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var common = require('../common');
var assert = require('assert');
var http = require('http');

var testServer = new http.Server(function(req, res) {
res.writeHead(200);
res.end('Hello world');
});

testServer.listen(common.PORT, function() {
http.get({ port: common.PORT }, function(res) {
assert.equal(res.readable, true, 'res.readable initially true');
res.on('end', function() {
assert.equal(res.readable, false, 'res.readable set to false after end');
testServer.close();
});
});
});

0 comments on commit 83727a4

Please sign in to comment.