Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
4
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 8.0.0 to 8.0.1

59

index.js

@@ -13,3 +13,3 @@ 'use strict';

const intoStream = require('into-stream');
const isStream = require('is-stream');
const is = require('@sindresorhus/is');
const getStream = require('get-stream');

@@ -24,3 +24,2 @@ const timedOut = require('timed-out');

const isURL = require('isurl');
const isPlainObj = require('is-plain-obj');
const PCancelable = require('p-cancelable');

@@ -35,3 +34,3 @@ const pTimeout = require('p-timeout');

const isFormData = body => isStream(body) && typeof body.getBoundary === 'function';
const isFormData = body => is.nodeStream(body) && is.function(body.getBoundary);

@@ -49,3 +48,3 @@ const getBodySize = opts => {

if (typeof body === 'string') {
if (is.string(body)) {
return Buffer.byteLength(body);

@@ -62,3 +61,3 @@ }

if (isStream(body) && Buffer.isBuffer(body._buffer)) {
if (is.nodeStream(body) && is.buffer(body._buffer)) {
return body._buffer.length;

@@ -76,3 +75,3 @@ }

const redirects = [];
const agents = typeof opts.agent === 'object' ? opts.agent : null;
const agents = is.object(opts.agent) ? opts.agent : null;
let retryCount = 0;

@@ -188,3 +187,3 @@ let redirectUrl;

const response = opts.decompress === true &&
typeof decompressResponse === 'function' &&
is.function(decompressResponse) &&
opts.method !== 'HEAD' ? decompressResponse(progressStream) : progressStream;

@@ -315,3 +314,3 @@

if (isStream(opts.body)) {
if (is.nodeStream(opts.body)) {
opts.body.pipe(req);

@@ -326,3 +325,3 @@ opts.body = undefined;

ee.on('response', res => {
const stream = opts.encoding === null ? getStream.buffer(res) : getStream(res, opts);
const stream = is.null(opts.encoding) ? getStream.buffer(res) : getStream(res, opts);

@@ -406,3 +405,3 @@ stream

if (isStream(opts.body)) {
if (is.nodeStream(opts.body)) {
opts.body.pipe(req);

@@ -430,2 +429,6 @@ return;

res.on('error', err => {
proxy.emit('error', new got.ReadError(err, opts));
});
res.pipe(output);

@@ -450,5 +453,5 @@

function normalizeArguments(url, opts) {
if (typeof url !== 'string' && typeof url !== 'object') {
throw new TypeError(`Parameter \`url\` must be a string or object, not ${typeof url}`);
} else if (typeof url === 'string') {
if (!is.string(url) && !is.object(url)) {
throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
} else if (is.string(url)) {
url = url.replace(/^unix:/, 'http://$&');

@@ -480,3 +483,3 @@ url = urlParseLax(url);

for (const key of Object.keys(headers)) {
if (headers[key] === null || headers[key] === undefined) {
if (is.nullOrUndefined(headers[key])) {
delete headers[key];

@@ -494,3 +497,3 @@ }

if (query) {
if (typeof query !== 'string') {
if (!is.string(query)) {
opts.query = querystring.stringify(query);

@@ -503,3 +506,3 @@ }

if (opts.json && opts.headers.accept === undefined) {
if (opts.json && is.undefined(opts.headers.accept)) {
opts.headers.accept = 'application/json';

@@ -509,9 +512,11 @@ }

const body = opts.body;
if (body !== null && body !== undefined) {
if (is.nullOrUndefined(body)) {
opts.method = (opts.method || 'GET').toUpperCase();
} else {
const headers = opts.headers;
if (!isStream(body) && typeof body !== 'string' && !Buffer.isBuffer(body) && !(opts.form || opts.json)) {
if (!is.nodeStream(body) && !is.string(body) && !is.buffer(body) && !(opts.form || opts.json)) {
throw new TypeError('The `body` option must be a stream.Readable, string, Buffer or plain Object');
}
const canBodyBeStringified = isPlainObj(body) || Array.isArray(body);
const canBodyBeStringified = is.plainObject(body) || is.array(body);
if ((opts.form || opts.json) && !canBodyBeStringified) {

@@ -532,4 +537,4 @@ throw new TypeError('The `body` option must be a plain Object or Array when the `form` or `json` option is used');

if (headers['content-length'] === undefined && headers['transfer-encoding'] === undefined && !isStream(body)) {
const length = typeof opts.body === 'string' ? Buffer.byteLength(opts.body) : opts.body.length;
if (is.undefined(headers['content-length']) && is.undefined(headers['transfer-encoding']) && !is.nodeStream(body)) {
const length = is.string(opts.body) ? Buffer.byteLength(opts.body) : opts.body.length;
headers['content-length'] = length;

@@ -540,3 +545,3 @@ }

// see https://github.com/sindresorhus/got/pull/322
if (Buffer.isBuffer(body)) {
if (is.buffer(body)) {
opts.body = intoStream(body);

@@ -547,4 +552,2 @@ opts.body._buffer = body;

opts.method = (opts.method || 'POST').toUpperCase();
} else {
opts.method = (opts.method || 'GET').toUpperCase();
}

@@ -562,3 +565,3 @@

if (typeof opts.retries !== 'function') {
if (!is.function(opts.retries)) {
const retries = opts.retries;

@@ -577,3 +580,3 @@

if (opts.followRedirect === undefined) {
if (is.undefined(opts.followRedirect)) {
opts.followRedirect = true;

@@ -583,3 +586,3 @@ }

if (opts.timeout) {
if (typeof opts.timeout === 'number') {
if (is.number(opts.timeout)) {
opts.gotTimeout = {request: opts.timeout};

@@ -625,3 +628,3 @@ } else {

if (error.code !== undefined) {
if (!is.undefined(error.code)) {
this.code = error.code;

@@ -628,0 +631,0 @@ }

{
"name": "got",
"version": "8.0.0",
"description": "Simplified HTTP requests",
"license": "MIT",
"repository": "sindresorhus/got",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Vsevolod Strukchinsky",
"email": "floatdrop@gmail.com",
"url": "github.com/floatdrop"
},
{
"name": "Alexander Tesfamichael",
"email": "alex.tesfamichael@gmail.com",
"url": "alextes.me"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js"
],
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple",
"curl",
"wget",
"fetch",
"net",
"network",
"electron"
],
"dependencies": {
"cacheable-request": "^2.1.1",
"decompress-response": "^3.3.0",
"duplexer3": "^0.1.4",
"get-stream": "^3.0.0",
"into-stream": "^3.1.0",
"is-plain-obj": "^1.1.0",
"is-retry-allowed": "^1.1.0",
"is-stream": "^1.1.0",
"isurl": "^1.0.0-alpha5",
"lowercase-keys": "^1.0.0",
"mimic-response": "^1.0.0",
"p-cancelable": "^0.3.0",
"p-timeout": "^1.2.0",
"pify": "^3.0.0",
"safe-buffer": "^5.1.1",
"timed-out": "^4.0.1",
"url-parse-lax": "^3.0.0",
"url-to-options": "^1.0.1"
},
"devDependencies": {
"ava": "^0.23.0",
"coveralls": "^3.0.0",
"form-data": "^2.1.1",
"get-port": "^3.0.0",
"nyc": "^11.0.2",
"p-event": "^1.3.0",
"pem": "^1.4.4",
"sinon": "^4.0.0",
"slow-stream": "0.0.4",
"tempfile": "^2.0.0",
"tempy": "^0.2.1",
"universal-url": "1.0.0-alpha",
"xo": "^0.18.0"
},
"ava": {
"concurrency": 4
},
"browser": {
"decompress-response": false,
"electron": false
}
"name": "got",
"version": "8.0.1",
"description": "Simplified HTTP requests",
"license": "MIT",
"repository": "sindresorhus/got",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Vsevolod Strukchinsky",
"email": "floatdrop@gmail.com",
"url": "github.com/floatdrop"
},
{
"name": "Alexander Tesfamichael",
"email": "alex.tesfamichael@gmail.com",
"url": "alextes.me"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js"
],
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple",
"curl",
"wget",
"fetch",
"net",
"network",
"electron"
],
"dependencies": {
"@sindresorhus/is": "^0.6.0",
"cacheable-request": "^2.1.1",
"decompress-response": "^3.3.0",
"duplexer3": "^0.1.4",
"get-stream": "^3.0.0",
"into-stream": "^3.1.0",
"is-retry-allowed": "^1.1.0",
"isurl": "^1.0.0-alpha5",
"lowercase-keys": "^1.0.0",
"mimic-response": "^1.0.0",
"p-cancelable": "^0.3.0",
"p-timeout": "^2.0.1",
"pify": "^3.0.0",
"safe-buffer": "^5.1.1",
"timed-out": "^4.0.1",
"url-parse-lax": "^3.0.0",
"url-to-options": "^1.0.1"
},
"devDependencies": {
"ava": "^0.23.0",
"coveralls": "^3.0.0",
"form-data": "^2.1.1",
"get-port": "^3.0.0",
"nyc": "^11.0.2",
"p-event": "^1.3.0",
"pem": "^1.4.4",
"sinon": "^4.0.0",
"slow-stream": "0.0.4",
"tempfile": "^2.0.0",
"tempy": "^0.2.1",
"universal-url": "1.0.0-alpha",
"xo": "^0.18.0"
},
"ava": {
"concurrency": 4
},
"browser": {
"decompress-response": false,
"electron": false
}
}

@@ -571,2 +571,3 @@ <h1 align="center">

- [gh-got](https://github.com/sindresorhus/gh-got) - Convenience wrapper for interacting with the GitHub API
- [gl-got](https://github.com/singapore/gl-got) - Convenience wrapper for interacting with the GitLab API
- [travis-got](https://github.com/samverschueren/travis-got) - Convenience wrapper for interacting with the Travis API

@@ -573,0 +574,0 @@ - [graphql-got](https://github.com/kevva/graphql-got) - Convenience wrapper for got to interact with GraphQL

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