1'use strict'; 2 3const common = require('../common'); 4const http = require('http'); 5const assert = require('assert'); 6 7// The callback should never be invoked because the server 8// should respond with a 400 Client Error when a double 9// Content-Length header is received. 10const server = http.createServer(common.mustNotCall()); 11server.on('clientError', common.mustCall((err, socket) => { 12 assert.match(err.message, /^Parse Error/); 13 assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); 14 socket.destroy(); 15})); 16 17server.listen(0, () => { 18 const req = http.get({ 19 port: server.address().port, 20 // Send two content-length header values. 21 headers: { 'Content-Length': [1, 2] } 22 }, common.mustNotCall('an error should have occurred')); 23 req.on('error', common.mustCall(() => { 24 server.close(); 25 })); 26}); 27