diff options
author | Rebecca Turner <me@re-becca.org> | 2016-04-15 01:42:40 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2016-04-22 02:34:45 +0300 |
commit | df1f2e4838b4d7ea2ea2321a95ae868c0ec0a520 (patch) | |
tree | 98744dc54a93d9803635b99e6528d9a2bd1679c5 /node_modules/request | |
parent | 776c599b204632aca9d29fd92ea5c4f099fdea9f (diff) |
request@2.72.0
Don't throw if invalid characters are found in an http header, emit via an
error event.
Fix crashes when response headers indicate gzipped content but the body is
empty.
Add `request.delete` as an alias for `del`
Add support for deflate content encoding.
Credit: @simov
Diffstat (limited to 'node_modules/request')
-rw-r--r-- | node_modules/request/.travis.yml | 10 | ||||
-rw-r--r-- | node_modules/request/CHANGELOG.md | 11 | ||||
-rw-r--r-- | node_modules/request/README.md | 6 | ||||
-rwxr-xr-x | node_modules/request/index.js | 11 | ||||
-rw-r--r-- | node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/index.js | 2 | ||||
-rw-r--r-- | node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/package.json | 36 | ||||
-rw-r--r-- | node_modules/request/package.json | 18 | ||||
-rw-r--r-- | node_modules/request/request.js | 40 |
8 files changed, 93 insertions, 41 deletions
diff --git a/node_modules/request/.travis.yml b/node_modules/request/.travis.yml index c24c59b5d..e5d9bde26 100644 --- a/node_modules/request/.travis.yml +++ b/node_modules/request/.travis.yml @@ -1,15 +1,19 @@ language: node_js + node_js: - node - - io.js - 0.12 - 0.10 -sudo: false -after_script: "npm run test-cov && cat ./coverage/lcov.info | codecov && cat ./coverage/lcov.info | coveralls" +after_script: + - npm run test-cov + - cat ./coverage/lcov.info | codecov + - cat ./coverage/lcov.info | coveralls webhooks: urls: https://webhooks.gitter.im/e/237280ed4796c19cc626 on_success: change # options: [always|never|change] default: always on_failure: always # options: [always|never|change] default: always on_start: false # default: false + +sudo: false diff --git a/node_modules/request/CHANGELOG.md b/node_modules/request/CHANGELOG.md index 34f8e7325..ce6826f2f 100644 --- a/node_modules/request/CHANGELOG.md +++ b/node_modules/request/CHANGELOG.md @@ -1,5 +1,16 @@ ## Change Log +### v2.72.0 (2016/04/17) +- [#2176](https://github.com/request/request/pull/2176) Do not try to pipe Gzip responses with no body (@simov) +- [#2175](https://github.com/request/request/pull/2175) Add 'delete' alias for the 'del' API method (@simov, @MuhanZou) +- [#2172](https://github.com/request/request/pull/2172) Add support for deflate content encoding (@czardoz) +- [#2169](https://github.com/request/request/pull/2169) Add callback option (@simov) +- [#2165](https://github.com/request/request/pull/2165) Check for self.req existence inside the write method (@simov) +- [#2167](https://github.com/request/request/pull/2167) Fix TravisCI badge reference master branch (@a0viedo) + +### v2.71.0 (2016/04/12) +- [#2164](https://github.com/request/request/pull/2164) Catch errors from the underlying http module (@simov) + ### v2.70.0 (2016/04/05) - [#2147](https://github.com/request/request/pull/2147) Update eslint to version 2.5.3 🚀 (@simov, @greenkeeperio-bot) - [#2009](https://github.com/request/request/pull/2009) Support JSON stringify replacer argument. (@elyobo) diff --git a/node_modules/request/README.md b/node_modules/request/README.md index 64c43e742..cf9072a21 100644 --- a/node_modules/request/README.md +++ b/node_modules/request/README.md @@ -3,7 +3,7 @@ [![npm package](https://nodei.co/npm/request.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/request/) -[![Build status](https://img.shields.io/travis/request/request.svg?style=flat-square)](https://travis-ci.org/request/request) +[![Build status](https://img.shields.io/travis/request/request/master.svg?style=flat-square)](https://travis-ci.org/request/request) [![Coverage](https://img.shields.io/codecov/c/github/request/request.svg?style=flat-square)](https://codecov.io/github/request/request?branch=master) [![Coverage](https://img.shields.io/coveralls/request/request.svg?style=flat-square)](https://coveralls.io/r/request/request) [![Dependency Status](https://img.shields.io/david/request/request.svg?style=flat-square)](https://david-dm.org/request/request) @@ -814,6 +814,7 @@ default in Linux can be anywhere from 20-120 seconds][linux-timeout]). - `time` - If `true`, the request-response cycle (including all redirects) is timed at millisecond resolution, and the result provided on the response's `elapsedTime` property. - `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)* +- `callback` - alternatively pass the request's callback in the options object The callback argument gets 3 arguments: @@ -888,12 +889,13 @@ Same as `request()`, but defaults to `method: "HEAD"`. request.head(url) ``` -### request.del +### request.del / request.delete Same as `request()`, but defaults to `method: "DELETE"`. ```js request.del(url) +request.delete(url) ``` ### request.get diff --git a/node_modules/request/index.js b/node_modules/request/index.js index 4d0c748da..911a90dbb 100755 --- a/node_modules/request/index.js +++ b/node_modules/request/index.js @@ -37,7 +37,7 @@ function initParams(uri, options, callback) { extend(params, uri) } - params.callback = callback + params.callback = callback || params.callback return params } @@ -56,7 +56,7 @@ function request (uri, options, callback) { } function verbFunc (verb) { - var method = verb === 'del' ? 'DELETE' : verb.toUpperCase() + var method = verb.toUpperCase() return function (uri, options, callback) { var params = initParams(uri, options, callback) params.method = method @@ -70,7 +70,8 @@ request.head = verbFunc('head') request.post = verbFunc('post') request.put = verbFunc('put') request.patch = verbFunc('patch') -request.del = verbFunc('del') +request.del = verbFunc('delete') +request['delete'] = verbFunc('delete') request.jar = function (store) { return cookies.jar(store) @@ -91,7 +92,7 @@ function wrapRequestMethod (method, options, requester, verb) { target.pool = params.pool || options.pool if (verb) { - target.method = (verb === 'del' ? 'DELETE' : verb.toUpperCase()) + target.method = verb.toUpperCase() } if (isFunction(requester)) { @@ -114,7 +115,7 @@ request.defaults = function (options, requester) { var defaults = wrapRequestMethod(self, options, requester) - var verbs = ['get', 'head', 'post', 'put', 'patch', 'del'] + var verbs = ['get', 'head', 'post', 'put', 'patch', 'del', 'delete'] verbs.forEach(function(verb) { defaults[verb] = wrapRequestMethod(self[verb], options, requester, verb) }) diff --git a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/index.js b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/index.js index cc64b902c..777377a1f 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/index.js +++ b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/index.js @@ -1,3 +1,3 @@ 'use strict'; -module.exports = global.Promise || require('pinkie'); +module.exports = typeof Promise === 'function' ? Promise : require('pinkie'); diff --git a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/package.json b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/package.json index 82ca19807..438996b7e 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/package.json @@ -2,20 +2,24 @@ "_args": [ [ "pinkie-promise@^2.0.0", - "/Users/ogd/Documents/projects/npm/npm/node_modules/request/node_modules/har-validator" + "/Users/rebecca/code/npm/node_modules/request/node_modules/har-validator" ] ], "_from": "pinkie-promise@>=2.0.0 <3.0.0", - "_id": "pinkie-promise@2.0.0", + "_id": "pinkie-promise@2.0.1", "_inCache": true, "_installable": true, "_location": "/request/har-validator/pinkie-promise", - "_nodeVersion": "4.2.0", + "_nodeVersion": "4.4.1", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/pinkie-promise-2.0.1.tgz_1460309839126_0.3422858319245279" + }, "_npmUser": { "email": "floatdrop@gmail.com", "name": "floatdrop" }, - "_npmVersion": "2.14.7", + "_npmVersion": "2.14.20", "_phantomChildren": {}, "_requested": { "name": "pinkie-promise", @@ -28,11 +32,11 @@ "_requiredBy": [ "/request/har-validator" ], - "_resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.0.tgz", - "_shasum": "4c83538de1f6e660c29e0a13446844f7a7e88259", + "_resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "_shasum": "2135d6dfa7a358c069ac9b178776288228450ffa", "_shrinkwrap": null, "_spec": "pinkie-promise@^2.0.0", - "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/request/node_modules/har-validator", + "_where": "/Users/rebecca/code/npm/node_modules/request/node_modules/har-validator", "author": { "email": "floatdrop@gmail.com", "name": "Vsevolod Strukchinsky", @@ -50,8 +54,8 @@ }, "directories": {}, "dist": { - "shasum": "4c83538de1f6e660c29e0a13446844f7a7e88259", - "tarball": "http://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.0.tgz" + "shasum": "2135d6dfa7a358c069ac9b178776288228450ffa", + "tarball": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" }, "engines": { "node": ">=0.10.0" @@ -59,21 +63,21 @@ "files": [ "index.js" ], - "gitHead": "f90fcae9838bcae7ae1ae4ebc9b29f11e5db4980", + "gitHead": "4a936c09c34ad591a25db93f1216d242de0d6184", "homepage": "https://github.com/floatdrop/pinkie-promise", "keywords": [ + "promise", + "promises", "es2015", "es6", "polyfill", - "ponyfill", - "promise", - "promises" + "ponyfill" ], "license": "MIT", "maintainers": [ { - "name": "floatdrop", - "email": "floatdrop@gmail.com" + "email": "floatdrop@gmail.com", + "name": "floatdrop" } ], "name": "pinkie-promise", @@ -86,5 +90,5 @@ "scripts": { "test": "mocha" }, - "version": "2.0.0" + "version": "2.0.1" } diff --git a/node_modules/request/package.json b/node_modules/request/package.json index 62960bd71..6c9fa0ec8 100644 --- a/node_modules/request/package.json +++ b/node_modules/request/package.json @@ -6,14 +6,14 @@ ] ], "_from": "request@latest", - "_id": "request@2.70.0", + "_id": "request@2.72.0", "_inCache": true, "_installable": true, "_location": "/request", "_nodeVersion": "5.9.0", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/request-2.70.0.tgz_1459850846109_0.8679330893792212" + "tmp": "tmp/request-2.72.0.tgz_1460901215210_0.9173020373564214" }, "_npmUser": { "email": "simeonvelichkov@gmail.com", @@ -22,7 +22,7 @@ "_npmVersion": "3.8.5", "_phantomChildren": { "ansi-regex": "2.0.0", - "readable-stream": "2.0.6", + "inherits": "2.0.1", "strip-ansi": "3.0.1" }, "_requested": { @@ -38,8 +38,8 @@ "/node-gyp", "/npm-registry-client" ], - "_resolved": "https://registry.npmjs.org/request/-/request-2.70.0.tgz", - "_shasum": "7ecf8437d6fb553e92e2981a411b9ee2aadd7cce", + "_resolved": "https://registry.npmjs.org/request/-/request-2.72.0.tgz", + "_shasum": "0ce3a179512620b10441f14c82e21c12c0ddb4e1", "_shrinkwrap": null, "_spec": "request@latest", "_where": "/Users/rebecca/code/npm", @@ -98,13 +98,13 @@ }, "directories": {}, "dist": { - "shasum": "7ecf8437d6fb553e92e2981a411b9ee2aadd7cce", - "tarball": "https://registry.npmjs.org/request/-/request-2.70.0.tgz" + "shasum": "0ce3a179512620b10441f14c82e21c12c0ddb4e1", + "tarball": "https://registry.npmjs.org/request/-/request-2.72.0.tgz" }, "engines": { "node": ">=0.8.0" }, - "gitHead": "bc781cb49aafedb057719e8b1eb7850979688a85", + "gitHead": "6dcac13642955577592fdafb5ff3cdc8a6ff1b1b", "homepage": "https://github.com/request/request#readme", "license": "Apache-2.0", "main": "index.js", @@ -146,5 +146,5 @@ "util", "utility" ], - "version": "2.70.0" + "version": "2.72.0" } diff --git a/node_modules/request/request.js b/node_modules/request/request.js index 6310e0a6b..124157e86 100644 --- a/node_modules/request/request.js +++ b/node_modules/request/request.js @@ -399,7 +399,7 @@ Request.prototype.init = function (options) { } if (self.gzip && !self.hasHeader('accept-encoding')) { - self.setHeader('accept-encoding', 'gzip') + self.setHeader('accept-encoding', 'gzip, deflate') } if (self.uri.auth && !self.hasHeader('authorization')) { @@ -749,7 +749,12 @@ Request.prototype.start = function () { debug('make request', self.uri.href) - self.req = self.httpModule.request(reqOptions) + try { + self.req = self.httpModule.request(reqOptions) + } catch (err) { + self.emit('error', err) + return + } if (self.timing) { self.startTime = new Date().getTime() @@ -915,14 +920,29 @@ Request.prototype.onRequestResponse = function (response) { self._ended = true }) + var noBody = function (code) { + return ( + self.method === 'HEAD' + // Informational + || (code >= 100 && code < 200) + // No Content + || code === 204 + // Not Modified + || code === 304 + ) + } + var responseContent - if (self.gzip) { + if (self.gzip && !noBody(response.statusCode)) { var contentEncoding = response.headers['content-encoding'] || 'identity' contentEncoding = contentEncoding.trim().toLowerCase() if (contentEncoding === 'gzip') { responseContent = zlib.createGunzip() response.pipe(responseContent) + } else if (contentEncoding === 'deflate') { + responseContent = zlib.createInflate() + response.pipe(responseContent) } else { // Since previous versions didn't check for Content-Encoding header, // ignore any invalid values to preserve backwards-compatibility @@ -1006,6 +1026,9 @@ Request.prototype.readResponseBody = function (response) { debug('end event', self.uri.href) if (self._aborted) { debug('aborted', self.uri.href) + // `buffer` is defined in the parent scope and used in a closure it exists for the life of the request. + // This can lead to leaky behavior if the user retains a reference to the request object. + buffer.destroy() return } @@ -1018,6 +1041,9 @@ Request.prototype.readResponseBody = function (response) { } else { response.body = buffer.toString(self.encoding) } + // `buffer` is defined in the parent scope and used in a closure it exists for the life of the Request. + // This can lead to leaky behavior if the user retains a reference to the request object. + buffer.destroy() } else if (strings.length) { // The UTF8 BOM [0xEF,0xBB,0xBF] is converted to [0xFE,0xFF] in the JS UTC16/UCS2 representation. // Strip this value out when the encoding is set to 'utf8', as upstream consumers won't expect it and it breaks JSON.parse(). @@ -1377,7 +1403,9 @@ Request.prototype.write = function () { if (!self._started) { self.start() } - return self.req.write.apply(self.req, arguments) + if (self.req) { + return self.req.write.apply(self.req, arguments) + } } Request.prototype.end = function (chunk) { var self = this @@ -1389,7 +1417,9 @@ Request.prototype.end = function (chunk) { if (!self._started) { self.start() } - self.req.end() + if (self.req) { + self.req.end() + } } Request.prototype.pause = function () { var self = this |