1'use strict'; 2 3const common = require('../common'); 4const http = require('http'); 5const net = require('net'); 6const assert = require('assert'); 7 8const reqstr = 'HTTP/1.1 200 OK\r\n' + 9 'Foo: Bar\r' + 10 'Content-Length: 1\r\n\r\n'; 11 12const server = net.createServer((socket) => { 13 socket.write(reqstr); 14}); 15 16server.listen(0, () => { 17 // The callback should not be called because the server is sending a 18 // header field that ends only in \r with no following \n 19 const req = http.get({ port: server.address().port }, common.mustNotCall()); 20 req.on('error', common.mustCall((err) => { 21 assert(/^Parse Error/.test(err.message)); 22 assert.strictEqual(err.code, 'HPE_LF_EXPECTED'); 23 server.close(); 24 })); 25}); 26