mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
ab03635fb1
This is a two-part fix: - Fix pending data notification in `OutgoingMessage` to notify server about flushed data too - Fix pause/resume behavior for the consumed socket. `resume` event is emitted on a next tick, and `socket._paused` can already be `true` at this time. Pause the socket again to avoid PAUSED error on parser. Fix: https://github.com/nodejs/node/issues/3332 PR-URL: https://github.com/nodejs/node/pull/3342 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
42 lines
1006 B
JavaScript
42 lines
1006 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
|
|
const big = new Buffer(16 * 1024);
|
|
big.fill('A');
|
|
|
|
const COUNT = 1e4;
|
|
|
|
var received = 0;
|
|
|
|
var client;
|
|
const server = http.createServer(function(req, res) {
|
|
res.end(big, function() {
|
|
if (++received === COUNT) {
|
|
server.close();
|
|
client.end();
|
|
}
|
|
});
|
|
}).listen(common.PORT, function() {
|
|
var req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n');
|
|
client = net.connect(common.PORT, function() {
|
|
client.write(req);
|
|
});
|
|
|
|
// Just let the test terminate instead of hanging
|
|
client.on('close', function() {
|
|
if (received !== COUNT)
|
|
server.close();
|
|
});
|
|
client.resume();
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
// The server should pause connection on pipeline flood, but it shoul still
|
|
// resume it and finish processing the requests, when its output queue will
|
|
// be empty again.
|
|
assert.equal(received, COUNT);
|
|
});
|