File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ let httpError = require('./errors')
2
2
let binaryTypes = require ( './helpers/binary-types' )
3
3
let { brotliCompressSync } = require ( 'zlib' )
4
4
5
+ let binaryTypesSet = new Set ( binaryTypes )
6
+
5
7
module . exports = function responseFormatter ( req , params ) {
6
8
let isError = params instanceof Error
7
9
@@ -167,7 +169,8 @@ module.exports = function responseFormatter (req, params) {
167
169
}
168
170
169
171
// Handle body encoding (if necessary)
170
- let isBinary = binaryTypes . some ( t => res . headers [ 'content-type' ] . includes ( t ) )
172
+ let [ cTest ] = ( res . headers [ 'content-type' ] || '' ) . split ( ';' )
173
+ let isBinary = binaryTypesSet . has ( cTest )
171
174
let bodyIsString = typeof res . body === 'string'
172
175
let b64enc = i => new Buffer . from ( i ) . toString ( 'base64' )
173
176
function compress ( body ) {
You can’t perform that action at this time.
0 commit comments