Follow redirects for hyperquest GET requests
Follow redirects for hyperquest GET requests. Process all other requests exactly as normal.
$ npm install hyperdirect
//basic usagevar request = require'hyperquest'request;request''piperequire'fs'createWriteStream__dirname + '/hyperdirect.tar.gz';//moderate usagevar request = require'hyperquest'2/* Max Redirects to follow, defaults to 10 */;request''piperequire'fs'createWriteStream__dirname + '/hyperdirect.tar.gz';//advanced usagevar hyperdirect = require'hyperdirect'5 require'hyperquest';
Returns a new function with the same API as hyperquest but which follows redirects for GET requests. Both
subquest are optional and can be in either order.
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
statusCode property set to the apropriate properties from the last request made.
The 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:
require'hyperdirect'100urlon'redirect'console.log'REDIRECT ' + resstatusCode + ': ' + resheaderslocation;on'response'console.log'FINAL URL: ' + resurl;;
Follows exactly the same API as hyperquest but automatically follows up to 10 redirects for GET requests. It's the same as what you get by calling