1'use strict';
2
3const common = require('../common');
4const http = require('http');
5const net = require('net');
6const assert = require('assert');
7
8const reqstr = 'POST / HTTP/1.1\r\n' +
9               'Content-Length: 1\r\n' +
10               'Transfer-Encoding: chunked\r\n\r\n';
11
12const server = http.createServer(common.mustNotCall());
13server.on('clientError', common.mustCall((err) => {
14  assert.match(err.message, /^Parse Error/);
15  assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
16  server.close();
17}));
18server.listen(0, () => {
19  const client = net.connect({ port: server.address().port }, () => {
20    client.write(reqstr);
21    client.end();
22  });
23  client.on('data', (data) => {
24    // Should not get to this point because the server should simply
25    // close the connection without returning any data.
26    assert.fail('no data should be returned by the server');
27  });
28  client.on('end', common.mustCall());
29});
30