diff --git a/index.js b/index.js index f190c689..f494bebe 100644 --- a/index.js +++ b/index.js @@ -80,8 +80,8 @@ function compression (options) { return false } - if (!this._header) { - this._implicitHeader() + if (!this.headersSent) { + this.writeHead(this.statusCode) } return stream @@ -94,13 +94,13 @@ function compression (options) { return false } - if (!this._header) { + if (!this.headersSent) { // estimate the length if (!this.getHeader('Content-Length')) { length = chunkLength(chunk, encoding) } - this._implicitHeader() + this.writeHead(this.statusCode) } if (!stream) {