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

request

Package Overview
Dependencies
Maintainers
4
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request - npm Package Compare versions

Comparing version 2.88.0 to 2.88.2

2

index.js

@@ -30,3 +30,3 @@ // Copyright 2010-2012 Mikeal Rogers

var params = {}
if (typeof options === 'object') {
if (options !== null && typeof options === 'object') {
extend(params, options, {uri: uri})

@@ -33,0 +33,0 @@ } else if (typeof uri === 'string') {

@@ -65,3 +65,3 @@ 'use strict'

var re = /([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi
for (;;) {
while (true) {
var match = re.exec(authHeader)

@@ -68,0 +68,0 @@ if (!match) {

@@ -43,3 +43,3 @@ 'use strict'

// environmental variables (NO_PROXY, HTTP_PROXY, etc.)
// respect NO_PROXY environment variables (see: http://lynx.isc.org/current/breakout/lynx_help/keystrokes/environments.html)
// respect NO_PROXY environment variables (see: https://lynx.invisible-island.net/lynx2.8.7/breakout/lynx_help/keystrokes/environments.html)

@@ -46,0 +46,0 @@ var noProxy = process.env.NO_PROXY || process.env.no_proxy || ''

@@ -175,3 +175,3 @@ 'use strict'

if (!param.fileName && !param.fileName && !param.contentType) {
if (!param.fileName && !param.contentType) {
options.formData[param.name] = param.value

@@ -178,0 +178,0 @@ return

@@ -10,3 +10,3 @@ {

],
"version": "2.88.0",
"version": "2.88.2",
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>",

@@ -22,3 +22,3 @@ "repository": {

"engines": {
"node": ">= 4"
"node": ">= 6"
},

@@ -39,3 +39,3 @@ "main": "index.js",

"form-data": "~2.3.2",
"har-validator": "~5.1.0",
"har-validator": "~5.1.3",
"http-signature": "~1.2.0",

@@ -50,3 +50,3 @@ "is-typedarray": "~1.0.0",

"safe-buffer": "^5.1.2",
"tough-cookie": "~2.4.3",
"tough-cookie": "~2.5.0",
"tunnel-agent": "^0.6.0",

@@ -58,3 +58,3 @@ "uuid": "^3.3.2"

"test-ci": "taper tests/test-*.js",
"test-cov": "istanbul cover tape tests/test-*.js",
"test-cov": "nyc --reporter=lcov tape tests/test-*.js",
"test-browser": "node tests/browser/start.js",

@@ -71,3 +71,2 @@ "lint": "standard"

"function-bind": "^1.0.2",
"istanbul": "^0.4.0",
"karma": "^3.0.0",

@@ -79,2 +78,3 @@ "karma-browserify": "^5.0.1",

"karma-tap": "^3.0.1",
"nyc": "^14.1.1",
"phantomjs-prebuilt": "^2.1.3",

@@ -81,0 +81,0 @@ "rimraf": "^2.2.8",

@@ -0,2 +1,8 @@

# Deprecated!
As of Feb 11th 2020, request is fully deprecated. No new changes are expected land. In fact, none have landed for some time.
For more information about why request is deprecated and possible alternatives refer to
[this issue](https://github.com/request/request/issues/3142).
# Request - Simplified HTTP client

@@ -19,5 +25,5 @@

```js
var request = require('request');
const request = require('request');
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.error('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received

@@ -90,3 +96,3 @@ console.log('body:', body); // Print the HTML for the Google homepage.

.on('error', function(err) {
console.log(err)
console.error(err)
})

@@ -115,3 +121,3 @@ .pipe(fs.createWriteStream('doodle.png'))

if (req.url === '/doodle.png') {
var x = request('http://mysite.com/doodle.png')
const x = request('http://mysite.com/doodle.png')
req.pipe(x)

@@ -132,3 +138,3 @@ x.pipe(resp)

```js
var r = request.defaults({'proxy':'http://localproxy.com'})
const r = request.defaults({'proxy':'http://localproxy.com'})

@@ -159,3 +165,5 @@ http.createServer(function (req, resp) {

Also, [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original), which is available from Node.js v8.0 can be used to convert a regular function that takes a callback to return a promise instead.
[back to top](#table-of-contents)

@@ -191,3 +199,3 @@

```js
var formData = {
const formData = {
// Pass a simple key-value pair

@@ -227,4 +235,4 @@ my_field: 'my_value',

// NOTE: Advanced use-case, for normal use see 'formData' usage above
var r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {...})
var form = r.form();
const r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {...})
const form = r.form();
form.append('my_field', 'my_value');

@@ -324,7 +332,7 @@ form.append('my_buffer', Buffer.from([1, 2, 3]));

```js
var username = 'username',
const username = 'username',
password = 'password',
url = 'http://' + username + ':' + password + '@some.server.com';
request({url: url}, function (error, response, body) {
request({url}, function (error, response, body) {
// Do more stuff with 'body' here

@@ -358,5 +366,5 @@ });

```js
var request = require('request');
const request = require('request');
var options = {
const options = {
url: 'https://api.github.com/repos/request/request',

@@ -370,3 +378,3 @@ headers: {

if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
const info = JSON.parse(body);
console.log(info.stargazers_count + " Stars");

@@ -395,3 +403,3 @@ console.log(info.forks_count + " Forks");

// step 1
var qs = require('querystring')
const qs = require('querystring')
, oauth =

@@ -411,4 +419,4 @@ { callback: 'http://mysite.com/callback/'

// step 2
var req_data = qs.parse(body)
var uri = 'https://api.twitter.com/oauth/authenticate'
const req_data = qs.parse(body)
const uri = 'https://api.twitter.com/oauth/authenticate'
+ '?' + qs.stringify({oauth_token: req_data.oauth_token})

@@ -419,3 +427,3 @@ // redirect the user to the authorize uri

// after the user is redirected back to your server
var auth_data = qs.parse(body)
const auth_data = qs.parse(body)
, oauth =

@@ -432,3 +440,3 @@ { consumer_key: CONSUMER_KEY

// ready to make signed requests on behalf of the user
var perm_data = qs.parse(body)
const perm_data = qs.parse(body)
, oauth =

@@ -622,3 +630,3 @@ { consumer_key: CONSUMER_KEY

```js
var fs = require('fs')
const fs = require('fs')
, path = require('path')

@@ -630,3 +638,3 @@ , certFile = path.resolve(__dirname, 'ssl/client.crt')

var options = {
const options = {
url: 'https://api.some-server.com/',

@@ -648,3 +656,3 @@ cert: fs.readFileSync(certFile),

```js
var fs = require('fs')
const fs = require('fs')
, path = require('path')

@@ -655,3 +663,3 @@ , certFile = path.resolve(__dirname, 'ssl/client.crt')

var options = {
const options = {
url: 'https://api.some-server.com/',

@@ -696,2 +704,21 @@ agentOptions: {

The `ca` value can be an array of certificates, in the event you have a private or internal corporate public-key infrastructure hierarchy. For example, if you want to connect to https://api.some-server.com which presents a key chain consisting of:
1. its own public key, which is signed by:
2. an intermediate "Corp Issuing Server", that is in turn signed by:
3. a root CA "Corp Root CA";
you can configure your request as follows:
```js
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
ca: [
fs.readFileSync('Corp Issuing Server.pem'),
fs.readFileSync('Corp Root CA.pem')
]
}
});
```
[back to top](#table-of-contents)

@@ -709,3 +736,3 @@

```js
var request = require('request')
const request = require('request')
request({

@@ -825,7 +852,5 @@ // will be ignored

property outside of the loop.
- `timeout` - integer containing the number of milliseconds to wait for a
server to send response headers (and start the response body) before aborting
the request. Note that if the underlying TCP connection cannot be established,
the OS-wide TCP connection timeout will overrule the `timeout` option ([the
default in Linux can be anywhere from 20-120 seconds][linux-timeout]).
- `timeout` - integer containing number of milliseconds, controls two timeouts.
- **Read timeout**: Time to wait for a server to send response headers (and start the response body) before aborting the request.
- **Connection timeout**: Sets the socket to timeout after `timeout` milliseconds of inactivity. Note that increasing the timeout beyond the OS-wide TCP connection timeout will not have any effect ([the default in Linux can be anywhere from 20-120 seconds][linux-timeout])

@@ -871,3 +896,3 @@ [linux-timeout]: http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout

- `har` - a [HAR 1.2 Request Object](http://www.softwareishard.com/blog/har-12-spec/#request), will be processed from HAR format into options overwriting matching values *(see the [HAR 1.2 section](#support-for-har-1.2) for details)*
- `har` - a [HAR 1.2 Request Object](http://www.softwareishard.com/blog/har-12-spec/#request), will be processed from HAR format into options overwriting matching values *(see the [HAR 1.2 section](#support-for-har-12) for details)*
- `callback` - alternatively pass the request's callback in the options object

@@ -905,3 +930,3 @@

//requests using baseRequest() will set the 'x-token' header
var baseRequest = request.defaults({
const baseRequest = request.defaults({
headers: {'x-token': 'my-token'}

@@ -912,3 +937,3 @@ })

//baseRequest and will also include the 'special' header
var specialRequest = baseRequest.defaults({
const specialRequest = baseRequest.defaults({
headers: {special: 'special value'}

@@ -945,2 +970,13 @@ })

### response.caseless.get('header-name')
Function that returns the specified response header field using a [case-insensitive match](https://tools.ietf.org/html/rfc7230#section-3.2)
```js
request('http://www.google.com', function (error, response, body) {
// print the Content-Type header even if the server returned it as 'content-type' (lowercase)
console.log('Content-Type is:', response.caseless.get('Content-Type'));
});
```
[back to top](#table-of-contents)

@@ -1003,3 +1039,3 @@

```js
var request = require('request')
const request = require('request')
, rand = Math.floor(Math.random()*100000000).toString()

@@ -1035,3 +1071,3 @@ ;

```js
var request = require('request')
const request = require('request')
request(

@@ -1064,3 +1100,3 @@ { method: 'GET'

```js
var request = request.defaults({jar: true})
const request = request.defaults({jar: true})
request('http://www.google.com', function () {

@@ -1074,4 +1110,4 @@ request('http://images.google.com')

```js
var j = request.jar()
var request = request.defaults({jar:j})
const j = request.jar()
const request = request.defaults({jar:j})
request('http://www.google.com', function () {

@@ -1085,5 +1121,5 @@ request('http://images.google.com')

```js
var j = request.jar();
var cookie = request.cookie('key1=value1');
var url = 'http://www.google.com';
const j = request.jar();
const cookie = request.cookie('key1=value1');
const url = 'http://www.google.com';
j.setCookie(cookie, url);

@@ -1101,5 +1137,5 @@ request({url: url, jar: j}, function () {

```js
var FileCookieStore = require('tough-cookie-filestore');
const FileCookieStore = require('tough-cookie-filestore');
// NOTE - currently the 'cookies.json' file must already exist!
var j = request.jar(new FileCookieStore('cookies.json'));
const j = request.jar(new FileCookieStore('cookies.json'));
request = request.defaults({ jar : j })

@@ -1114,3 +1150,3 @@ request('http://www.google.com', function() {

store and it must support synchronous operations; see the
[`CookieStore` API docs](https://github.com/SalesforceEng/tough-cookie#cookiestore-api)
[`CookieStore` API docs](https://github.com/SalesforceEng/tough-cookie#api)
for details.

@@ -1121,6 +1157,6 @@

```js
var j = request.jar()
const j = request.jar()
request({url: 'http://www.google.com', jar: j}, function () {
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
var cookies = j.getCookies(url);
const cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
const cookies = j.getCookies(url);
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]

@@ -1127,0 +1163,0 @@ })

@@ -831,4 +831,3 @@ 'use strict'

socket.removeListener('connect', onReqSockConnect)
clearTimeout(self.timeoutTimer)
self.timeoutTimer = null
self.clearTimeout()
setReqTimeout()

@@ -878,6 +877,3 @@ }

}
if (self.timeout && self.timeoutTimer) {
clearTimeout(self.timeoutTimer)
self.timeoutTimer = null
}
self.clearTimeout()
self.emit('error', error)

@@ -969,6 +965,3 @@ }

}
if (self.timeout && self.timeoutTimer) {
clearTimeout(self.timeoutTimer)
self.timeoutTimer = null
}
self.clearTimeout()

@@ -1178,2 +1171,3 @@ var targetCookieJar = (self._jar && self._jar.setCookie) ? self._jar : globalCookieJar

self.clearTimeout()
self.emit('abort')

@@ -1455,3 +1449,3 @@ }

} else {
var targetCookieJar = (jar && jar.getCookieString) ? jar : globalCookieJar
var targetCookieJar = jar.getCookieString ? jar : globalCookieJar
var urihref = self.uri.href

@@ -1540,2 +1534,3 @@ // fetch cookie in the Specified host

var self = this
this.clearTimeout()
if (!self._ended) {

@@ -1548,2 +1543,9 @@ self.end()

Request.prototype.clearTimeout = function () {
if (this.timeoutTimer) {
clearTimeout(this.timeoutTimer)
this.timeoutTimer = null
}
}
Request.defaultProxyHeaderWhiteList =

@@ -1550,0 +1552,0 @@ Tunnel.defaultProxyHeaderWhiteList.slice()

Sorry, the diff of this file is too big to display

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