11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst http = require('http'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// The callback should never be invoked because the server 81cb0ef41Sopenharmony_ci// should respond with a 400 Client Error when a double 91cb0ef41Sopenharmony_ci// Content-Length header is received. 101cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall()); 111cb0ef41Sopenharmony_ciserver.on('clientError', common.mustCall((err, socket) => { 121cb0ef41Sopenharmony_ci assert.match(err.message, /^Parse Error/); 131cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); 141cb0ef41Sopenharmony_ci socket.destroy(); 151cb0ef41Sopenharmony_ci})); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciserver.listen(0, () => { 181cb0ef41Sopenharmony_ci const req = http.get({ 191cb0ef41Sopenharmony_ci port: server.address().port, 201cb0ef41Sopenharmony_ci // Send two content-length header values. 211cb0ef41Sopenharmony_ci headers: { 'Content-Length': [1, 2] } 221cb0ef41Sopenharmony_ci }, common.mustNotCall('an error should have occurred')); 231cb0ef41Sopenharmony_ci req.on('error', common.mustCall(() => { 241cb0ef41Sopenharmony_ci server.close(); 251cb0ef41Sopenharmony_ci })); 261cb0ef41Sopenharmony_ci}); 27