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 'Content-Length: 1\r\n' + 101cb0ef41Sopenharmony_ci 'Transfer-Encoding: chunked\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 181cb0ef41Sopenharmony_ci // both a Content-Length header and a Transfer-Encoding: chunked 191cb0ef41Sopenharmony_ci // header, which is a violation of the HTTP spec. 201cb0ef41Sopenharmony_ci const req = http.get({ port: server.address().port }, common.mustNotCall()); 211cb0ef41Sopenharmony_ci req.on('error', common.mustCall((err) => { 221cb0ef41Sopenharmony_ci assert.match(err.message, /^Parse Error/); 231cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); 241cb0ef41Sopenharmony_ci server.close(); 251cb0ef41Sopenharmony_ci })); 261cb0ef41Sopenharmony_ci}); 27