2016-02-04 02:28:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const net = require('net');
|
|
|
|
const http = require('http');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const str = 'GET / HTTP/1.1\r\n' +
|
|
|
|
'Dummy: Header\r' +
|
|
|
|
'Content-Length: 1\r\n' +
|
|
|
|
'\r\n';
|
|
|
|
|
|
|
|
|
|
|
|
const server = http.createServer((req, res) => {
|
2016-07-14 17:26:35 +02:00
|
|
|
common.fail('this should not be called');
|
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_LF_EXPECTED');
|
|
|
|
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.on('data', (chunk) => {
|
2016-07-14 17:26:35 +02:00
|
|
|
common.fail('this should not be called');
|
2016-02-04 02:28:48 +01:00
|
|
|
});
|
|
|
|
client.on('end', common.mustCall(() => {
|
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
client.write(str);
|
|
|
|
client.end();
|
|
|
|
});
|
|
|
|
});
|