Skip to content

Commit 21ab1b7

Browse files
authored
refactor: use res.headersSent (#225)
1 parent fc2ff9b commit 21ab1b7

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

index.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function compression (options) {
9090
return false
9191
}
9292

93-
if (!headersSent(res)) {
93+
if (!res.headersSent) {
9494
this.writeHead(this.statusCode)
9595
}
9696

@@ -104,7 +104,7 @@ function compression (options) {
104104
return false
105105
}
106106

107-
if (!headersSent(res)) {
107+
if (!res.headersSent) {
108108
// estimate the length
109109
if (!this.getHeader('Content-Length')) {
110110
length = chunkLength(chunk, encoding)
@@ -298,17 +298,3 @@ function toBuffer (chunk, encoding) {
298298
? chunk
299299
: Buffer.from(chunk, encoding)
300300
}
301-
302-
/**
303-
* Determine if the response headers have been sent.
304-
*
305-
* @param {object} res
306-
* @returns {boolean}
307-
* @private
308-
*/
309-
310-
function headersSent (res) {
311-
return typeof res.headersSent !== 'boolean'
312-
? Boolean(res._header)
313-
: res.headersSent
314-
}

0 commit comments

Comments
 (0)