Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

got

Package Overview
Dependencies
Maintainers
1
Versions
178
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 9.5.0 to 9.5.1

6

package.json
{
"name": "got",
"version": "9.5.0",
"version": "9.5.1",
"description": "Simplified HTTP requests",

@@ -38,4 +38,4 @@ "license": "MIT",

"@sindresorhus/is": "^0.14.0",
"@szmarczak/http-timer": "^1.1.0",
"cacheable-request": "^5.1.0",
"@szmarczak/http-timer": "^1.1.2",
"cacheable-request": "^6.0.0",
"decompress-response": "^3.3.0",

@@ -42,0 +42,0 @@ "duplexer3": "^0.1.4",

@@ -158,3 +158,3 @@ <div align="center">

*If you provide this option, `got.stream()` will be read-only.*
**Note:** If you provide this option, `got.stream()` will be read-only.

@@ -171,6 +171,6 @@ The body that will be sent with a `POST` request.

**Note:** If you provide this option, `options.headers.cookie` will be overridden.
Cookie support. You don't have to care about parsing or how to store them. [Example.](#cookies)
**Note:** `options.headers.cookie` will be overridden.
###### encoding

@@ -188,8 +188,7 @@

*If you provide this option, `got.stream()` will be read-only.*
**Note:** If you provide this option, `got.stream()` will be read-only.
**Note:** `body` must be a plain object. It will be converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).
If set to `true` and `Content-Type` header is not set, it will be set to `application/x-www-form-urlencoded`.
`body` must be a plain object. It will be converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).
###### json

@@ -200,3 +199,4 @@

*If you use `got.stream()`, this option will be ignored.*
**Note:** If you use `got.stream()`, this option will be ignored.
**Note:** `body` must be a plain object or array and will be stringified.

@@ -207,4 +207,2 @@ If set to `true` and `Content-Type` header is not set, it will be set to `application/json`.

`body` must be a plain object or array and will be stringified.
###### query

@@ -278,3 +276,3 @@

**Note:** By default, it retries *only* on the specified methods, status codes, and on these network errors:
By default, it retries *only* on the specified methods, status codes, and on these network errors:
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.

@@ -371,3 +369,3 @@ - `ECONNRESET`: Connection was forcibly closed by a peer.

**Note**: If you modify the `body` you will need to modify the `content-length` header too, because it has already been computed and assigned.
**Note:** If you modify the `body` you will need to modify the `content-length` header too, because it has already been computed and assigned.

@@ -512,3 +510,3 @@ ###### hooks.beforeRedirect

**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
**Note:** The time is a `number` representing the milliseconds elapsed since the UNIX epoch.

@@ -535,3 +533,3 @@ ##### fromCache

**Note**: Progress events, redirect events and request/response events can also be used with promises.
**Note:** Progress events, redirect events and request/response events can also be used with promises.

@@ -548,3 +546,3 @@ #### got.stream(url, [options])

**Tip**: You can use `request` event to abort request:
**Tip:** You can use `request` event to abort request:

