Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
1
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 1.0.1 to 1.1.0

26

index.js

@@ -11,2 +11,6 @@ 'use strict';

// extract own options
var encoding = opts.encoding;
delete opts.encoding;
var get = function (url, opts, cb) {

@@ -31,4 +35,2 @@ if (typeof opts === 'function') {

fn.get(arg, function (res) {
var ret = '';
// redirect

@@ -59,12 +61,20 @@ if (res.statusCode < 400 && res.statusCode >= 300 && res.headers.location) {

res.setEncoding('utf8');
res.once('error', cb);
res.on('data', function (data) {
ret += data;
var chunks = [];
var len = 0;
res.on('data', function (chunk) {
chunks.push(chunk);
len += chunk.length;
});
res.once('error', cb);
res.once('end', function () {
var data = Buffer.concat(chunks, len);
res.once('end', function () {
cb(null, ret, res);
if (encoding !== null) {
data = data.toString(encoding || 'utf8');
}
cb(null, data, res);
});

@@ -71,0 +81,0 @@ }).once('error', cb);

{
"name": "got",
"version": "1.0.1",
"version": "1.1.0",
"description": "Simplified HTTP/HTTPS requests",

@@ -5,0 +5,0 @@ "license": "MIT",

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

##### options.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.
##### callback(err, data, response)

@@ -52,0 +59,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