Skip to content

Commit

Permalink
fix: set isBase64Encoded when content-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
TMaize authored and yugasun committed May 20, 2021
1 parent a2223ad commit d3d23a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ function forwardResponseToApiGateway (server, response, resolver) {
})

const contentType = getContentType({ contentTypeHeader: headers['content-type'] })
const isBase64Encoded = isContentTypeBinaryMimeType({ contentType, binaryMimeTypes: server._binaryTypes })
let isBase64Encoded = isContentTypeBinaryMimeType({ contentType, binaryMimeTypes: server._binaryTypes })
if (['gzip', 'compress', 'deflate', 'br'].indexOf(headers['content-encoding']) !== -1) {
isBase64Encoded = true
}
const body = bodyBuffer.toString(isBase64Encoded ? 'base64' : 'utf8')
const successResponse = {statusCode, body, headers, isBase64Encoded}

Expand Down

0 comments on commit d3d23a4

Please sign in to comment.