@pollyjs/adapter-node-http
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [4.2.1](https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-node-http/compare/v4.2.0...v4.2.1) (2020-04-30) | ||
### Bug Fixes | ||
* **adapter-node-http:** Improve binary response body handling ([#329](https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-node-http/issues/329)) ([9466989](https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-node-http/commit/9466989)) | ||
# [4.2.0](https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-node-http/compare/v4.1.0...v4.2.0) (2020-04-29) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@pollyjs/adapter-node-http", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Node HTTP adapter for @pollyjs", | ||
@@ -46,3 +46,3 @@ "main": "dist/cjs/pollyjs-adapter-node-http.js", | ||
"dependencies": { | ||
"@pollyjs/adapter": "^4.1.0", | ||
"@pollyjs/adapter": "^4.2.1", | ||
"@pollyjs/utils": "^4.1.0", | ||
@@ -53,4 +53,4 @@ "lodash-es": "^4.17.11", | ||
"devDependencies": { | ||
"@pollyjs/core": "^4.1.0", | ||
"@pollyjs/persister-fs": "^4.2.0", | ||
"@pollyjs/core": "^4.2.1", | ||
"@pollyjs/persister-fs": "^4.2.1", | ||
"form-data": "^2.5.1", | ||
@@ -61,3 +61,3 @@ "get-stream": "^5.1.0", | ||
}, | ||
"gitHead": "63c23ca00ce935291cc1544d000a63c44ad473c1" | ||
"gitHead": "93afd031b5c804be2931b80a5bcaa7b24110f518" | ||
} |
@@ -204,3 +204,4 @@ import http from 'http'; | ||
statusCode: response.statusCode, | ||
body: responseBody | ||
body: responseBody.body, | ||
isBinary: responseBody.isBinary | ||
}; | ||
@@ -211,3 +212,3 @@ } | ||
const { req, respond } = pollyRequest.requestArguments; | ||
const { statusCode, body, headers } = pollyRequest.response; | ||
const { statusCode, body, headers, isBinary } = pollyRequest.response; | ||
@@ -234,3 +235,3 @@ if (pollyRequest[ABORT_HANDLER]) { | ||
const chunks = this.getChunksFromBody(body, headers); | ||
const chunks = this.getChunksFromBody(body, headers, isBinary); | ||
const stream = new ReadableStream(); | ||
@@ -280,6 +281,10 @@ | ||
return JSON.stringify(hexChunks); | ||
return { | ||
isBinary: true, | ||
body: JSON.stringify(hexChunks) | ||
}; | ||
} | ||
const buffer = mergeChunks(chunks); | ||
const isBinaryBuffer = !isUtf8Representable(buffer); | ||
@@ -289,6 +294,9 @@ // The merged buffer can be one of two things: | ||
// 2. A string buffer. | ||
return buffer.toString(isUtf8Representable(buffer) ? 'utf8' : 'hex'); | ||
return { | ||
isBinary: isBinaryBuffer, | ||
body: buffer.toString(isBinaryBuffer ? 'hex' : 'utf8') | ||
}; | ||
} | ||
getChunksFromBody(body, headers) { | ||
getChunksFromBody(body, headers, isBinary = false) { | ||
if (!body) { | ||
@@ -310,9 +318,7 @@ return []; | ||
const buffer = Buffer.from(body); | ||
// The body can be one of two things: | ||
// 1. A hex string which then means its binary data. | ||
// 2. A utf8 string which means a regular string. | ||
return [Buffer.from(buffer, isUtf8Representable(buffer) ? 'utf8' : 'hex')]; | ||
return [Buffer.from(body, isBinary ? 'hex' : 'utf8')]; | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5383536
39647
29
Updated@pollyjs/adapter@^4.2.1