@@ -652,3 +650,3 @@ ```js

*Need more control over the behavior of Got? Check out the [`got.create()`](advanced-creation.md).*
**Tip:** Need more control over the behavior of Got? Check out the [`got.create()`](advanced-creation.md).

@@ -1029,3 +1027,3 @@ #### got.mergeOptions(parentOptions, newOptions)

*Need to merge some instances into a single one? Check out [`got.mergeInstances()`](advanced-creation.md#merging-instances).*
**Tip:** Need to merge some instances into a single one? Check out [`got.mergeInstances()`](advanced-creation.md#merging-instances).

@@ -1050,84 +1048,145 @@ ### Experimental HTTP2 support

| | `got` | `request` | `node-fetch` | `axios` |
|-----------------------|:------------:|:------------:|:------------:|:------------:|
| HTTP/2 support | ❔ | ✖ | ✖ | ✖ |
| Browser support | ✖ | ✖ | ✔* | ✔ |
| Electron support | ✔ | ✖ | ✖ | ✖ |
| Promise API | ✔ | ✔ | ✔ | ✔ |
| Stream API | ✔ | ✔ | Node.js only | ✖ |
| Request cancelation | ✔ | ✖ | ✔ | ✔ |
| RFC compliant caching | ✔ | ✖ | ✖ | ✖ |
| Cookies (out-of-box) | ✔ | ✔ | ✖ | ✖ |
| Follows redirects | ✔ | ✔ | ✔ | ✔ |
| Retries on failure | ✔ | ✖ | ✖ | ✖ |
| Progress events | ✔ | ✖ | ✖ | Browser only |
| Handles gzip/deflate | ✔ | ✔ | ✔ | ✔ |
| Advanced timeouts | ✔ | ✖ | ✖ | ✖ |
| Timings | ✔ | ✔ | ✖ | ✖ |
| Errors with metadata | ✔ | ✖ | ✖ | ✔ |
| JSON mode | ✔ | ✔ | ✖ | ✔ |
| Custom defaults | ✔ | ✔ | ✖ | ✔ |
| Composable | ✔ | ✖ | ✖ | ✖ |
| Hooks | ✔ | ✖ | ✖ | ✔ |
| Issues open | ![][gio] | ![][rio] | ![][nio] | ![][aio] |
| Issues closed | ![][gic] | ![][ric] | ![][nic] | ![][aic] |
| Downloads | ![][gd] | ![][rd] | ![][nd] | ![][ad] |
| Coverage | ![][gc] | ![][rc] | ![][nc] | ![][ac] |
| Build | ![][gb] | ![][rb] | ![][nb] | ![][ab] |
| Bugs | ![][gbg] | ![][rbg] | ![][nbg] | ![][abg] |
| Dependents | ![][gdp] | ![][rdp] | ![][ndp] | ![][adp] |
| Install size | ![][gis] | ![][ris] | ![][nis] | ![][ais] |
| | `got` | [`request`][r0] | [`node-fetch`][n0] | [`axios`][a0] | [`superagent`][s0] |
|-----------------------|:--------------:|:---------------:|:------------------:|:---------------:|:--------------------:|
| HTTP/2 support | ❔ | ✖ | ✖ | ✖ | ✔\*\* |
| Browser support | ✖ | ✖ | ✔\* | ✔ | ✔ |
| Electron support | ✔ | ✖ | ✖ | ✖ | ✖ |
| Promise API | ✔ | ✔ | ✔ | ✔ | ✔ |
| Stream API | ✔ | ✔ | Node.js only | ✖ | ✔ |
| Request cancelation | ✔ | ✖ | ✔ | ✔ | ✔ |
| RFC compliant caching | ✔ | ✖ | ✖ | ✖ | ✖ |
| Cookies (out-of-box) | ✔ | ✔ | ✖ | ✖ | ✖ |
| Follows redirects | ✔ | ✔ | ✔ | ✔ | ✔ |
| Retries on failure | ✔ | ✖ | ✖ | ✖ | ✔ |
| Progress events | ✔ | ✖ | ✖ | Browser only | ✔ |
| Handles gzip/deflate | ✔ | ✔ | ✔ | ✔ | ✔ |
| Advanced timeouts | ✔ | ✖ | ✖ | ✖ | ✖ |
| Timings | ✔ | ✔ | ✖ | ✖ | ✖ |
| Errors with metadata | ✔ | ✖ | ✖ | ✔ | ✖ |
| JSON mode | ✔ | ✔ | ✖ | ✔ | ✔ |
| Custom defaults | ✔ | ✔ | ✖ | ✔ | ✖ |
| Composable | ✔ | ✖ | ✖ | ✖ | ✔ |
| Hooks | ✔ | ✖ | ✖ | ✔ | ✖ |
| Issues open | [![][gio]][g1] | [![][rio]][r1] | [![][nio]][n1] | [![][aio]][a1] | [![][sio]][s1] |
| Issues closed | [![][gic]][g2] | [![][ric]][r2] | [![][nic]][n2] | [![][aic]][a2] | [![][sic]][s2] |
| Downloads | [![][gd]][g3] | [![][rd]][r3] | [![][nd]][n3] | [![][ad]][a3] | [![][sd]][s3] |
| Coverage | [![][gc]][g4] | [![][rc]][r4] | [![][nc]][n4] | [![][ac]][a4] | unknown |
| Build | [![][gb]][g5] | [![][rb]][r5] | [![][nb]][n5] | [![][ab]][a5] | [![][sb]][s5] |
| Bugs | [![][gbg]][g6] | [![][rbg]][r6] | [![][nbg]][n6] | [![][abg]][a6] | [![][sbg]][s6] |
| Dependents | [![][gdp]][g7] | [![][rdp]][r7] | [![][ndp]][n7] | [![][adp]][a7] | [![][sdp]][s7] |
| Install size | [![][gis]][g8] | [![][ris]][r8] | [![][nis]][n8] | [![][ais]][a8] | [![][sis]][s8] |
\* It's almost API compatible with the browser `fetch` API.<br>
\*\* Need to switch the protocol manually.<br>
❔ Experimental support.
<!-- GITHUB -->
[r0]: https://github.com/request/request
[n0]: https://github.com/bitinn/node-fetch
[a0]: https://github.com/axios/axios
[s0]: https://github.com/visionmedia/superagent
<!-- ISSUES OPEN -->
[gio]: https://img.shields.io/github/issues/sindresorhus/got.svg
[rio]: https://img.shields.io/github/issues/request/request.svg
[nio]: https://img.shields.io/github/issues/bitinn/node-fetch.svg
[aio]: https://img.shields.io/github/issues/axios/axios.svg
[gio]: https://badgen.net/github/open-issues/sindresorhus/got?label
[rio]: https://badgen.net/github/open-issues/request/request?label
[nio]: https://badgen.net/github/open-issues/bitinn/node-fetch?label
[aio]: https://badgen.net/github/open-issues/axios/axios?label
[sio]: https://badgen.net/github/open-issues/visionmedia/superagent?label
[g1]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
[r1]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
[n1]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
[a1]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
[s1]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
<!-- ISSUES CLOSED -->
[gic]: https://img.shields.io/github/issues-closed/sindresorhus/got.svg
[ric]: https://img.shields.io/github/issues-closed/request/request.svg
[nic]: https://img.shields.io/github/issues-closed/bitinn/node-fetch.svg
[aic]: https://img.shields.io/github/issues-closed/axios/axios.svg
[gic]: https://badgen.net/github/closed-issues/sindresorhus/got?label
[ric]: https://badgen.net/github/closed-issues/request/request?label
[nic]: https://badgen.net/github/closed-issues/bitinn/node-fetch?label
[aic]: https://badgen.net/github/closed-issues/axios/axios?label
[sic]: https://badgen.net/github/closed-issues/visionmedia/superagent?label
[g2]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
[r2]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
[n2]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
[a2]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
[s2]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
<!-- DOWNLOADS -->
[gd]: https://img.shields.io/npm/dm/got.svg
[rd]: https://img.shields.io/npm/dm/request.svg
[nd]: https://img.shields.io/npm/dm/node-fetch.svg
[ad]: https://img.shields.io/npm/dm/axios.svg
[gd]: https://badgen.net/npm/dm/got?label
[rd]: https://badgen.net/npm/dm/request?label
[nd]: https://badgen.net/npm/dm/node-fetch?label
[ad]: https://badgen.net/npm/dm/axios?label
[sd]: https://badgen.net/npm/dm/superagent?label
[g3]: https://www.npmjs.com/package/got
[r3]: https://www.npmjs.com/package/request
[n3]: https://www.npmjs.com/package/node-fetch
[a3]: https://www.npmjs.com/package/axios
[s3]: https://www.npmjs.com/package/superagent
<!-- COVERAGE -->
[gc]: https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master
[rc]: https://coveralls.io/repos/github/request/request/badge.svg?branch=master
[nc]: https://coveralls.io/repos/github/bitinn/node-fetch/badge.svg?branch=master
[ac]: https://coveralls.io/repos/github/mzabriskie/axios/badge.svg?branch=master
[gc]: https://badgen.net/coveralls/c/github/sindresorhus/got?label
[rc]: https://badgen.net/coveralls/c/github/request/request?label
[nc]: https://badgen.net/coveralls/c/github/bitinn/node-fetch?label
[ac]: https://badgen.net/coveralls/c/github/mzabriskie/axios?label
[g4]: https://coveralls.io/github/sindresorhus/got
[r4]: https://coveralls.io/github/request/request
[n4]: https://coveralls.io/github/bitinn/node-fetch
[a4]: https://coveralls.io/github/mzabriskie/axios
<!-- BUILD -->
[gb]: https://travis-ci.org/sindresorhus/got.svg?branch=master
[rb]: https://travis-ci.org/request/request.svg?branch=master
[nb]: https://travis-ci.org/bitinn/node-fetch.svg?branch=master
[ab]: https://travis-ci.org/axios/axios.svg?branch=master
[gb]: https://badgen.net/travis/sindresorhus/got?label
[rb]: https://badgen.net/travis/request/request?label
[nb]: https://badgen.net/travis/bitinn/node-fetch?label
[ab]: https://badgen.net/travis/axios/axios?label
[sb]: https://badgen.net/travis/visionmedia/superagent?label
[g5]: https://travis-ci.org/sindresorhus/got
[r5]: https://travis-ci.org/request/request
[n5]: https://travis-ci.org/bitinn/node-fetch
[a5]: https://travis-ci.org/axios/axios
[s5]: https://travis-ci.org/visionmedia/superagent
<!-- BUGS -->
[gbg]: https://badgen.net/github/label-issues/sindresorhus/got/bug/open
[rbg]: https://badgen.net/github/label-issues/request/request/Needs%20investigation/open
[nbg]: https://badgen.net/github/label-issues/bitinn/node-fetch/bug/open
[abg]: https://badgen.net/github/label-issues/axios/axios/bug/open
[gbg]: https://badgen.net/github/label-issues/sindresorhus/got/bug/open?label
[rbg]: https://badgen.net/github/label-issues/request/request/Needs%20investigation/open?label
[nbg]: https://badgen.net/github/label-issues/bitinn/node-fetch/bug/open?label
[abg]: https://badgen.net/github/label-issues/axios/axios/bug/open?label
[sbg]: https://badgen.net/github/label-issues/visionmedia/superagent/Bug/open?label
[g6]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
[r6]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A"Needs+investigation"
[n6]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
[a6]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
[s6]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3ABug
<!-- DEPENDENTS -->
[gdp]: https://badgen.net/npm/dependents/got
[rdp]: https://badgen.net/npm/dependents/request
[ndp]: https://badgen.net/npm/dependents/node-fetch
[adp]: https://badgen.net/npm/dependents/axios
[gdp]: https://badgen.net/npm/dependents/got?label
[rdp]: https://badgen.net/npm/dependents/request?label
[ndp]: https://badgen.net/npm/dependents/node-fetch?label
[adp]: https://badgen.net/npm/dependents/axios?label
[sdp]: https://badgen.net/npm/dependents/superagent?label
[g7]: https://www.npmjs.com/package/got?activeTab=dependents
[r7]: https://www.npmjs.com/package/request?activeTab=dependents
[n7]: https://www.npmjs.com/package/node-fetch?activeTab=dependents
[a7]: https://www.npmjs.com/package/axios?activeTab=dependents
[s7]: https://www.npmjs.com/package/visionmedia?activeTab=dependents
<!-- INSTALL SIZE -->
[gis]: https://packagephobia.now.sh/badge?p=got
[ris]: https://packagephobia.now.sh/badge?p=request
[nis]: https://packagephobia.now.sh/badge?p=node-fetch
[ais]: https://packagephobia.now.sh/badge?p=axios
[gis]: https://badgen.net/packagephobia/install/got?label
[ris]: https://badgen.net/packagephobia/install/request?label
[nis]: https://badgen.net/packagephobia/install/node-fetch?label
[ais]: https://badgen.net/packagephobia/install/axios?label
[sis]: https://badgen.net/packagephobia/install/superagent?label
[g8]: https://packagephobia.now.sh/result?p=got
[r8]: https://packagephobia.now.sh/result?p=request
[n8]: https://packagephobia.now.sh/result?p=node-fetch
[a8]: https://packagephobia.now.sh/result?p=axios
[s8]: https://packagephobia.now.sh/result?p=superagent
## Related

@@ -1134,0 +1193,0 @@

@@ -85,7 +85,12 @@ 'use strict';

if (delays.socket !== undefined) {
request.setTimeout(delays.socket, () => {
const socketTimeoutHandler = () => {
timeoutHandler(delays.socket, 'socket');
});
};
cancelers.push(() => request.setTimeout(0));
request.setTimeout(delays.socket, socketTimeoutHandler);
// `request.setTimeout(0)` causes a memory leak.
// We can just remove the listener and forget about the timer - it's unreffed.
// See https://github.com/sindresorhus/got/issues/690
cancelers.push(() => request.removeListener('timeout', socketTimeoutHandler));
}

@@ -92,0 +97,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