Socket
Socket
Sign inDemoInstall

apollo-datasource-http

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-datasource-http - npm Package Compare versions

Comparing version 0.20.0 to 0.21.0

27

dist/src/http-data-source.js

@@ -11,2 +11,4 @@ "use strict";

const quick_lru_1 = __importDefault(require("@alloc/quick-lru"));
const zlib_1 = require("zlib");
const stream_to_promise_1 = __importDefault(require("stream-to-promise"));
const apollo_server_errors_1 = require("apollo-server-errors");

@@ -158,7 +160,22 @@ const url_1 = require("url");

const responseData = await this.pool.request(requestOptions);
let body = await responseData.body.text();
const body = responseData.body;
const headers = responseData.headers;
let dataBuffer;
switch (headers['content-encoding']) {
case 'br':
dataBuffer = await (0, stream_to_promise_1.default)(body.pipe((0, zlib_1.createBrotliDecompress)()));
break;
case 'gzip':
case 'deflate':
dataBuffer = await (0, stream_to_promise_1.default)(body.pipe((0, zlib_1.createUnzip)()));
break;
default:
dataBuffer = await (0, stream_to_promise_1.default)(body);
break;
}
let data = dataBuffer.toString('utf-8');
if (((_b = responseData.headers['content-type']) === null || _b === void 0 ? void 0 : _b.includes('application/json')) &&
body.length &&
typeof body === 'string') {
body = JSON.parse(body);
data.length &&
typeof data === 'string') {
data = JSON.parse(data);
}

@@ -169,3 +186,3 @@ const response = {

...responseData,
body: body,
body: data,
};

@@ -172,0 +189,0 @@ this.onResponse(request, response);

4

package.json
{
"name": "apollo-datasource-http",
"version": "0.20.0",
"version": "0.21.0",
"author": "Dustin Deus <deusdustin@gmail.com>",

@@ -57,2 +57,3 @@ "license": "MIT",

"apollo-server-types": "^3.5.1",
"stream-to-promise": "^3.0.0",
"undici": "^4.13.0"

@@ -68,2 +69,3 @@ },

"@types/sinonjs__fake-timers": "^8.1.1",
"@types/stream-to-promise": "^2.2.1",
"abort-controller": "^3.0.0",

@@ -70,0 +72,0 @@ "apollo-datasource-rest": "^3.5.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc