diff --git a/lib/core/client.js b/lib/core/client.js index 587c4408121..4eb86c1eff2 100644 --- a/lib/core/client.js +++ b/lib/core/client.js @@ -500,7 +500,7 @@ class Parser extends HTTPParser { if (shouldKeepAlive && client[kKeepAlive]) { const keepAliveTimeout = util.parseKeepAliveTimeout(headers) - if (Number.isFinite(keepAliveTimeout)) { + if (keepAliveTimeout != null) { const timeout = Math.min( keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout] diff --git a/lib/core/util.js b/lib/core/util.js index 00348a35080..30ff7f2d13e 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -51,8 +51,8 @@ function parseKeepAliveTimeout (headers) { for (let n = 0; n < headers.length; n += 2) { const key = headers[n + 0] if (key.length === 10 && key.toLowerCase() === 'keep-alive') { - const m = headers[n + 1].match(/timeout=(\d+)/) - return m ? Number(m[1]) * 1000 : undefined + const timeout = parseInt(headers[n + 1].split('timeout=', 2)[1]) + return timeout ? timeout * 1000 : undefined } } }