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.1 to 8.0.2

errors.js

141

index.js

@@ -28,2 +28,3 @@ 'use strict';

const pkg = require('./package.json');
const errors = require('./errors');

@@ -230,29 +231,31 @@ const getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]);

req.connection.once('connect', () => {
const uploadEventFrequency = 150;
if (req.connection) {
req.connection.once('connect', () => {
const uploadEventFrequency = 150;
progressInterval = setInterval(() => {
const lastUploaded = uploaded;
const headersSize = Buffer.byteLength(req._header);
uploaded = req.connection.bytesWritten - headersSize;
progressInterval = setInterval(() => {
const lastUploaded = uploaded;
const headersSize = Buffer.byteLength(req._header);
uploaded = req.connection.bytesWritten - headersSize;
// Prevent the known issue of `bytesWritten` being larger than body size
if (uploadBodySize && uploaded > uploadBodySize) {
uploaded = uploadBodySize;
}
// Prevent the known issue of `bytesWritten` being larger than body size
if (uploadBodySize && uploaded > uploadBodySize) {
uploaded = uploadBodySize;
}
// Don't emit events with unchanged progress and
// prevent last event from being emitted, because
// it's emitted when `response` is emitted
if (uploaded === lastUploaded || uploaded === uploadBodySize) {
return;
}
// Don't emit events with unchanged progress and
// prevent last event from being emitted, because
// it's emitted when `response` is emitted
if (uploaded === lastUploaded || uploaded === uploadBodySize) {
return;
}
ee.emit('uploadProgress', {
percent: uploadBodySize ? uploaded / uploadBodySize : 0,
transferred: uploaded,
total: uploadBodySize
});
}, uploadEventFrequency);
});
ee.emit('uploadProgress', {
percent: uploadBodySize ? uploaded / uploadBodySize : 0,
transferred: uploaded,
total: uploadBodySize
});
}, uploadEventFrequency);
});
}
});

@@ -448,2 +451,9 @@

url = url.replace(/^unix:/, 'http://$&');
try {
decodeURI(url);
} catch (err) {
throw new Error('Parameter `url` must contain valid UTF-8 character sequences');
}
url = urlParseLax(url);

@@ -603,87 +613,4 @@ if (url.auth) {

class StdError extends Error {
constructor(message, error, opts) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = 'StdError';
Object.assign(got, errors);
if (!is.undefined(error.code)) {
this.code = error.code;
}
Object.assign(this, {
host: opts.host,
hostname: opts.hostname,
method: opts.method,
path: opts.path,
protocol: opts.protocol,
url: opts.href
});
}
}
got.CacheError = class extends StdError {
constructor(error, opts) {
super(error.message, error, opts);
this.name = 'CacheError';
}
};
got.RequestError = class extends StdError {
constructor(error, opts) {
super(error.message, error, opts);
this.name = 'RequestError';
}
};
got.ReadError = class extends StdError {
constructor(error, opts) {
super(error.message, error, opts);
this.name = 'ReadError';
}
};
got.ParseError = class extends StdError {
constructor(error, statusCode, opts, data) {
super(`${error.message} in "${urlLib.format(opts)}": \n${data.slice(0, 77)}...`, error, opts);
this.name = 'ParseError';
this.statusCode = statusCode;
this.statusMessage = http.STATUS_CODES[this.statusCode];
}
};
got.HTTPError = class extends StdError {
constructor(statusCode, statusMessage, headers, opts) {
if (statusMessage) {
statusMessage = statusMessage.replace(/\r?\n/g, ' ').trim();
} else {
statusMessage = http.STATUS_CODES[statusCode];
}
super(`Response code ${statusCode} (${statusMessage})`, {}, opts);
this.name = 'HTTPError';
this.statusCode = statusCode;
this.statusMessage = statusMessage;
this.headers = headers;
}
};
got.MaxRedirectsError = class extends StdError {
constructor(statusCode, redirectUrls, opts) {
super('Redirected 10 times. Aborting.', {}, opts);
this.name = 'MaxRedirectsError';
this.statusCode = statusCode;
this.statusMessage = http.STATUS_CODES[this.statusCode];
this.redirectUrls = redirectUrls;
}
};
got.UnsupportedProtocolError = class extends StdError {
constructor(opts) {
super(`Unsupported protocol "${opts.protocol}"`, {}, opts);
this.name = 'UnsupportedProtocolError';
}
};
got.CancelError = PCancelable.CancelError;
module.exports = got;
{
"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
}
"name": "got",
"version": "8.0.2",
"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",
"errors.js"
],
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple",
"curl",
"wget",
"fetch",
"net",
"network",
"electron"
],
"dependencies": {
"@sindresorhus/is": "^0.7.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.24.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
}
}

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

When used in Electron, Got will use [`electron.net`](https://electron.atom.io/docs/api/net/) instead of the Node.js `http` module. According to the Electron docs, it should be fully compatible, but it's not entirely. See [#315](https://github.com/sindresorhus/got/issues/315).
When used in Electron, Got will use [`electron.net`](https://electronjs.org/docs/api/net/) instead of the Node.js `http` module. According to the Electron docs, it should be fully compatible, but it's not entirely. See [#315](https://github.com/sindresorhus/got/issues/315).

@@ -343,2 +343,4 @@

Got implements [RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching which works out of the box in memory or is easily pluggable with a wide range of storage adapters. Fresh cache entries are served directly from cache and stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. You can read more about the underlying cache behaviour in the `cacheable-request` [documentation](https://github.com/lukechilds/cacheable-request).
You can use the JavaScript `Map` type as an in memory cache:

@@ -572,6 +574,7 @@

- [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
- [graphql-got](https://github.com/kevva/graphql-got) - Convenience wrapper for got to interact with GraphQL
- [gh-got](https://github.com/sindresorhus/gh-got) - Got convenience wrapper to interact with the GitHub API
- [gl-got](https://github.com/singapore/gl-got) - Got convenience wrapper to interact with the GitLab API
- [travis-got](https://github.com/samverschueren/travis-got) - Got convenience wrapper to interact with the Travis API
- [graphql-got](https://github.com/kevva/graphql-got) - Got convenience wrapper to interact with GraphQL
- [GotQL](https://github.com/khaosdoctor/gotql) - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of strings

@@ -578,0 +581,0 @@

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