/
package.json
33 lines (33 loc) · 3.17 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"name": "hyperdirect",
"version": "0.0.0",
"description": "Follow redirects for hyperquest GET requests",
"main": "index.js",
"scripts": {
"test": "mocha -R spec"
},
"repository": {
"type": "git",
"url": "https://github.com/ForbesLindesay/hyperdirect.git"
},
"author": {
"name": "ForbesLindesay"
},
"license": "MIT",
"dependencies": {
"through": "~2.3.4",
"hyperquest": "~0.1.5"
},
"readme": "# hyperdirect\r\n\r\nFollow redirects for hyperquest GET requests. Process all other requests exactly as normal.\r\n\r\n## Installation\r\n\r\n $ npm install hyperdirect\r\n\r\n## Usage\r\n\r\n```js\r\n//basic usage\r\nvar request = require('hyperquest').request;\r\n\r\nrequest('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz')\r\n .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz'));\r\n\r\n//moderate usage\r\nvar request = require('hyperquest')(2/* Max Redirects to follow, defaults to 10 */);\r\n\r\nrequest('https://github.com/ForbesLindesay/hyperdirect/archive/master.tar.gz')\r\n .pipe(require('fs').createWriteStream(__dirname + '/hyperdirect.tar.gz'));\r\n\r\n//advanced usage\r\nvar hyperdirect = require('hyperdirect')(5, require('hyperquest'));\r\n```\r\n\r\n## API\r\n\r\n### hyperdirect(maxRedirects, subquest)\r\n\r\nReturns a new function with the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but which follows redirects for GET requests. Both `maxRedirects` and `subquest` are optional and can be in either order.\r\n\r\nIf provided, `subquest` should be a function which matches the API of [hyperquest](https://github.com/hyperquest/hyperquest) or an object of the form `{request: hyperquest}` where `hyperquest` is a function matching the API of [hyperquest](https://github.com/hyperquest/hyperquest).\r\n\r\n`maxRedirects` will default to `10`. Once the request has been redirected more times than that it will give up and throw an error. The error has a `res` and `statusCode` property set to the apropriate properties from the last request made.\r\n\r\nThe returned stream will emit `redirect` events with the response of any request that results in another redirect. This means you could trace the path something a request took by doing:\r\n\r\n```js\r\nrequire('hyperdirect')(100)(url)\r\n .on('redirect', function (res) {\r\n console.log('REDIRECT ' + res.statusCode + ': ' + res.headers.location);\r\n })\r\n .on('response', function (res) {\r\n console.log('FINAL URL: ' + res.url);\r\n });\r\n```\r\n\r\n### hyperdirect.request(uri, opts, cb)\r\n\r\nFollows exactly the same API as [hyperquest](https://github.com/hyperquest/hyperquest) but automatically follows up to 10 redirects for GET requests. It's the same as what you get by calling `hyperdirect()`.\r\n\r\n## License\r\n\r\nMIT",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/ForbesLindesay/hyperdirect/issues"
},
"homepage": "https://github.com/ForbesLindesay/hyperdirect",
"_id": "hyperdirect@0.0.0",
"dist": {
"shasum": "4024d59ba71442d340c1cf649ce7e42209840c3d"
},
"_from": "hyperdirect@",
"_resolved": "https://registry.npmjs.org/hyperdirect/-/hyperdirect-0.0.0.tgz"
}