From 8dd485aff51538e64b445a5c3cc0bad3077e45ef Mon Sep 17 00:00:00 2001 From: Jayne Doe Date: Tue, 14 Nov 2023 17:27:57 +0000 Subject: [PATCH] refactor(request): abstract https server into a tls server for protocol checks The TLS.Server instance is common for both the https library and the http2 library, according to the NodeJS documentation. Since it is a common ancestor, we should check for this instance instead of the specific https flavour Signed-off-by: Jayne Doe --- lib/request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/request.js b/lib/request.js index 224cedb..189bdf8 100644 --- a/lib/request.js +++ b/lib/request.js @@ -9,7 +9,7 @@ */ var http = require('http') - , https = require('https') + , tls = require('tls') , methods = require('methods') , superagent = require('superagent') , Agent = superagent.agent @@ -283,7 +283,7 @@ function serverAddress (app, path) { if (!addr) { throw new Error('Server is not listening') } - var protocol = (app instanceof https.Server) ? 'https' : 'http'; + var protocol = (app instanceof tls.Server) ? 'https' : 'http'; // If address is "unroutable" IPv4/6 address, then set to localhost if (addr.address === '0.0.0.0' || addr.address === '::') { addr.address = '127.0.0.1';