Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
2
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 2.8.1 to 2.9.0

25

index.js

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

var zlib = require('zlib');
var querystring = require('querystring');
var objectAssign = require('object-assign');

@@ -28,7 +29,9 @@ var infinityAgent = require('infinity-agent');

function got(url, opts, cb) {
if (typeof url !== 'string' && !(url instanceof Object)) {
throw new GotError('Parameter \'url\' must be a string or object, not ' + typeof url);
}
if (typeof opts === 'function') {
cb = opts;
opts = {};
} else if (!opts) {
opts = {};
}

@@ -72,7 +75,13 @@

if (body && !(typeof body === 'string' || body instanceof Buffer || isStream.readable(body))) {
throw new GotError('options.body must be a ReadableStream, string or Buffer');
}
function get(url, opts, cb) {
var parsedUrl = urlLib.parse(prependHttp(url));
var parsedUrl = typeof url === 'string' ? urlLib.parse(prependHttp(url)) : url;
var fn = parsedUrl.protocol === 'https:' ? https : http;
var arg = objectAssign({}, parsedUrl, opts);
url = typeof url === 'string' ? prependHttp(url) : urlLib.format(url);
if (arg.agent === undefined) {

@@ -94,2 +103,6 @@ arg.agent = infinityAgent[fn === https ? 'https' : 'http'].globalAgent;

if (opts.query) {
arg.path = (arg.path ? arg.path.split('?')[0] : '') + '?' + (typeof opts.query === 'string' ? opts.query : querystring.stringify(opts.query));
}
var req = fn.request(arg, function (response) {

@@ -117,5 +130,3 @@ var statusCode = response.statusCode;

if (['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) {
var unzip = zlib.createUnzip();
res.pipe(unzip);
res = unzip;
res = res.pipe(zlib.createUnzip());
}

@@ -215,3 +226,3 @@

cb = opts;
opts = undefined;
opts = {};
}

@@ -218,0 +229,0 @@

{
"name": "got",
"version": "2.8.1",
"version": "2.9.0",
"description": "Simplified HTTP/HTTPS requests",

@@ -39,3 +39,6 @@ "license": "MIT",

"utility",
"simple"
"simple",
"curl",
"wget",
"fetch"
],

@@ -42,0 +45,0 @@ "dependencies": {

@@ -7,3 +7,3 @@ # got [![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got)

It also supports following redirects, streams, and automagically handling gzip/deflate.
It supports following redirects, streams, automagically handling gzip/deflate and some convenience options.

@@ -15,3 +15,3 @@ Created because [`request`](https://github.com/mikeal/request) is bloated *(several megabytes!)* and slow.

```sh
```
$ npm install --save got

@@ -49,5 +49,5 @@ ```

*Required*
Type: `string`
Type: `string`, `Object`
The URL to request.
The URL to request or bare [http.request options](https://nodejs.org/api/http.html#http_http_request_options_callback) object.

@@ -60,11 +60,4 @@ ##### options

##### options.encoding
###### body
Type: `string`, `null`
Default: `'utf8'`
Encoding to be used on `setEncoding` of the response data. If null, the body is returned as a Buffer.
##### options.body
Type: `string`, `Buffer`, `ReadableStream`

@@ -76,4 +69,11 @@

##### options.json
###### encoding
Type: `string`, `null`
Default: `'utf8'`
Encoding to be used on `setEncoding` of the response data. If null, the body is returned as a Buffer.
###### json
Type: `Boolean`

@@ -86,4 +86,10 @@ Default: `false`

##### options.timeout
###### query
Type: `string`, `Object`
Query string object, that will be added to request url. This will override query string in `url`.
###### timeout
Type: `number`

@@ -93,3 +99,3 @@

##### options.agent
###### agent

@@ -172,4 +178,5 @@ [http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) instance.

## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
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