Socket
Socket
Sign inDemoInstall

then-request

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

then-request - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

0

browser.js

@@ -0,0 +0,0 @@ 'use strict';

14

index.js
'use strict';
var assert = require('assert');
var parseUrl = require('url').parse;

@@ -50,13 +49,6 @@ var Promise = require('promise');

var body = options.body ? options.body : new Buffer(0);
if (typeof body === 'string') body = new Buffer(body);
assert(Buffer.isBuffer(body), 'body should be a Buffer or a String');
if (!Object.keys(options.headers).some(function (name) { return name.toLowerCase() === 'content-length'; })) {
options.headers['content-length'] = body.length;
}
var req = module.exports._request(method, url, {
headers: options.headers,
followRedirects: options.followRedirects !== false,
gzip: options.gzip !== false,
followRedirects: true,
gzip: true,
cache: options.cache

@@ -72,3 +64,3 @@ }, function (err, res) {

if (req) {
req.end(body);
req.end(options.body ? options.body : new Buffer(0));
}

@@ -75,0 +67,0 @@ });

@@ -0,0 +0,0 @@ 'use strict';

{
"name": "then-request",
"version": "1.1.0",
"version": "2.0.0",
"description": "A request library that returns promises, inspired by request",

@@ -8,11 +8,11 @@ "keywords": [],

"dependencies": {
"promise": "^6.0.1",
"concat-stream": "^1.4.7",
"qs": "^2.3.3",
"promise": "^5.0.0",
"concat-stream": "^1.4.6",
"qs": "^1.1.0",
"http-response-object": "^1.0.1",
"http-basic": "^1.1.1"
"http-basic": "^2.0.0"
},
"devDependencies": {
"testit": "^1.2.0",
"istanbul": "^0.3.5"
"istanbul": "^0.3.0"
},

@@ -28,2 +28,2 @@ "scripts": {

"license": "MIT"
}
}

@@ -40,8 +40,6 @@ # then-request

- `cache` - only used in node.js (browsers already have their own caches) Can be `'memory'`, `'file'` or your own custom implementaton (see https://github.com/ForbesLindesay/http-basic#implementing-a-cache).
- `followRedirects` - defaults to `true` but can be explicitly set to `false` on node.js to prevent then-request following redirects automatically.
- `gzip` - defaults to `true` but can be explicitly set to `false` on node.js to prevent then-request automatically supporting the gzip encoding on responses.
**Callback / Returns:**
If a callback is provided it is called with `err` and `res`. If no callback is provided, a [Promise](https://www.promisejs.org/) is returned that eventually resolves to `res`. The resulting Promise also has an additional `.getBody(encoding?)` method that is equivallent to calling `.then(function (res) { return res.getBody(encoding?); })`.
If a callback is provided it is called with `err` and `res`. If no callback is provided, a [Promise](https://www.promisejs.org/) is returned that eventually resolves to `res`. The resulting Promise also has an additional `.getBody(encoding?)` method that is equivallent to calling `.then(function (res) { return res.getBody(); })`.

@@ -48,0 +46,0 @@ ### Response

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

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

var test = require('testit');
var Promise = require('promise');

@@ -11,4 +10,2 @@ test('./lib/handle-qs.js', function () {

assert(handleQs('http://example.com/', {}) === 'http://example.com/');
assert(handleQs('http://example.com/?foo=bar', {}) === 'http://example.com/?foo=bar');
assert(handleQs('http://example.com/', {foo: 'bar'}) === 'http://example.com/?foo=bar');

@@ -75,26 +72,4 @@ assert(handleQs('http://example.com/', {foo: {bar: 'baz'}}) === 'http://example.com/?foo%5Bbar%5D=baz');

});
test(env + ' - Callbacks', function () {
return new Promise(function (resolve, reject) {
return request('GET', 'http://example.com', function (err, res) {
if (err) return reject(err);
assert(res.statusCode === 200);
assert(res.headers['foo'] === 'bar');
assert(res.body.toString() === 'body');
resolve(null);
});
});
});
test(env + ' - Callbacks', function () {
return new Promise(function (resolve, reject) {
return request('GET', 'http://example.com', {}, function (err, res) {
if (err) return reject(err);
assert(res.statusCode === 200);
assert(res.headers['foo'] === 'bar');
assert(res.body.toString() === 'body');
resolve(null);
});
});
});
}
testEnv('browser');
testEnv('server');

@@ -0,0 +0,0 @@ 'use strict';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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