• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --insecure-http-parser
2
3'use strict';
4const common = require('../common');
5const assert = require('assert');
6const http = require('http');
7const net = require('net');
8
9const server = http.createServer(function(req, res) {
10  assert.strictEqual(req.headers['content-type'], 'text/te\bt');
11  req.pipe(res);
12});
13
14server.listen(0, common.mustCall(function() {
15  const bufs = [];
16  const client = net.connect(
17    this.address().port,
18    function() {
19      client.write(
20        'GET / HTTP/1.1\r\n' +
21        'Content-Type: text/te\x08t\r\n' +
22        'Connection: close\r\n\r\n');
23    }
24  );
25  client.on('data', function(chunk) {
26    bufs.push(chunk);
27  });
28  client.on('end', common.mustCall(function() {
29    const head = Buffer.concat(bufs)
30      .toString('latin1')
31      .split('\r\n')[0];
32    assert.strictEqual(head, 'HTTP/1.1 200 OK');
33    server.close();
34  }));
35}));
36