2016-02-04 02:28:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const http = require('http');
|
|
|
|
const net = require('net');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const reqstr = 'POST / HTTP/1.1\r\n' +
|
|
|
|
'Content-Length: 1\r\n' +
|
|
|
|
'Transfer-Encoding: chunked\r\n\r\n';
|
|
|
|
|
|
|
|
const server = http.createServer((req, res) => {
|
2016-07-14 17:26:35 +02:00
|
|
|
common.fail('callback should not be invoked');
|
2016-02-04 02:28:48 +01:00
|
|
|
});
|
|
|
|
server.on('clientError', common.mustCall((err) => {
|
|
|
|
assert(/^Parse Error/.test(err.message));
|
|
|
|
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
|
|
|
server.close();
|
|
|
|
}));
|
2016-05-29 09:06:56 +02:00
|
|
|
server.listen(0, () => {
|
|
|
|
const client = net.connect({port: server.address().port}, () => {
|
2016-02-04 02:28:48 +01:00
|
|
|
client.write(reqstr);
|
|
|
|
client.end();
|
|
|
|
});
|
|
|
|
client.on('data', (data) => {
|
|
|
|
// Should not get to this point because the server should simply
|
|
|
|
// close the connection without returning any data.
|
2016-07-14 17:26:35 +02:00
|
|
|
common.fail('no data should be returned by the server');
|
2016-02-04 02:28:48 +01:00
|
|
|
});
|
|
|
|
client.on('end', common.mustCall(() => {}));
|
|
|
|
});
|