xref: /third_party/node/test/parallel/test-http-parser-finish-error.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst net = require('net');
51cb0ef41Sopenharmony_ciconst http = require('http');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst str = 'GET / HTTP/1.1\r\n' +
91cb0ef41Sopenharmony_ci            'Content-Length:';
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall());
131cb0ef41Sopenharmony_ciserver.on('clientError', common.mustCall((err, socket) => {
141cb0ef41Sopenharmony_ci  assert.match(err.message, /^Parse Error/);
151cb0ef41Sopenharmony_ci  assert.strictEqual(err.code, 'HPE_INVALID_EOF_STATE');
161cb0ef41Sopenharmony_ci  socket.destroy();
171cb0ef41Sopenharmony_ci}, 1));
181cb0ef41Sopenharmony_ciserver.listen(0, () => {
191cb0ef41Sopenharmony_ci  const client = net.connect({ port: server.address().port }, () => {
201cb0ef41Sopenharmony_ci    client.on('data', common.mustNotCall());
211cb0ef41Sopenharmony_ci    client.on('end', common.mustCall(() => {
221cb0ef41Sopenharmony_ci      server.close();
231cb0ef41Sopenharmony_ci    }));
241cb0ef41Sopenharmony_ci    client.write(str);
251cb0ef41Sopenharmony_ci    client.end();
261cb0ef41Sopenharmony_ci  });
271cb0ef41Sopenharmony_ci});
28

Indexes created Thu Nov 07 10:32:03 CST 2024