xref: /third_party/node/test/parallel/test-http-server-reject-cr-no-lf.js
  • 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            'Dummy: Header\r' +
101cb0ef41Sopenharmony_ci            'Content-Length: 1\r\n' +
111cb0ef41Sopenharmony_ci            '\r\n';
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall());
151cb0ef41Sopenharmony_ciserver.on('clientError', common.mustCall((err) => {
161cb0ef41Sopenharmony_ci  assert.match(err.message, /^Parse Error/);
171cb0ef41Sopenharmony_ci  assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
181cb0ef41Sopenharmony_ci  server.close();
191cb0ef41Sopenharmony_ci}));
201cb0ef41Sopenharmony_ciserver.listen(0, () => {
211cb0ef41Sopenharmony_ci  const client = net.connect({ port: server.address().port }, () => {
221cb0ef41Sopenharmony_ci    client.on('data', common.mustNotCall());
231cb0ef41Sopenharmony_ci    client.on('end', common.mustCall(() => {
241cb0ef41Sopenharmony_ci      server.close();
251cb0ef41Sopenharmony_ci    }));
261cb0ef41Sopenharmony_ci    client.write(str);
271cb0ef41Sopenharmony_ci    client.end();
281cb0ef41Sopenharmony_ci  });
291cb0ef41Sopenharmony_ci});
30

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