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

got

Package Overview
Dependencies
Maintainers
3
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 6.3.0 to 6.5.0

29

index.js

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

const nodeStatusCodes = require('node-status-codes');
const isPlainObj = require('is-plain-obj');
const isRetryAllowed = require('is-retry-allowed');

@@ -29,2 +28,3 @@ const pkg = require('./package.json');

let retryCount = 0;
let redirectUrl;

@@ -37,2 +37,6 @@ const get = opts => {

if (redirectUrl) {
res.url = redirectUrl;
}
if (isRedirect(statusCode) && opts.followRedirect && 'location' in res.headers && (opts.method === 'GET' || opts.method === 'HEAD')) {

@@ -46,3 +50,3 @@ res.resume();

const redirectUrl = urlLib.resolve(urlLib.format(opts), res.headers.location);
redirectUrl = urlLib.resolve(urlLib.format(opts), new Buffer(res.headers.location, 'binary').toString());
const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl));

@@ -108,2 +112,3 @@

res.body = data;
res.requestUrl = opts.href || urlLib.resolve(urlLib.format(opts), opts.path);

@@ -197,2 +202,3 @@ if (opts.json && res.body) {

if (typeof url === 'string') {
url = url.replace(/^unix:/, 'http://$&');
url = urlParseLax(url);

@@ -206,3 +212,7 @@

opts = Object.assign(
{protocol: 'http:', path: '', retries: 5},
{
protocol: 'http:',
path: '',
retries: 5
},
url,

@@ -235,3 +245,3 @@ opts

if (body) {
if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream(body) && !isPlainObj(body)) {
if (typeof body !== 'string' && !(body !== null && typeof body === 'object')) {
throw new Error('options.body must be a ReadableStream, string, Buffer or plain Object');

@@ -242,3 +252,6 @@ }

if (isPlainObj(body)) {
if (isStream(body) && typeof body.getBoundary === 'function') {
// Special case for https://github.com/form-data/form-data
opts.headers['content-type'] = opts.headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`;
} else if (body !== null && typeof body === 'object' && !Buffer.isBuffer(body) && !isStream(body)) {
opts.headers['content-type'] = opts.headers['content-type'] || 'application/x-www-form-urlencoded';

@@ -276,3 +289,3 @@ body = opts.body = querystring.stringify(body);

return (1 << iter) * 1000 + noise;
return ((1 << iter) * 1000) + noise;
};

@@ -291,4 +304,4 @@ }

return asPromise(normalizeArguments(url, opts));
} catch (error) {
return Promise.reject(error);
} catch (err) {
return Promise.reject(err);
}

@@ -295,0 +308,0 @@ }

{
"name": "got",
"version": "6.3.0",
"version": "6.5.0",
"description": "Simplified HTTP requests",

@@ -50,4 +50,3 @@ "license": "MIT",

"duplexer3": "^0.1.4",
"get-stream": "^1.1.0",
"is-plain-obj": "^1.0.0",
"get-stream": "^2.3.0",
"is-redirect": "^1.0.0",

@@ -59,11 +58,13 @@ "is-retry-allowed": "^1.0.0",

"timed-out": "^2.0.0",
"unzip-response": "^1.0.0",
"unzip-response": "^2.0.1",
"url-parse-lax": "^1.0.0"
},
"devDependencies": {
"ava": "^0.13.0",
"ava": "^0.16.0",
"coveralls": "^2.11.4",
"form-data": "^1.0.1",
"get-port": "^2.0.0",
"into-stream": "^2.0.0",
"nyc": "^6.0.0",
"get-stream": "^2.3.0",
"into-stream": "^3.0.0",
"nyc": "^8.1.0",
"pem": "^1.4.4",

@@ -70,0 +71,0 @@ "pify": "^2.3.0",

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

```js
const fs = require('fs');
const got = require('got');

@@ -59,3 +60,3 @@

Returns a Promise, that resolves to `response` object with `body` property.
Returns a Promise for a `response` object with a `body` property, a `url` property with the final URL after redirects, and a `requestUrl` property with the original request URL.

@@ -131,3 +132,3 @@ ##### url

Type: `boolean`
Type: `boolean`<br>
Default: `true`

@@ -238,3 +239,3 @@

You can use the [`form-data`](https://www.npmjs.com/package/form-data) module to create POST request with form data:
You can use the [`form-data`](https://github.com/form-data/form-data) module to create POST request with form data:

@@ -250,3 +251,2 @@ ```js

got.post('google.com', {
headers: form.getHeaders(),
body: form

@@ -257,2 +257,32 @@ });

## OAuth
You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create a signed OAuth request:
```js
const got = require('got');
const OAuth = require('oauth-1.0a');
const oauth = OAuth({
consumer: {
public: process.env.CONSUMER_KEY,
secret: process.env.CONSUMER_SECRET
},
signature_method: 'HMAC-SHA1'
});
const token = {
public: process.env.ACCESS_TOKEN,
secret: process.env.ACCESS_TOKEN_SECRET
};
const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
got(url, {
headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),
json: true
});
```
## Unix Domain Sockets

@@ -259,0 +289,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