xref: /third_party/node/test/parallel/test-http-client-reject-cr-no-lf.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 http = require('http');
51cb0ef41Sopenharmony_ciconst net = require('net');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst reqstr = 'HTTP/1.1 200 OK\r\n' +
91cb0ef41Sopenharmony_ci               'Foo: Bar\r' +
101cb0ef41Sopenharmony_ci               'Content-Length: 1\r\n\r\n';
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst server = net.createServer((socket) => {
131cb0ef41Sopenharmony_ci  socket.write(reqstr);
141cb0ef41Sopenharmony_ci});
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciserver.listen(0, () => {
171cb0ef41Sopenharmony_ci  // The callback should not be called because the server is sending a
181cb0ef41Sopenharmony_ci  // header field that ends only in \r with no following \n
191cb0ef41Sopenharmony_ci  const req = http.get({ port: server.address().port }, common.mustNotCall());
201cb0ef41Sopenharmony_ci  req.on('error', common.mustCall((err) => {
211cb0ef41Sopenharmony_ci    assert.match(err.message, /^Parse Error/);
221cb0ef41Sopenharmony_ci    assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
231cb0ef41Sopenharmony_ci    server.close();
241cb0ef41Sopenharmony_ci  }));
251cb0ef41Sopenharmony_ci});
26

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