11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ciconst net = require('net');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst reqstr = 'POST / HTTP/1.1\r\n' +
91cb0ef41Sopenharmony_ci               'Content-Length: 1\r\n' +
101cb0ef41Sopenharmony_ci               'Transfer-Encoding: chunked\r\n\r\n';
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall());
131cb0ef41Sopenharmony_ciserver.on('clientError', common.mustCall((err) => {
141cb0ef41Sopenharmony_ci  assert.match(err.message, /^Parse Error/);
151cb0ef41Sopenharmony_ci  assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
161cb0ef41Sopenharmony_ci  server.close();
171cb0ef41Sopenharmony_ci}));
181cb0ef41Sopenharmony_ciserver.listen(0, () => {
191cb0ef41Sopenharmony_ci  const client = net.connect({ port: server.address().port }, () => {
201cb0ef41Sopenharmony_ci    client.write(reqstr);
211cb0ef41Sopenharmony_ci    client.end();
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci  client.on('data', (data) => {
241cb0ef41Sopenharmony_ci    // Should not get to this point because the server should simply
251cb0ef41Sopenharmony_ci    // close the connection without returning any data.
261cb0ef41Sopenharmony_ci    assert.fail('no data should be returned by the server');
271cb0ef41Sopenharmony_ci  });
281cb0ef41Sopenharmony_ci  client.on('end', common.mustCall());
291cb0ef41Sopenharmony_ci});
30