diff --git a/package.json b/package.json index 7f2b28500..e96f25139 100644 --- a/package.json +++ b/package.json @@ -123,6 +123,6 @@ "supertest": "6.3.3" }, "engines": { - "node": ">=18" + "node": ">=18.5" } } diff --git a/packages/node_modules/node-red/package.json b/packages/node_modules/node-red/package.json index 19ae837cb..0e2ecba04 100644 --- a/packages/node_modules/node-red/package.json +++ b/packages/node_modules/node-red/package.json @@ -47,6 +47,6 @@ "bcrypt": "5.1.0" }, "engines": { - "node": ">=18" + "node": ">=18.5" } } diff --git a/test/nodes/core/network/21-httprequest_spec.js b/test/nodes/core/network/21-httprequest_spec.js index 6459a2122..494cd73d3 100644 --- a/test/nodes/core/network/21-httprequest_spec.js +++ b/test/nodes/core/network/21-httprequest_spec.js @@ -2509,69 +2509,59 @@ describe('HTTP Request Node', function() { }); describe('should parse broken headers', function() { + let port = testPort++ - const versions = process.versions.node.split('.') + let server; - if (( versions[0] == 14 && versions[1] >= 20 ) || - ( versions[0] == 16 && versions[1] >= 16 ) || - ( versions[0] == 18 && versions[1] >= 5 ) || - ( versions[0] > 18)) { - // only test if on new enough NodeJS version + before(function() { + server = net.createServer(function (socket) { + socket.write("HTTP/1.0 200\nContent-Type: text/plain\n\nHelloWorld") + socket.end() + }) - let port = testPort++ + server.listen(port,'127.0.0.1', function(err) { + }) + }); - let server; + after(function() { + server.close() + }); - before(function() { - server = net.createServer(function (socket) { - socket.write("HTTP/1.0 200\nContent-Type: text/plain\n\nHelloWorld") - socket.end() + it('should accept broken headers', function (done) { + var flow = [{id:'n1',type:'http request',wires:[['n2']],method:'GET',ret:'obj',url:`http://localhost:${port}/`, insecureHTTPParser: true}, + {id:"n2", type:"helper"}]; + helper.load(httpRequestNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on('input', function(msg) { + try { + msg.payload.should.equal('HelloWorld') + done() + } catch (err) { + done(err) + } }) + n1.receive({payload: 'foo'}) + }); + }); - server.listen(port,'127.0.0.1', function(err) { + it('should reject broken headers', function (done) { + var flow = [{id:'n1',type:'http request',wires:[['n2']],method:'GET',ret:'obj',url:`http://localhost:${port}/`}, + {id:"n2", type:"helper"}]; + helper.load(httpRequestNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on('input', function(msg) { + try{ + msg.payload.should.match(/RequestError: Parse Error/) + done() + } catch (err) { + done(err) + } }) - }); + n1.receive({payload: 'foo'}) - after(function() { - server.close() }); - - it('should accept broken headers', function (done) { - var flow = [{id:'n1',type:'http request',wires:[['n2']],method:'GET',ret:'obj',url:`http://localhost:${port}/`, insecureHTTPParser: true}, - {id:"n2", type:"helper"}]; - helper.load(httpRequestNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - n2.on('input', function(msg) { - try { - msg.payload.should.equal('HelloWorld') - done() - } catch (err) { - done(err) - } - }) - n1.receive({payload: 'foo'}) - }); - }); - - it('should reject broken headers', function (done) { - var flow = [{id:'n1',type:'http request',wires:[['n2']],method:'GET',ret:'obj',url:`http://localhost:${port}/`}, - {id:"n2", type:"helper"}]; - helper.load(httpRequestNode, flow, function() { - var n1 = helper.getNode("n1"); - var n2 = helper.getNode("n2"); - n2.on('input', function(msg) { - try{ - msg.payload.should.match(/RequestError: Parse Error/) - done() - } catch (err) { - done(err) - } - }) - n1.receive({payload: 'foo'}) - - }); - }); - } + }); }); });