{"_id":"follow-redirects@1.16.1","bugs":{"url":"https://github.com/follow-redirects/follow-redirects/issues"},"dist":{"shasum":"6e0efa40a727fb369b98dab15883ec34787d675e","tarball":"http://registry-npm.ywwl.com/follow-redirects/download/follow-redirects-1.16.1.tgz","fileCount":7,"integrity":"sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==","signatures":[{"sig":"MEUCIDlLW9TqaQ0J7J+MavDgYbB7jO3NhnQIiJb85kbsKqiZAiEAshgQ8tx69DCCFfb3VaEsgdGX9Pam35+QlnBc64S0lWw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEedyKTGE1ZH4memHkLDQ7OK4sHupa6u58g2pkWGdVaQAiEA9NxDuPOtkYCAKO2bAlvuNKcw8v8NPg5H/zzJ6sUZZq8="}],"unpackedSize":30959,"size":10076,"noattachment":false,"key":"/follow-redirects/-/follow-redirects-1.16.1.tgz"},"main":"index.js","name":"follow-redirects","author":{"url":"https://ruben.verborgh.org/","name":"Ruben Verborgh","email":"ruben@verborgh.org"},"engines":{"node":">=4.0"},"funding":[{"url":"https://github.com/sponsors/RubenVerborgh","type":"individual"}],"gitHead":"46301256333c90b7faac7aa126effe72ec16d16e","license":"MIT","scripts":{"lint":"eslint *.js test","test":"nyc mocha"},"version":"1.16.1","_npmUser":{"name":"rubenverborgh","email":"ruben@verborgh.org"},"homepage":"https://github.com/follow-redirects/follow-redirects","keywords":["http","https","url","redirect","client","location","utility"],"repository":{"url":"git+ssh://git@github.com/follow-redirects/follow-redirects.git","type":"git"},"_npmVersion":"11.13.0","description":"HTTP and HTTPS modules that follow redirects.","directories":{},"maintainers":[{"name":"rubenverborgh","email":"ruben@verborgh.org"},{"name":"olalonde","email":"olalonde@gmail.com"}],"_nodeVersion":"24.16.0","contributors":[{"url":"http://www.syskall.com","name":"Olivier Lalonde","email":"olalonde@gmail.com"},{"name":"James Talmage","email":"james@talmage.io"}],"_hasShrinkwrap":false,"devDependencies":{"nyc":"^14.1.1","lolex":"^3.1.0","mocha":"^6.0.2","eslint":"^5.16.0","express":"^4.16.4","concat-stream":"^2.0.0"},"peerDependenciesMeta":{"debug":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/follow-redirects_1.16.1_1790862751691_0.5341497383448428"},"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":1790862751780,"_cnpm_publish_time":1790862751780,"dist-tags":{"latest":"1.16.3"}}