diff --git a/index.js b/index.js index bd6d5ea9..b1a19067 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ function compression (options) { return false } - if (!headersSent(res)) { + if (!res.headersSent) { this.writeHead(this.statusCode) } @@ -104,7 +104,7 @@ function compression (options) { return false } - if (!headersSent(res)) { + if (!res.headersSent) { // estimate the length if (!this.getHeader('Content-Length')) { length = chunkLength(chunk, encoding) @@ -298,17 +298,3 @@ function toBuffer (chunk, encoding) { ? chunk : Buffer.from(chunk, encoding) } - -/** - * Determine if the response headers have been sent. - * - * @param {object} res - * @returns {boolean} - * @private - */ - -function headersSent (res) { - return typeof res.headersSent !== 'boolean' - ? Boolean(res._header) - : res.headersSent -}