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

node-pre-gyp

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pre-gyp - npm Package Compare versions

Comparing version 0.5.13 to 0.5.14

node_modules/rc/node_modules/deep-extend/.npmignore

6

CHANGELOG.md
# node-pre-gyp changelog
## 0.5.14
- Finished support for cross building using `--target_platform` option (#82)
- Now skipping binary validation on install if target arch/platform do not match the host.
- Removed multi-arch validing for OS X since it required a FAT node.js binary
## 0.5.13

@@ -4,0 +10,0 @@

22

lib/testbinary.js

@@ -15,7 +15,3 @@ module.exports = exports = testbinary

var options = {}
var shell_cmd;
var arch_names = {
'ia32':'-i386',
'x64':'-x86_64'
}
var shell_cmd = process.execPath;
var package_json = JSON.parse(fs.readFileSync('./package.json'));

@@ -59,9 +55,11 @@ var opts = versioning.evaluate(package_json, gyp.opts);

}
if (process.platform === 'darwin' && arch_names[opts.target_arch]) {
shell_cmd = 'arch';
args.push(arch_names[opts.target_arch]);
args.push(process.execPath);
} else if (process.arch == opts.target_arch) {
shell_cmd = process.execPath;
} else return callback();
if ((process.arch != opts.target_arch) ||
(process.platform != opts.target_platform)) {
var msg = "skipping validation since host platform/arch (";
msg += process.platform+'/'+process.arch+")";
msg += " does not match target (";
msg += opts.target_platform+'/'+opts.target_arch+")";
log.info('validate', msg);
return callback();
}
args.push('--eval');

@@ -68,0 +66,0 @@ args.push("require('" + binary_module +"')");

@@ -136,2 +136,3 @@

, platform: options.target_platform || process.platform
, target_platform: options.target_platform || process.platform
, arch: options.target_arch || process.arch

@@ -138,0 +139,0 @@ , target_arch: options.target_arch || process.arch

var fs = require('fs')
var ini = require('ini')
var path = require('path')
var stripJsonComments = require('strip-json-comments')

@@ -13,3 +14,3 @@ var parse = exports.parse = function (content, file) {

if((file && /\.json$/.test(file)) || /^\s*{/.test(content))
return JSON.parse(content)
return JSON.parse(stripJsonComments(content))
return ini.parse(content)

@@ -16,0 +17,0 @@

@@ -47,3 +47,3 @@ /*!

var key, val, src, clone;
var key, val, src, clone, tmpBuf;

@@ -64,2 +64,7 @@ args.forEach(function (obj) {

continue;
} else if (val instanceof Buffer) {
tmpBuf = new Buffer(val.length);
val.copy(tmpBuf);
target[key] = tmpBuf;
continue;
}

@@ -66,0 +71,0 @@

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.2.8",
"version": "0.2.10",
"homepage": "https://github.com/unclechu/node-deep-extend",

@@ -17,2 +17,8 @@ "repository": {

},
"contributors": [
{
"name": "Romain Prieto",
"url": "https://github.com/rprieto"
}
],
"main": "index",

@@ -22,2 +28,12 @@ "engines": {

},
"scripts": {
"test": "mocha"
},
"devDependencies": {
"mocha": "~1.19.0",
"should": "~3.3.2"
},
"directories": {
"test": "./test"
},
"readme": "Node.JS module “Deep Extend”\r\n============================\r\n\r\nRecursive object extending.\r\n\r\nInstall\r\n-----\r\n\r\n npm install deep-extend\r\n\r\nUsage\r\n-----\r\n\r\n var deepExtend = require('deep-extend');\r\n var obj1 = {\r\n a: 1,\r\n b: 2,\r\n d: {\r\n a: 1,\r\n b: [],\r\n c: { test1: 123, test2: 321 }\r\n },\r\n f: 5,\r\n g: 123\r\n };\r\n var obj2 = {\r\n b: 3,\r\n c: 5,\r\n d: {\r\n b: { first: 'one', second: 'two' },\r\n c: { test2: 222 }\r\n },\r\n e: { one: 1, two: 2 },\r\n f: [],\r\n g: (void 0)\r\n };\r\n\r\n deepExtend(obj1, obj2);\r\n\r\n console.log(obj1);\r\n /*\r\n { a: 1,\r\n b: 3,\r\n d:\r\n { a: 1,\r\n b: { first: 'one', second: 'two' },\r\n c: { test1: 123, test2: 222 } },\r\n f: [],\r\n c: 5,\r\n e: { one: 1, two: 2 },\r\n g: undefined }\r\n */\r\n",

@@ -28,6 +44,6 @@ "readmeFilename": "README.md",

},
"_id": "deep-extend@0.2.8",
"_shasum": "6d2893a805286e46d8243137c32fb991b50f4299",
"_id": "deep-extend@0.2.10",
"_shasum": "8dd87f56835e91a7da57d07f3c5472165cf5d467",
"_from": "deep-extend@~0.2.5",
"_resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.8.tgz"
"_resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.10.tgz"
}
{
"name": "rc",
"version": "0.3.5",
"version": "0.4.0",
"description": "hardwired configuration loader",

@@ -36,5 +36,6 @@ "main": "index.js",

"deep-extend": "~0.2.5",
"strip-json-comments": "0.1.x",
"ini": "~1.1.0"
},
"readme": "# rc\n\nThe non-configurable configuration loader for lazy people.\n\n## Usage\n\nThe only option is to pass rc the name of your app, and your default configuration.\n\n```javascript\nvar conf = require('rc')(appname, {\n //defaults go here.\n port: 2468,\n\n //defaults which are objects will be merged, not replaced\n views: {\n engine: 'jade'\n }\n});\n```\n\n`rc` will return your configuration options merged with the defaults you specify.\nIf you pass in a predefined defaults object, it will be mutated:\n\n```javascript\nvar conf = {};\nrequire('rc')(appname, conf);\n```\n\n\n## Standards\n\nGiven your application name (`appname`), rc will look in all the obvious places for configuration.\n\n * command line arguments (parsed by minimist)\n * environment variables prefixed with `${appname}_`\n * if you passed an option `--config file` then from that file\n * a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc.\n * `$HOME/.${appname}rc`\n * `$HOME/.${appname}/config`\n * `$HOME/.config/${appname}`\n * `$HOME/.config/${appname}/config`\n * `/etc/${appname}rc`\n * `/etc/${appname}/config`\n * the defaults object you passed in.\n\nAll configuration sources that were found will be flattened into one object,\nso that sources **earlier** in this list override later ones.\n\n\n## Configuration File Formats\n\nConfiguration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. rc ignores file extensions of configuration files. The example configurations below are equivalent:\n\n\n#### Formatted as `ini`\n\n```\n; You can include comments in `ini` format if you want.\n\ndependsOn=0.10.0\n\n\n; `rc` has built-in support for ini sections, see?\n\n[commands]\n www = ./commands/www\n console = ./commands/repl\n\n\n; You can even do nested sections\n\n[generators.options]\n engine = ejs\n\n[generators.modules]\n new = generate-new\n engine = generate-backend\n\n```\n\n#### Formatted as `json`\n\n```json\n{\n \"dependsOn\": \"0.10.0\",\n \"commands\": {\n \"www\": \"./commands/www\",\n \"console\": \"./commands/repl\"\n },\n \"generators\": {\n \"options\": {\n \"engine\": \"ejs\"\n },\n \"modules\": {\n \"new\": \"generate-new\",\n \"backend\": \"generate-backend\"\n }\n }\n}\n```\n\n\n> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.\n\n\n\n## Advanced Usage\n\n#### Pass in your own `argv`\n\nYou may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12).\n\n```javascript\nrequire('rc')(appname, defaults, customArgvParser);\n```\n\n\n## Note on Performance\n\n`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler) \n\n\n## License\n\nBSD / MIT / Apache2\n",
"readme": "# rc\n\nThe non-configurable configuration loader for lazy people.\n\n## Usage\n\nThe only option is to pass rc the name of your app, and your default configuration.\n\n```javascript\nvar conf = require('rc')(appname, {\n //defaults go here.\n port: 2468,\n\n //defaults which are objects will be merged, not replaced\n views: {\n engine: 'jade'\n }\n});\n```\n\n`rc` will return your configuration options merged with the defaults you specify.\nIf you pass in a predefined defaults object, it will be mutated:\n\n```javascript\nvar conf = {};\nrequire('rc')(appname, conf);\n```\n\n\n## Standards\n\nGiven your application name (`appname`), rc will look in all the obvious places for configuration.\n\n * command line arguments (parsed by minimist)\n * environment variables prefixed with `${appname}_`\n * if you passed an option `--config file` then from that file\n * a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc.\n * `$HOME/.${appname}rc`\n * `$HOME/.${appname}/config`\n * `$HOME/.config/${appname}`\n * `$HOME/.config/${appname}/config`\n * `/etc/${appname}rc`\n * `/etc/${appname}/config`\n * the defaults object you passed in.\n\nAll configuration sources that were found will be flattened into one object,\nso that sources **earlier** in this list override later ones.\n\n\n## Configuration File Formats\n\nConfiguration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. The example configurations below are equivalent:\n\n\n#### Formatted as `ini`\n\n```\n; You can include comments in `ini` format if you want.\n\ndependsOn=0.10.0\n\n\n; `rc` has built-in support for ini sections, see?\n\n[commands]\n www = ./commands/www\n console = ./commands/repl\n\n\n; You can even do nested sections\n\n[generators.options]\n engine = ejs\n\n[generators.modules]\n new = generate-new\n engine = generate-backend\n\n```\n\n#### Formatted as `json`\n\n```json\n{\n // You can even comment your JSON, if you want\n \"dependsOn\": \"0.10.0\",\n \"commands\": {\n \"www\": \"./commands/www\",\n \"console\": \"./commands/repl\"\n },\n \"generators\": {\n \"options\": {\n \"engine\": \"ejs\"\n },\n \"modules\": {\n \"new\": \"generate-new\",\n \"backend\": \"generate-backend\"\n }\n }\n}\n```\n\nComments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).\n\n> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.\n\n\n\n## Advanced Usage\n\n#### Pass in your own `argv`\n\nYou may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12).\n\n```javascript\nrequire('rc')(appname, defaults, customArgvParser);\n```\n\n\n## Note on Performance\n\n`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler) \n\n\n## License\n\nBSD / MIT / Apache2\n",
"readmeFilename": "README.md",

