Skip to content

Commit

Permalink
Code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyxu2005 committed Mar 27, 2024
1 parent d75f3b4 commit 2179320
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,10 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
}

setVaryHeader(reply)
params.removeContentLengthHeader
? reply
.header('Content-Encoding', encoding)
.removeHeader('content-length')
: reply.header('Content-Encoding', encoding)
reply.header('Content-Encoding', encoding)
if (params.removeContentLengthHeader) {
reply.removeHeader('content-length')
}

stream = zipStream(params.compressStream, encoding)
pump(payload, stream, onEnd.bind(reply))
Expand Down Expand Up @@ -405,11 +404,10 @@ function compress (params) {
}

setVaryHeader(this)
params.removeContentLengthHeader
? this
.header('Content-Encoding', encoding)
.removeHeader('content-length')
: this.header('Content-Encoding', encoding)
this.header('Content-Encoding', encoding)
if (params.removeContentLengthHeader) {
this.removeHeader('content-length')
}

stream = zipStream(params.compressStream, encoding)
pump(payload, stream, onEnd.bind(this))
Expand Down

0 comments on commit 2179320

Please sign in to comment.