Socket
Socket
Sign inDemoInstall

http-call

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-call - npm Package Compare versions

Comparing version 4.0.5 to 4.0.6

lib/deps.js.map

1

lib/deps.js

@@ -27,1 +27,2 @@ "use strict";

}
//# sourceMappingURL=deps.js.map

170

lib/http.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const util = require("util");

@@ -43,4 +44,4 @@ const uri = require("url");

let newHeaders = caseInsensitiveObject();
for (let [k, v] of Object.entries(headers)) {
newHeaders[k] = v;
for (let k of Object.keys(headers)) {
newHeaders[k] = headers[k];
}

@@ -107,4 +108,6 @@ return newHeaders;

*/
static async patch(url, options = {}) {
return this.request(url, Object.assign({}, options, { method: 'PATCH' }));
static patch(url, options = {}) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.request(url, Object.assign({}, options, { method: 'PATCH' }));
});
}

@@ -122,4 +125,6 @@ /**

*/
static async delete(url, options = {}) {
return this.request(url, Object.assign({}, options, { method: 'DELETE' }));
static delete(url, options = {}) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.request(url, Object.assign({}, options, { method: 'DELETE' }));
});
}

@@ -141,6 +146,8 @@ /**

}
static async request(url, options = {}) {
let http = new this(url, options);
await http._request();
return http;
static request(url, options = {}) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let http = new this(url, options);
yield http._request();
return http;
});
}

@@ -207,59 +214,65 @@ static defaults(options = {}) {

}
async _request() {
this._debugRequest();
try {
this.response = await this._performRequest();
}
catch (err) {
debug(err);
return this._maybeRetry(err);
}
if (this._shouldParseResponseBody)
await this._parse();
this._debugResponse();
if (this._responseRedirect)
return this._redirect();
if (!this._responseOK) {
throw new HTTPError(this);
}
if (!this.partial)
await this._getNextRange();
_request() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this._debugRequest();
try {
this.response = yield this._performRequest();
}
catch (err) {
debug(err);
return this._maybeRetry(err);
}
if (this._shouldParseResponseBody)
yield this._parse();
this._debugResponse();
if (this._responseRedirect)
return this._redirect();
if (!this._responseOK) {
throw new HTTPError(this);
}
if (!this.partial)
yield this._getNextRange();
});
}
async _redirect() {
if (!this._redirectRetries)
this._redirectRetries = 0;
this._redirectRetries++;
if (this._redirectRetries > 10)
throw new Error(`Redirect loop at ${this.url}`);
if (!this.headers.location)
throw new Error(`Redirect from ${this.url} has no location header`);
const location = this.headers.location;
if (Array.isArray(location)) {
this.url = location[0];
}
else {
this.url = location;
}
await this._request();
_redirect() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!this._redirectRetries)
this._redirectRetries = 0;
this._redirectRetries++;
if (this._redirectRetries > 10)
throw new Error(`Redirect loop at ${this.url}`);
if (!this.headers.location)
throw new Error(`Redirect from ${this.url} has no location header`);
const location = this.headers.location;
if (Array.isArray(location)) {
this.url = location[0];
}
else {
this.url = location;
}
yield this._request();
});
}
async _maybeRetry(err) {
if (!this._errorRetries)
this._errorRetries = 0;
this._errorRetries++;
const allowed = (err) => {
if (this._errorRetries > 5)
return false;
if (!err.code)
return false;
if (err.code === 'ENOTFOUND')
return true;
return require('is-retry-allowed')(err);
};
if (allowed(err)) {
let noise = Math.random() * 100;
await this._wait((1 << this._errorRetries) * 100 + noise);
await this._request();
return;
}
throw err;
_maybeRetry(err) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!this._errorRetries)
this._errorRetries = 0;
this._errorRetries++;
const allowed = (err) => {
if (this._errorRetries > 5)
return false;
if (!err.code)
return false;
if (err.code === 'ENOTFOUND')
return true;
return require('is-retry-allowed')(err);
};
if (allowed(err)) {
let noise = Math.random() * 100;
yield this._wait((1 << this._errorRetries) * 100 + noise);
yield this._request();
return;
}
throw err;
});
}

@@ -297,7 +310,9 @@ _debugRequest() {

}
async _parse() {
this.body = await concat(this.response);
let json = this.response.headers['content-type'] && deps_1.deps.contentType.parse(this.response).type.startsWith('application/json');
if (json)
this.body = JSON.parse(this.body);
_parse() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this.body = yield concat(this.response);
let json = this.response.headers['content-type'] && deps_1.deps.contentType.parse(this.response).type.startsWith('application/json');
if (json)
this.body = JSON.parse(this.body);
});
}

@@ -320,8 +335,10 @@ _parseBody(body) {

}
async _getNextRange() {
const next = this.headers['next-range'];
this.options.headers['range'] = Array.isArray(next) ? next[0] : next;
let prev = this.body;
await this._request();
this.body = prev.concat(this.body);
_getNextRange() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const next = this.headers['next-range'];
this.options.headers['range'] = Array.isArray(next) ? next[0] : next;
let prev = this.body;
yield this._request();
this.body = prev.concat(this.body);
});
}

@@ -367,1 +384,2 @@ _redactedHeaders(headers) {

exports.HTTPError = HTTPError;
//# sourceMappingURL=http.js.map

@@ -62,1 +62,2 @@ "use strict";

exports.default = ProxyUtil;
//# sourceMappingURL=proxy.js.map
{
"name": "http-call",
"description": "make http requests",
"version": "4.0.5",
"version": "4.0.6",
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/heroku/http-call/issues",
"dependencies": {
"content-type": "1.0.4",
"content-type": "^1.0.4",
"debug": "^3.1.0",
"is-retry-allowed": "^1.1.0",
"is-stream": "^1.1.0",
"tslib": "^1.8.1",
"tunnel-agent": "^0.6.0"

@@ -17,13 +18,15 @@ },

"@types/is-stream": "^1.1.0",
"@types/jest": "^21.1.8",
"@types/jest": "^21.1.9",
"@types/nock": "^9.1.0",
"@types/node": "^8.5.1",
"jest": "^21.2.1",
"nock": "^9.1.4",
"remap-istanbul": "^0.9.5",
"rimraf": "^2.6.2",
"@types/node": "^8.5.2",
"del-cli": "^1.1.0",
"jest": "^22.0.4",
"nock": "^9.1.5",
"standard": "^10.0.3",
"ts-jest": "^21.2.4",
"ts-jest": "^22.0.0",
"typescript": "^2.6.2"
},
"engines": {
"node": ">=6.0.0"
},
"files": [

@@ -55,5 +58,4 @@ "lib"

"scripts": {
"coverage": "cat coverage/coverage-final.json | remap-istanbul -o coverage/coverage-final.json && curl -s https://codecov.io/bash | bash",
"precommit": "lint-staged",
"prepare": "rimraf lib && tsc && rimraf 'lib/**/*.test.js' 'lib/**/*.test.d.ts'",
"prepare": "del-cli lib && tsc && del-cli 'lib/**/*.test.js' 'lib/**/*.test.d.ts'",
"pretest": "tsc --sourcemap",

@@ -60,0 +62,0 @@ "test": "jest"

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