{"name":"follow-redirects","version":"1.16.0","description":"HTTP and HTTPS modules that follow redirects.","license":"MIT","main":"index.js","engines":{"node":">=4.0"},"scripts":{"lint":"eslint *.js test","test":"nyc mocha"},"repository":{"type":"git","url":"git+ssh://git@github.com/follow-redirects/follow-redirects.git"},"homepage":"https://github.com/follow-redirects/follow-redirects","bugs":{"url":"https://github.com/follow-redirects/follow-redirects/issues"},"keywords":["http","https","url","redirect","client","location","utility"],"author":{"name":"Ruben Verborgh","email":"ruben@verborgh.org","url":"https://ruben.verborgh.org/"},"contributors":[{"name":"Olivier Lalonde","email":"olalonde@gmail.com","url":"http://www.syskall.com"},{"name":"James Talmage","email":"james@talmage.io"}],"funding":[{"type":"individual","url":"https://github.com/sponsors/RubenVerborgh"}],"peerDependenciesMeta":{"debug":{"optional":true}},"devDependencies":{"concat-stream":"^2.0.0","eslint":"^5.16.0","express":"^4.16.4","lolex":"^3.1.0","mocha":"^6.0.2","nyc":"^14.1.1"},"_id":"follow-redirects@1.16.0","gitHead":"0c23a223067201c368035e82954c11eb2578a33b","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==","shasum":"28474a159d3b9d11ef62050a14ed60e4df6d61bc","tarball":"http://registry-npm.ywwl.com/follow-redirects/download/follow-redirects-1.16.0.tgz","fileCount":7,"unpackedSize":30614,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAlmIKUMCu7ZO+tvv33RkvWcpQHqixrai1CcJS9FSLL9AiB4QMrHaTv6rk8r0m2byvSJvCX5Iv3iihrFWy8DkeTELw=="}],"size":9967,"noattachment":false,"key":"/follow-redirects/-/follow-redirects-1.16.0.tgz"},"_npmUser":{"name":"rubenverborgh","email":"ruben@verborgh.org"},"directories":{},"maintainers":[{"name":"rubenverborgh","email":"ruben@verborgh.org"},{"name":"olalonde","email":"olalonde@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/follow-redirects_1.16.0_1776078225094_0.10274239368541882"},"_hasShrinkwrap":false,"readme":"## Follow Redirects\n\nDrop-in replacement for Node's `http` and `https` modules that automatically follows redirects.\n\n[![npm version](https://img.shields.io/npm/v/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects)\n[![Build Status](https://github.com/follow-redirects/follow-redirects/workflows/CI/badge.svg)](https://github.com/follow-redirects/follow-redirects/actions)\n[![Coverage Status](https://coveralls.io/repos/follow-redirects/follow-redirects/badge.svg?branch=master)](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)\n[![npm downloads](https://img.shields.io/npm/dm/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects)\n[![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor&message=%F0%9F%92%96&logo=GitHub)](https://github.com/sponsors/RubenVerborgh)\n\n`follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback)\n methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback)\n modules, with the exception that they will seamlessly follow redirects.\n\n```javascript\nconst { http, https } = require('follow-redirects');\n\nhttp.get('http://en.wikipedia.org/', response => {\n  response.on('data', chunk => {\n    console.log(chunk);\n  });\n}).on('error', err => {\n  console.error(err);\n});\n```\n\nYou can inspect the final redirected URL through the `responseUrl` property on the `response`.\nIf no redirection happened, `responseUrl` is the original request URL.\n\n```javascript\nconst request = https.request({\n  host: 'en.wikipedia.org',\n  path: '/',\n}, response => {\n  console.log(response.responseUrl);\n  // 'http://duckduckgo.com/robots.txt'\n});\nrequest.end();\n```\n\n## Options\n### Global options\nGlobal options are set directly on the `follow-redirects` module:\n\n```javascript\nconst followRedirects = require('follow-redirects');\nfollowRedirects.maxRedirects = 10;\nfollowRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB\n```\n\nThe following global options are supported:\n\n- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.\n\n- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.\n\n### Per-request options\nPer-request options are set by passing an `options` object:\n\n```javascript\nconst url = require('url');\nconst { http, https } = require('follow-redirects');\n\nconst options = url.parse('http://en.wikipedia.org/');\noptions.maxRedirects = 10;\noptions.beforeRedirect = (options, response, request) => {\n  // Use this to adjust the request options upon redirecting,\n  // to inspect the latest response headers,\n  // or to cancel the request by throwing an error\n\n  // response.headers = the redirect response headers\n  // response.statusCode = the redirect response code (eg. 301, 307, etc.)\n\n  // request.url = the requested URL that resulted in a redirect\n  // request.headers = the headers in the request that resulted in a redirect\n  // request.method = the method of the request that resulted in a redirect\n  if (options.hostname === \"example.org\") {\n    options.auth = \"user:password\";\n  }\n};\nhttp.request(options);\n```\n\nIn addition to the [standard HTTP](https://nodejs.org/api/http.html#http_http_request_options_callback) and [HTTPS options](https://nodejs.org/api/https.html#https_https_request_options_callback),\nthe following per-request options are supported:\n- `followRedirects` (default: `true`) – whether redirects should be followed.\n\n- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.\n\n- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.\n\n- `beforeRedirect` (default: `undefined`) – optionally change the request `options` on redirects, or abort the request by throwing an error.\n\n- `agents` (default: `undefined`) – sets the `agent` option per protocol, since HTTP and HTTPS use different agents. Example value: `{ http: new http.Agent(), https: new https.Agent() }`\n\n- `trackRedirects` (default: `false`) – whether to store the redirected response details into the `redirects` array on the response object.\n\n- `sensitiveHeaders` (default: `[]`) – names of headers to omit when making redirected requests (such as `X-API-Key`, `X-Auth-Token`…)\n\n\n### Advanced usage\nBy default, `follow-redirects` will use the Node.js default implementations\nof [`http`](https://nodejs.org/api/http.html)\nand [`https`](https://nodejs.org/api/https.html).\nTo enable features such as caching and/or intermediate request tracking,\nyou might instead want to wrap `follow-redirects` around custom protocol implementations:\n\n```javascript\nconst { http, https } = require('follow-redirects').wrap({\n  http: require('your-custom-http'),\n  https: require('your-custom-https'),\n});\n```\n\nSuch custom protocols only need an implementation of the `request` method.\n\n## Browser Usage\n\nDue to the way the browser works,\nthe `http` and `https` browser equivalents perform redirects by default.\n\nBy requiring `follow-redirects` this way:\n```javascript\nconst http = require('follow-redirects/http');\nconst https = require('follow-redirects/https');\n```\nyou can easily tell webpack and friends to replace\n`follow-redirect` by the built-in versions:\n\n```json\n{\n  \"follow-redirects/http\"  : \"http\",\n  \"follow-redirects/https\" : \"https\"\n}\n```\n\n## Contributing\n\nPull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues)\n detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied\n by tests. You can run the test suite locally with a simple `npm test` command.\n\n## Debug Logging\n\n`follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging\n set the environment variable `DEBUG=follow-redirects` for debug output from just this module. When running the test\n suite it is sometimes advantageous to set `DEBUG=*` to see output from the express server as well.\n\n## Authors\n\n- [Ruben Verborgh](https://ruben.verborgh.org/)\n- [Olivier Lalonde](mailto:olalonde@gmail.com)\n- [James Talmage](mailto:james@talmage.io)\n\n## License\n\n[MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE)\n","publish_time":1776078225228,"_cnpm_publish_time":1776078225228,"dist-tags":{"latest":"1.16.3"}}