@@ -45,6 +46,6 @@ "bugs": {

"homepage": "https://github.com/dominictarr/rc",
"_id": "rc@0.3.5",
"_shasum": "fce2220593be57aa1296685a7e37ed003dfcc728",
"_from": "rc@~0.3.4",
"_resolved": "https://registry.npmjs.org/rc/-/rc-0.3.5.tgz"
"_id": "rc@0.4.0",
"_shasum": "ce24a2029ad94c3a40d09604a87227027d7210d3",
"_from": "rc@~0.4.0",
"_resolved": "https://registry.npmjs.org/rc/-/rc-0.4.0.tgz"
}

@@ -52,3 +52,3 @@ # rc

Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. rc ignores file extensions of configuration files. The example configurations below are equivalent:
Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. The example configurations below are equivalent:

@@ -86,2 +86,3 @@

{
// You can even comment your JSON, if you want
"dependsOn": "0.10.0",

@@ -104,2 +105,3 @@ "commands": {

Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).

@@ -106,0 +108,0 @@ > Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.

@@ -32,1 +32,26 @@

assert.equal(customArgv.envOption, 24)
var fs = require('fs')
var path = require('path')
var jsonrc = path.resolve('.' + n + 'rc');
fs.writeFileSync(jsonrc, [
'{',
'// json overrides default',
'"option": false,',
'/* env overrides json */',
'"envOption": 24',
'}'
].join('\n'));
var commentedJSON = require('../')(n, {
option: true
})
fs.unlinkSync(jsonrc);
console.log(commentedJSON)
assert.equal(commentedJSON.option, false)
assert.equal(commentedJSON.envOption, 42)
assert.equal(commentedJSON.config, jsonrc)

@@ -18,2 +18,3 @@ // Copyright 2010-2012 Mikeal Rogers

, Request = require('./request')
, util = require('util')
;

@@ -25,29 +26,32 @@

function initParams(uri, options, callback) {
var opts;
if ((typeof options === 'function') && !callback) callback = options
if (options && typeof options === 'object') {
options.uri = uri
opts = util._extend({}, options);
opts.uri = uri
} else if (typeof uri === 'string') {
options = {uri:uri}
opts = {uri:uri}
} else {
options = uri
uri = options.uri
opts = util._extend({}, uri);
uri = opts.uri
}
return { uri: uri, options: options, callback: callback }
return { uri: uri, options: opts, callback: callback }
}
function request (uri, options, callback) {
var opts;
if (typeof uri === 'undefined') throw new Error('undefined is not a valid uri or options object.')
if ((typeof options === 'function') && !callback) callback = options
if (options && typeof options === 'object') {
options.uri = uri
opts = util._extend({}, options);
opts.uri = uri
} else if (typeof uri === 'string') {
options = {uri:uri}
opts = {uri:uri}
} else {
options = uri
opts = util._extend({}, uri);
}
options = copy(options)
if (callback) options.callback = callback
var r = new Request(options)
if (callback) opts.callback = callback
var r = new Request(opts)
return r

@@ -114,3 +118,7 @@ }

request.get = request
request.get = function (uri, options, callback) {
var params = initParams(uri, options, callback)
params.options.method = 'GET'
return requester(params)(params.uri || null, params.options, params.callback)
}
request.post = function (uri, options, callback) {

@@ -117,0 +125,0 @@ var params = initParams(uri, options, callback)

@@ -29,3 +29,4 @@ {

"_from": "forever-agent@~0.5.0",
"_resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz"
"_resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz",
"scripts": {}
}

@@ -32,3 +32,4 @@ {

"_from": "delayed-stream@0.0.5",
"_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz"
"_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz",
"scripts": {}
}

@@ -33,3 +33,4 @@ {

"_from": "combined-stream@~0.0.4",
"_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz"
"_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz",
"scripts": {}
}

@@ -21,3 +21,4 @@ {

"_from": "assert-plus@0.1.2",
"_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz"
"_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz",
"scripts": {}
}

@@ -19,3 +19,4 @@ {

"_from": "ctype@0.5.2",
"_resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz"
"_resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz",
"scripts": {}
}

@@ -37,3 +37,4 @@ {

"_from": "mime@~1.2.9",
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz"
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz",
"scripts": {}
}

@@ -36,3 +36,4 @@ {

"_from": "node-uuid@~1.4.0",
"_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz"
"_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz",
"scripts": {}
}

@@ -70,5 +70,14 @@ 'use strict'

TunnelingAgent.prototype.addRequest = function addRequest(req, host, port) {
TunnelingAgent.prototype.addRequest = function addRequest(req, options) {
var self = this
// Legacy API: addRequest(req, host, port, path)
if (typeof options === 'string') {
options = {
host: options,
port: arguments[2],
path: arguments[3]
};
}
if (self.sockets.length >= this.maxSockets) {

@@ -81,3 +90,3 @@ // We are over limit so we'll add it to the queue.

// If we are under maxSockets create a new one.
self.createSocket({host: host, port: port, request: req}, function(socket) {
self.createSocket({host: options.host, port: options.port, request: req}, function(socket) {
socket.on('free', onFree)

@@ -89,3 +98,3 @@ socket.on('close', onCloseOrRemove)

function onFree() {
self.emit('free', socket, host, port)
self.emit('free', socket, options.host, options.port)
}

@@ -92,0 +101,0 @@

@@ -9,3 +9,3 @@ {

"description": "HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.",
"version": "0.3.0",
"version": "0.4.0",
"repository": {

@@ -27,6 +27,6 @@ "url": "https://github.com/mikeal/tunnel-agent"

"homepage": "https://github.com/mikeal/tunnel-agent",
"_id": "tunnel-agent@0.3.0",
"_shasum": "ad681b68f5321ad2827c4cfb1b7d5df2cfe942ee",
"_from": "tunnel-agent@~0.3.0",
"_resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.3.0.tgz"
"_id": "tunnel-agent@0.4.0",
"_shasum": "b1184e312ffbcf70b3b4c78e8c219de7ebb1c550",
"_from": "tunnel-agent@~0.4.0",
"_resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.0.tgz"
}

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

],
"version": "2.34.0",
"version": "2.36.0",
"author": {

@@ -31,8 +31,8 @@ "name": "Mikeal Rogers",

"json-stringify-safe": "~5.0.0",
"mime": "~1.2.9",
"forever-agent": "~0.5.0",
"node-uuid": "~1.4.0",
"mime": "~1.2.9",
"tough-cookie": ">=0.12.0",
"form-data": "~0.1.0",
"tunnel-agent": "~0.3.0",
"tunnel-agent": "~0.4.0",
"http-signature": "~0.10.0",

@@ -46,3 +46,3 @@ "oauth-sign": "~0.3.0",

"form-data": "~0.1.0",
"tunnel-agent": "~0.3.0",
"tunnel-agent": "~0.4.0",
"http-signature": "~0.10.0",

@@ -56,9 +56,9 @@ "oauth-sign": "~0.3.0",

},
"readme": "# Request -- Simplified HTTP client\n\n[![NPM](https://nodei.co/npm/request.png)](https://nodei.co/npm/request/)\n\n## Super simple to use\n\nRequest is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.\n\n```javascript\nvar request = require('request');\nrequest('http://www.google.com', function (error, response, body) {\n if (!error && response.statusCode == 200) {\n console.log(body) // Print the google web page.\n }\n})\n```\n\n## Streaming\n\nYou can stream any response to a file stream.\n\n```javascript\nrequest('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))\n```\n\nYou can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types (in this case `application/json`) and use the proper `content-type` in the PUT request (if the headers don’t already provide one).\n\n```javascript\nfs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))\n```\n\nRequest can also `pipe` to itself. When doing so, `content-type` and `content-length` are preserved in the PUT headers.\n\n```javascript\nrequest.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'))\n```\n\nNow let’s get fancy.\n\n```javascript\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n if (req.method === 'PUT') {\n req.pipe(request.put('http://mysite.com/doodle.png'))\n } else if (req.method === 'GET' || req.method === 'HEAD') {\n request.get('http://mysite.com/doodle.png').pipe(resp)\n }\n }\n})\n```\n\nYou can also `pipe()` from `http.ServerRequest` instances, as well as to `http.ServerResponse` instances. The HTTP method, headers, and entity-body data will be sent. Which means that, if you don't really care about security, you can do:\n\n```javascript\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n var x = request('http://mysite.com/doodle.png')\n req.pipe(x)\n x.pipe(resp)\n }\n})\n```\n\nAnd since `pipe()` returns the destination stream in ≥ Node 0.5.x you can do one line proxying. :)\n\n```javascript\nreq.pipe(request('http://mysite.com/doodle.png')).pipe(resp)\n```\n\nAlso, none of this new functionality conflicts with requests previous features, it just expands them.\n\n```javascript\nvar r = request.defaults({'proxy':'http://localproxy.com'})\n\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n r.get('http://google.com/doodle.png').pipe(resp)\n }\n})\n```\n\nYou can still use intermediate proxies, the requests will still follow HTTP forwards, etc.\n\n## UNIX Socket \n\n`request` supports the `unix://` protocol for all requests. The path is assumed to be absolute to the root of the host file system. \n\nHTTP paths are extracted from the supplied URL by testing each level of the full URL against net.connect for a socket response.\n\nThus the following request will GET `/httppath` from the HTTP server listening on `/tmp/unix.socket`\n\n```javascript\nrequest.get('unix://tmp/unix.socket/httppath')\n```\n\n## Forms\n\n`request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API.\n\nURL-encoded forms are simple.\n\n```javascript\nrequest.post('http://service.com/upload', {form:{key:'value'}})\n// or\nrequest.post('http://service.com/upload').form({key:'value'})\n```\n\nFor `multipart/form-data` we use the [form-data](https://github.com/felixge/node-form-data) library by [@felixge](https://github.com/felixge). You don’t need to worry about piping the form object or setting the headers, `request` will handle that for you.\n\n```javascript\nvar r = request.post('http://service.com/upload')\nvar form = r.form()\nform.append('my_field', 'my_value')\nform.append('my_buffer', new Buffer([1, 2, 3]))\nform.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png'))\nform.append('remote_file', request('http://google.com/doodle.png'))\n```\n\n## HTTP Authentication\n\n```javascript\nrequest.get('http://some.server.com/').auth('username', 'password', false);\n// or\nrequest.get('http://some.server.com/', {\n 'auth': {\n 'user': 'username',\n 'pass': 'password',\n 'sendImmediately': false\n }\n});\n```\n\nIf passed as an option, `auth` should be a hash containing values `user` || `username`, `password` || `pass`, and `sendImmediately` (optional). The method form takes parameters `auth(username, password, sendImmediately)`.\n\n`sendImmediately` defaults to `true`, which causes a basic authentication header to be sent. If `sendImmediately` is `false`, then `request` will retry with a proper authentication header after receiving a `401` response from the server (which must contain a `WWW-Authenticate` header indicating the required authentication method).\n\nDigest authentication is supported, but it only works with `sendImmediately` set to `false`; otherwise `request` will send basic authentication on the initial request, which will probably cause the request to fail.\n\n## OAuth Signing\n\n```javascript\n// Twitter OAuth\nvar qs = require('querystring')\n , oauth =\n { callback: 'http://mysite.com/callback/'\n , consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n }\n , url = 'https://api.twitter.com/oauth/request_token'\n ;\nrequest.post({url:url, oauth:oauth}, function (e, r, body) {\n // Ideally, you would take the body in the response\n // and construct a URL that a user clicks on (like a sign in button).\n // The verifier is only available in the response after a user has\n // verified with twitter that they are authorizing your app.\n var access_token = qs.parse(body)\n , oauth =\n { consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n , token: access_token.oauth_token\n , verifier: access_token.oauth_verifier\n }\n , url = 'https://api.twitter.com/oauth/access_token'\n ;\n request.post({url:url, oauth:oauth}, function (e, r, body) {\n var perm_token = qs.parse(body)\n , oauth =\n { consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n , token: perm_token.oauth_token\n , token_secret: perm_token.oauth_token_secret\n }\n , url = 'https://api.twitter.com/1.1/users/show.json?'\n , params =\n { screen_name: perm_token.screen_name\n , user_id: perm_token.user_id\n }\n ;\n url += qs.stringify(params)\n request.get({url:url, oauth:oauth, json:true}, function (e, r, user) {\n console.log(user)\n })\n })\n})\n```\n\n### Custom HTTP Headers\n\nHTTP Headers, such as `User-Agent`, can be set in the `options` object.\nIn the example below, we call the github API to find out the number\nof stars and forks for the request repository. This requires a\ncustom `User-Agent` header as well as https.\n\n```javascript\nvar request = require('request');\n\nvar options = {\n\turl: 'https://api.github.com/repos/mikeal/request',\n\theaders: {\n\t\t'User-Agent': 'request'\n\t}\n};\n\nfunction callback(error, response, body) {\n\tif (!error && response.statusCode == 200) {\n\t\tvar info = JSON.parse(body);\n\t\tconsole.log(info.stargazers_count + \" Stars\");\n\t\tconsole.log(info.forks_count + \" Forks\");\n\t}\n}\n\nrequest(options, callback);\n```\n\n### request(options, callback)\n\nThe first argument can be either a `url` or an `options` object. The only required option is `uri`; all others are optional.\n\n* `uri` || `url` - fully qualified uri or a parsed url object from `url.parse()`\n* `qs` - object containing querystring values to be appended to the `uri`\n* `method` - http method (default: `\"GET\"`)\n* `headers` - http headers (default: `{}`)\n* `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer` or `String`.\n* `form` - when passed an object, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request).\n* `auth` - A hash containing values `user` || `username`, `password` || `pass`, and `sendImmediately` (optional). See documentation above.\n* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON.\n* `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.\n* `followRedirect` - follow HTTP 3xx responses as redirects (default: `true`)\n* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects (default: `false`)\n* `maxRedirects` - the maximum number of redirects to follow (default: `10`)\n* `encoding` - Encoding to be used on `setEncoding` of response data. If `null`, the `body` is returned as a `Buffer`.\n* `pool` - A hash object containing the agents for these requests. If omitted, the request will use the global pool (which is set to node's default `maxSockets`)\n* `pool.maxSockets` - Integer containing the maximum amount of sockets in the pool.\n* `timeout` - Integer containing the number of milliseconds to wait for a request to respond before aborting the request\n* `proxy` - An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the `url` parameter (by embedding the auth info in the `uri`)\n* `oauth` - Options for OAuth HMAC-SHA1 signing. See documentation above.\n* `hawk` - Options for [Hawk signing](https://github.com/hueniverse/hawk). The `credentials` key must contain the necessary signing info, [see hawk docs for details](https://github.com/hueniverse/hawk#usage-example).\n* `strictSSL` - If `true`, requires SSL certificates be valid. **Note:** to use your own certificate authority, you need to specify an agent that was created with that CA as an option.\n* `jar` - If `true`, remember cookies for future use (or define your custom cookie jar; see examples section)\n* `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`. Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services)\n* `httpSignature` - Options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options.\n* `localAddress` - Local interface to bind for network connections.\n\n\nThe callback argument gets 3 arguments: \n\n1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object)\n2. An [`http.IncomingMessage`](http://nodejs.org/api/http.html#http_http_incomingmessage) object\n3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied)\n\n## Convenience methods\n\nThere are also shorthand methods for different HTTP METHODs and some other conveniences.\n\n### request.defaults(options)\n\nThis method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.\n\n### request.put\n\nSame as `request()`, but defaults to `method: \"PUT\"`.\n\n```javascript\nrequest.put(url)\n```\n\n### request.patch\n\nSame as `request()`, but defaults to `method: \"PATCH\"`.\n\n```javascript\nrequest.patch(url)\n```\n\n### request.post\n\nSame as `request()`, but defaults to `method: \"POST\"`.\n\n```javascript\nrequest.post(url)\n```\n\n### request.head\n\nSame as request() but defaults to `method: \"HEAD\"`.\n\n```javascript\nrequest.head(url)\n```\n\n### request.del\n\nSame as `request()`, but defaults to `method: \"DELETE\"`.\n\n```javascript\nrequest.del(url)\n```\n\n### request.get\n\nSame as `request()` (for uniformity).\n\n```javascript\nrequest.get(url)\n```\n### request.cookie\n\nFunction that creates a new cookie.\n\n```javascript\nrequest.cookie('cookie_string_here')\n```\n### request.jar\n\nFunction that creates a new cookie jar.\n\n```javascript\nrequest.jar()\n```\n\n\n## Examples:\n\n```javascript\n var request = require('request')\n , rand = Math.floor(Math.random()*100000000).toString()\n ;\n request(\n { method: 'PUT'\n , uri: 'http://mikeal.iriscouch.com/testjs/' + rand\n , multipart:\n [ { 'content-type': 'application/json'\n , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})\n }\n , { body: 'I am an attachment' }\n ]\n }\n , function (error, response, body) {\n if(response.statusCode == 201){\n console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)\n } else {\n console.log('error: '+ response.statusCode)\n console.log(body)\n }\n }\n )\n```\n\nCookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set `jar` to `true` (either in `defaults` or `options`).\n\n```javascript\nvar request = request.defaults({jar: true})\nrequest('http://www.google.com', function () {\n request('http://images.google.com')\n})\n```\n\nTo use a custom cookie jar (instead `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`)\n\n```javascript\nvar j = request.jar()\nvar request = request.defaults({jar:j})\nrequest('http://www.google.com', function () {\n request('http://images.google.com')\n})\n```\n\nOR\n\n```javascript\nvar j = request.jar()\nvar cookie = request.cookie('your_cookie_here')\nj.setCookie(cookie, uri);\nrequest({url: 'http://www.google.com', jar: j}, function () {\n request('http://images.google.com')\n})\n```\n",
"readme": "# Request -- Simplified HTTP client\n\n[![NPM](https://nodei.co/npm/request.png)](https://nodei.co/npm/request/)\n\n## Super simple to use\n\nRequest is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.\n\n```javascript\nvar request = require('request');\nrequest('http://www.google.com', function (error, response, body) {\n if (!error && response.statusCode == 200) {\n console.log(body) // Print the google web page.\n }\n})\n```\n\n## Streaming\n\nYou can stream any response to a file stream.\n\n```javascript\nrequest('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))\n```\n\nYou can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types (in this case `application/json`) and use the proper `content-type` in the PUT request (if the headers don’t already provide one).\n\n```javascript\nfs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))\n```\n\nRequest can also `pipe` to itself. When doing so, `content-type` and `content-length` are preserved in the PUT headers.\n\n```javascript\nrequest.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'))\n```\n\nNow let’s get fancy.\n\n```javascript\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n if (req.method === 'PUT') {\n req.pipe(request.put('http://mysite.com/doodle.png'))\n } else if (req.method === 'GET' || req.method === 'HEAD') {\n request.get('http://mysite.com/doodle.png').pipe(resp)\n }\n }\n})\n```\n\nYou can also `pipe()` from `http.ServerRequest` instances, as well as to `http.ServerResponse` instances. The HTTP method, headers, and entity-body data will be sent. Which means that, if you don't really care about security, you can do:\n\n```javascript\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n var x = request('http://mysite.com/doodle.png')\n req.pipe(x)\n x.pipe(resp)\n }\n})\n```\n\nAnd since `pipe()` returns the destination stream in ≥ Node 0.5.x you can do one line proxying. :)\n\n```javascript\nreq.pipe(request('http://mysite.com/doodle.png')).pipe(resp)\n```\n\nAlso, none of this new functionality conflicts with requests previous features, it just expands them.\n\n```javascript\nvar r = request.defaults({'proxy':'http://localproxy.com'})\n\nhttp.createServer(function (req, resp) {\n if (req.url === '/doodle.png') {\n r.get('http://google.com/doodle.png').pipe(resp)\n }\n})\n```\n\nYou can still use intermediate proxies, the requests will still follow HTTP forwards, etc.\n\n## UNIX Socket \n\n`request` supports the `unix://` protocol for all requests. The path is assumed to be absolute to the root of the host file system. \n\nHTTP paths are extracted from the supplied URL by testing each level of the full URL against net.connect for a socket response.\n\nThus the following request will GET `/httppath` from the HTTP server listening on `/tmp/unix.socket`\n\n```javascript\nrequest.get('unix://tmp/unix.socket/httppath')\n```\n\n## Forms\n\n`request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API.\n\nURL-encoded forms are simple.\n\n```javascript\nrequest.post('http://service.com/upload', {form:{key:'value'}})\n// or\nrequest.post('http://service.com/upload').form({key:'value'})\n```\n\nFor `multipart/form-data` we use the [form-data](https://github.com/felixge/node-form-data) library by [@felixge](https://github.com/felixge). You don’t need to worry about piping the form object or setting the headers, `request` will handle that for you.\n\n```javascript\nvar r = request.post('http://service.com/upload', function optionalCallback (err, httpResponse, body) {\n if (err) {\n return console.error('upload failed:', err);\n }\n console.log('Upload successful! Server responded with:', body);\n})\nvar form = r.form()\nform.append('my_field', 'my_value')\nform.append('my_buffer', new Buffer([1, 2, 3]))\nform.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png')))\nform.append('remote_file', request('http://google.com/doodle.png'))\n\n// Just like always, `r` is a writable stream, and can be used as such (you have until nextTick to pipe it, etc.)\n// Alternatively, you can provide a callback (that's what this example does-- see `optionalCallback` above).\n```\n\n## HTTP Authentication\n\n```javascript\nrequest.get('http://some.server.com/').auth('username', 'password', false);\n// or\nrequest.get('http://some.server.com/', {\n 'auth': {\n 'user': 'username',\n 'pass': 'password',\n 'sendImmediately': false\n }\n});\n// or\nrequest.get('http://some.server.com/').auth(null, null, true, 'bearerToken');\n// or\nrequest.get('http://some.server.com/', {\n 'auth': {\n 'bearer': 'bearerToken'\n }\n});\n```\n\nIf passed as an option, `auth` should be a hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). The method form takes parameters `auth(username, password, sendImmediately)`.\n\n`sendImmediately` defaults to `true`, which causes a basic authentication header to be sent. If `sendImmediately` is `false`, then `request` will retry with a proper authentication header after receiving a `401` response from the server (which must contain a `WWW-Authenticate` header indicating the required authentication method).\n\nDigest authentication is supported, but it only works with `sendImmediately` set to `false`; otherwise `request` will send basic authentication on the initial request, which will probably cause the request to fail.\n\nBearer authentication is supported, and is activated when the `bearer` value is available. The value may be either a `String` or a `Function` returning a `String`. Using a function to supply the bearer token is particularly useful if used in conjuction with `defaults` to allow a single function to supply the last known token at the time or sending a request or to compute one on the fly.\n\n## OAuth Signing\n\n```javascript\n// Twitter OAuth\nvar qs = require('querystring')\n , oauth =\n { callback: 'http://mysite.com/callback/'\n , consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n }\n , url = 'https://api.twitter.com/oauth/request_token'\n ;\nrequest.post({url:url, oauth:oauth}, function (e, r, body) {\n // Ideally, you would take the body in the response\n // and construct a URL that a user clicks on (like a sign in button).\n // The verifier is only available in the response after a user has\n // verified with twitter that they are authorizing your app.\n var access_token = qs.parse(body)\n , oauth =\n { consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n , token: access_token.oauth_token\n , verifier: access_token.oauth_verifier\n }\n , url = 'https://api.twitter.com/oauth/access_token'\n ;\n request.post({url:url, oauth:oauth}, function (e, r, body) {\n var perm_token = qs.parse(body)\n , oauth =\n { consumer_key: CONSUMER_KEY\n , consumer_secret: CONSUMER_SECRET\n , token: perm_token.oauth_token\n , token_secret: perm_token.oauth_token_secret\n }\n , url = 'https://api.twitter.com/1.1/users/show.json?'\n , params =\n { screen_name: perm_token.screen_name\n , user_id: perm_token.user_id\n }\n ;\n url += qs.stringify(params)\n request.get({url:url, oauth:oauth, json:true}, function (e, r, user) {\n console.log(user)\n })\n })\n})\n```\n\n### Custom HTTP Headers\n\nHTTP Headers, such as `User-Agent`, can be set in the `options` object.\nIn the example below, we call the github API to find out the number\nof stars and forks for the request repository. This requires a\ncustom `User-Agent` header as well as https.\n\n```javascript\nvar request = require('request');\n\nvar options = {\n\turl: 'https://api.github.com/repos/mikeal/request',\n\theaders: {\n\t\t'User-Agent': 'request'\n\t}\n};\n\nfunction callback(error, response, body) {\n\tif (!error && response.statusCode == 200) {\n\t\tvar info = JSON.parse(body);\n\t\tconsole.log(info.stargazers_count + \" Stars\");\n\t\tconsole.log(info.forks_count + \" Forks\");\n\t}\n}\n\nrequest(options, callback);\n```\n\n### request(options, callback)\n\nThe first argument can be either a `url` or an `options` object. The only required option is `uri`; all others are optional.\n\n* `uri` || `url` - fully qualified uri or a parsed url object from `url.parse()`\n* `qs` - object containing querystring values to be appended to the `uri`\n* `method` - http method (default: `\"GET\"`)\n* `headers` - http headers (default: `{}`)\n* `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer` or `String`.\n* `form` - when passed an object, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request).\n* `auth` - A hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above.\n* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON.\n* `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.\n* `followRedirect` - follow HTTP 3xx responses as redirects (default: `true`)\n* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects (default: `false`)\n* `maxRedirects` - the maximum number of redirects to follow (default: `10`)\n* `encoding` - Encoding to be used on `setEncoding` of response data. If `null`, the `body` is returned as a `Buffer`.\n* `pool` - A hash object containing the agents for these requests. If omitted, the request will use the global pool (which is set to node's default `maxSockets`)\n* `pool.maxSockets` - Integer containing the maximum amount of sockets in the pool.\n* `timeout` - Integer containing the number of milliseconds to wait for a request to respond before aborting the request\n* `proxy` - An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the `url` parameter (by embedding the auth info in the `uri`)\n* `oauth` - Options for OAuth HMAC-SHA1 signing. See documentation above.\n* `hawk` - Options for [Hawk signing](https://github.com/hueniverse/hawk). The `credentials` key must contain the necessary signing info, [see hawk docs for details](https://github.com/hueniverse/hawk#usage-example).\n* `strictSSL` - If `true`, requires SSL certificates be valid. **Note:** to use your own certificate authority, you need to specify an agent that was created with that CA as an option.\n* `jar` - If `true`, remember cookies for future use (or define your custom cookie jar; see examples section)\n* `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`. Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services)\n* `httpSignature` - Options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options.\n* `localAddress` - Local interface to bind for network connections.\n\n\nThe callback argument gets 3 arguments: \n\n1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object)\n2. An [`http.IncomingMessage`](http://nodejs.org/api/http.html#http_http_incomingmessage) object\n3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied)\n\n## Convenience methods\n\nThere are also shorthand methods for different HTTP METHODs and some other conveniences.\n\n### request.defaults(options)\n\nThis method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.\n\n### request.put\n\nSame as `request()`, but defaults to `method: \"PUT\"`.\n\n```javascript\nrequest.put(url)\n```\n\n### request.patch\n\nSame as `request()`, but defaults to `method: \"PATCH\"`.\n\n```javascript\nrequest.patch(url)\n```\n\n### request.post\n\nSame as `request()`, but defaults to `method: \"POST\"`.\n\n```javascript\nrequest.post(url)\n```\n\n### request.head\n\nSame as request() but defaults to `method: \"HEAD\"`.\n\n```javascript\nrequest.head(url)\n```\n\n### request.del\n\nSame as `request()`, but defaults to `method: \"DELETE\"`.\n\n```javascript\nrequest.del(url)\n```\n\n### request.get\n\nSame as `request()` (for uniformity).\n\n```javascript\nrequest.get(url)\n```\n### request.cookie\n\nFunction that creates a new cookie.\n\n```javascript\nrequest.cookie('cookie_string_here')\n```\n### request.jar\n\nFunction that creates a new cookie jar.\n\n```javascript\nrequest.jar()\n```\n\n\n## Examples:\n\n```javascript\n var request = require('request')\n , rand = Math.floor(Math.random()*100000000).toString()\n ;\n request(\n { method: 'PUT'\n , uri: 'http://mikeal.iriscouch.com/testjs/' + rand\n , multipart:\n [ { 'content-type': 'application/json'\n , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})\n }\n , { body: 'I am an attachment' }\n ]\n }\n , function (error, response, body) {\n if(response.statusCode == 201){\n console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)\n } else {\n console.log('error: '+ response.statusCode)\n console.log(body)\n }\n }\n )\n```\n\nCookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set `jar` to `true` (either in `defaults` or `options`).\n\n```javascript\nvar request = request.defaults({jar: true})\nrequest('http://www.google.com', function () {\n request('http://images.google.com')\n})\n```\n\nTo use a custom cookie jar (instead of `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`)\n\n```javascript\nvar j = request.jar()\nvar request = request.defaults({jar:j})\nrequest('http://www.google.com', function () {\n request('http://images.google.com')\n})\n```\n\nOR\n\n```javascript\nvar j = request.jar()\nvar cookie = request.cookie('your_cookie_here')\nj.setCookie(cookie, uri);\nrequest({url: 'http://www.google.com', jar: j}, function () {\n request('http://images.google.com')\n})\n```\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/mikeal/request",
"_id": "request@2.34.0",
"_shasum": "b5d8b9526add4a2d4629f4d417124573996445ae",
"_id": "request@2.36.0",
"_shasum": "28c6c04262c7b9ffdd21b9255374517ee6d943f5",
"_from": "request@2",
"_resolved": "https://registry.npmjs.org/request/-/request-2.34.0.tgz"
"_resolved": "https://registry.npmjs.org/request/-/request-2.36.0.tgz"
}

@@ -111,8 +111,16 @@ # Request -- Simplified HTTP client

```javascript
var r = request.post('http://service.com/upload')
var r = request.post('http://service.com/upload', function optionalCallback (err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
})
var form = r.form()
form.append('my_field', 'my_value')
form.append('my_buffer', new Buffer([1, 2, 3]))
form.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png'))
form.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png')))
form.append('remote_file', request('http://google.com/doodle.png'))
// Just like always, `r` is a writable stream, and can be used as such (you have until nextTick to pipe it, etc.)
// Alternatively, you can provide a callback (that's what this example does-- see `optionalCallback` above).
```

@@ -132,5 +140,13 @@

});
// or
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
// or
request.get('http://some.server.com/', {
'auth': {
'bearer': 'bearerToken'
}
});
```
If passed as an option, `auth` should be a hash containing values `user` || `username`, `password` || `pass`, and `sendImmediately` (optional). The method form takes parameters `auth(username, password, sendImmediately)`.
If passed as an option, `auth` should be a hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). The method form takes parameters `auth(username, password, sendImmediately)`.

@@ -141,2 +157,4 @@ `sendImmediately` defaults to `true`, which causes a basic authentication header to be sent. If `sendImmediately` is `false`, then `request` will retry with a proper authentication header after receiving a `401` response from the server (which must contain a `WWW-Authenticate` header indicating the required authentication method).

Bearer authentication is supported, and is activated when the `bearer` value is available. The value may be either a `String` or a `Function` returning a `String`. Using a function to supply the bearer token is particularly useful if used in conjuction with `defaults` to allow a single function to supply the last known token at the time or sending a request or to compute one on the fly.
## OAuth Signing

@@ -228,3 +246,3 @@

* `form` - when passed an object, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request).
* `auth` - A hash containing values `user` || `username`, `password` || `pass`, and `sendImmediately` (optional). See documentation above.
* `auth` - A hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above.
* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON.

@@ -362,3 +380,3 @@ * `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.

To use a custom cookie jar (instead `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`)
To use a custom cookie jar (instead of `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`)

@@ -365,0 +383,0 @@ ```javascript

@@ -247,9 +247,9 @@ var optional = require('./lib/optional')

var self = this;
if (options.form) {
self.form(options.form)
}
if (options.qs) self.qs(options.qs)
if (self.uri.path) {

@@ -260,6 +260,6 @@ self.path = self.uri.path

}
if (self.path.length === 0) self.path = '/'
// Auth must happen last in case signing is dependent on other headers

@@ -269,26 +269,27 @@ if (options.oauth) {

}
if (options.aws) {
self.aws(options.aws)
}
if (options.hawk) {
self.hawk(options.hawk)
}
if (options.httpSignature) {
self.httpSignature(options.httpSignature)
}
if (options.auth) {
if (Object.prototype.hasOwnProperty.call(options.auth, 'username')) options.auth.user = options.auth.username
if (Object.prototype.hasOwnProperty.call(options.auth, 'password')) options.auth.pass = options.auth.password
self.auth(
options.auth.user,
options.auth.pass,
options.auth.sendImmediately
options.auth.sendImmediately,
options.auth.bearer
)
}
if (self.uri.auth && !self.hasHeader('authorization')) {

@@ -301,6 +302,6 @@ var authPieces = self.uri.auth.split(':').map(function(item){ return querystring.unescape(item) })

}
if (self.proxy && !self.tunnel) self.path = (self.uri.protocol + '//' + self.uri.host + self.path)
if (options.json) {

@@ -312,3 +313,3 @@ self.json(options.json)

}
if (self.body) {

@@ -334,3 +335,3 @@ var length = 0

}
var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol

@@ -341,10 +342,10 @@ , defaultModules = {'http:':http, 'https:':https, 'unix:':http}

self.httpModule = httpModules[protocol] || defaultModules[protocol]
if (!self.httpModule) return this.emit('error', new Error("Invalid protocol"))
if (!self.httpModule) return this.emit('error', new Error("Invalid protocol: " + protocol))
if (options.ca) self.ca = options.ca
if (!self.agent) {
if (options.agentOptions) self.agentOptions = options.agentOptions
if (options.agentClass) {

@@ -358,3 +359,3 @@ self.agentClass = options.agentClass

}
if (self.pool === false) {

@@ -373,3 +374,3 @@ self.agent = false

}
self.on('pipe', function (src) {

@@ -394,3 +395,3 @@ if (self.ntick && self._started) throw new Error("You cannot pipe to this stream after the outbound request has started.")

}
// self.on('pipe', function () {

@@ -400,6 +401,6 @@ // console.error("You have already piped to this stream. Pipeing twice is likely to break the request.")

})
process.nextTick(function () {
if (self._aborted) return
if (self._form) {

@@ -433,5 +434,5 @@ self.setHeaders(self._form.getHeaders())

})
} // End _buildRequest
self._handleUnixSocketURI = function(self){

@@ -441,11 +442,11 @@ // Parse URI and extract a socket path (tested as a valid socket using net.connect), and a http style path suffix

// and a request for '/urlpath' will be sent to the unix socket at /tmp/my.socket
self.unixsocket = true;
var full_path = self.uri.href.replace(self.uri.protocol+'/', '');
var lookup = full_path.split('/');
var error_connecting = true;
var lookup_table = {};
var lookup_table = {};
do { lookup_table[lookup.join('/')]={} } while(lookup.pop())

@@ -455,3 +456,3 @@ for (r in lookup_table){

}
function try_next(table_row){

@@ -464,5 +465,5 @@ var client = net.connect( table_row );

}
wait_for_socket_response();
response_counter = 0;

@@ -485,7 +486,7 @@

wait_for_socket_response()
else
else
set_socket_properties();
})
}
function set_socket_properties(){

@@ -502,3 +503,3 @@ var host;

var path = full_path.replace(host, '')
self.socketPath = host

@@ -515,3 +516,3 @@ self.uri.pathname = path

}
// Intercept UNIX protocol requests to change properties to match socket

@@ -523,3 +524,3 @@ if(/^unix:/.test(self.uri.protocol)){

}
}

@@ -602,2 +603,3 @@

if (this.secureProtocol) options.secureProtocol = this.secureProtocol
if (this.secureOptions) options.secureOptions = this.secureOptions
if (typeof this.rejectUnauthorized !== 'undefined') options.rejectUnauthorized = this.rejectUnauthorized

@@ -810,2 +812,7 @@

case 'bearer':
self.auth(null, null, true, self._bearer)
redirectTo = self.uri
break
case 'digest':

@@ -900,3 +907,3 @@ // TODO: More complete implementation of RFC 2617.

)
if (self.followAllRedirects && response.statusCode != 401) self.method = 'GET'
if (self.followAllRedirects && response.statusCode != 401 && response.statusCode != 307) self.method = 'GET'
// self.method = 'GET' // Force all redirects to use GET || commented out fixes #215

@@ -907,3 +914,3 @@ delete self.src

delete self._started
if (response.statusCode != 401) {
if (response.statusCode != 401 && response.statusCode != 307) {
// Remove parameters from the previous response, unless this is the second request

@@ -1166,2 +1173,3 @@ // for a server that requires digest authentication.

Object.keys(headers).forEach(function (key) {
if (key.length !== name.length) return
re = new RegExp(name, 'i')

@@ -1175,3 +1183,15 @@ match = key.match(re)

Request.prototype.auth = function (user, pass, sendImmediately) {
Request.prototype.auth = function (user, pass, sendImmediately, bearer) {
if (bearer !== undefined) {
this._bearer = bearer
this._hasAuth = true
if (sendImmediately || typeof sendImmediately == 'undefined') {
if (typeof bearer === 'function') {
bearer = bearer()
}
this.setHeader('authorization', 'Bearer ' + bearer)
this._sentAuth = true
}
return this
}
if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) {

@@ -1178,0 +1198,0 @@ throw new Error('auth() received invalid user or password')

{
"name": "node-pre-gyp",
"description": "Node.js native addon binary install tool",
"version" : "0.5.13",
"version" : "0.5.14",
"keywords": [

@@ -29,3 +29,3 @@ "native",

"mkdirp":"~0.5.0",
"rc":"~0.3.4",
"rc":"~0.4.0",
"rimraf":"~2.2.5"

@@ -32,0 +32,0 @@ },

@@ -75,3 +75,4 @@ # node-pre-gyp

- `--target=0.10.25`: Pass the target node or node-webkit version to compile against
- `--target_arch=ia32`: Pass the target arch (will override the host `arch`)
- `--target_arch=ia32`: Pass the target arch and override the host `arch`. Valid values are 'ia32','x64', or `arm`.
- `--target_platform=ia32`: Pass the target platform and override the host `platform`. Valid values are `linux`, `darwin`, `win32`, `sunos`, `freebsd`, `openbsd`, and `aix`.

@@ -438,3 +439,3 @@ Both `--build-from-source` and `--fallback-to-build` can be passed alone or they can provide values. You can pass `--fallback-to-build=false` to override the option as declared in package.json. In addition to being able to pass `--build-from-source` you can also pass `--build-from-source=myapp` where `myapp` is the name of your module.

- `node_abi`: The node C++ `ABI` number. This value is available in javascript as `process.versions.modules` as of [`>= v0.10.4 >= v0.11.7`](https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e) and in C++ as the `NODE_MODULE_VERSION` define much earlier. For versions of Node before this was available we fallback to the V8 major and minor version.
- `platform` matches node's `process.platform` like `linux`, `darwin`, and `win32`
- `platform` matches node's `process.platform` like `linux`, `darwin`, and `win32` unless the user passed the `--target_platform` option to override.
- `arch` matches node's `process.arch` like `x64` or `ia32` unless the user passes the `--target_arch` option to override.

@@ -441,0 +442,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