node_modules: update

This commit is contained in:
Dawid Dziurla 2020-11-12 16:37:43 +01:00
parent 4a21c51f2f
commit b91baffed3
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B
107 changed files with 3886 additions and 2943 deletions

View file

@ -1,26 +1,25 @@
## Follow Redirects
Drop-in replacement for Nodes `http` and `https` that automatically follows redirects.
Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects.
[![npm version](https://img.shields.io/npm/v/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects)
[![Build Status](https://travis-ci.org/follow-redirects/follow-redirects.svg?branch=master)](https://travis-ci.org/follow-redirects/follow-redirects)
[![Coverage Status](https://coveralls.io/repos/follow-redirects/follow-redirects/badge.svg?branch=master)](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)
[![Dependency Status](https://david-dm.org/follow-redirects/follow-redirects.svg)](https://david-dm.org/follow-redirects/follow-redirects)
[![npm downloads](https://img.shields.io/npm/dm/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects)
[![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor&message=%F0%9F%92%96&logo=GitHub)](https://github.com/sponsors/RubenVerborgh)
`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)
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)
modules, with the exception that they will seamlessly follow redirects.
```javascript
var http = require('follow-redirects').http;
var https = require('follow-redirects').https;
const { http, https } = require('follow-redirects');
http.get('http://bit.ly/900913', function (response) {
response.on('data', function (chunk) {
http.get('http://bit.ly/900913', response => {
response.on('data', chunk => {
console.log(chunk);
});
}).on('error', function (err) {
}).on('error', err => {
console.error(err);
});
```
@ -29,13 +28,14 @@ You can inspect the final redirected URL through the `responseUrl` property on t
If no redirection happened, `responseUrl` is the original request URL.
```javascript
https.request({
const request = https.request({
host: 'bitly.com',
path: '/UHfDGO',
}, function (response) {
}, response => {
console.log(response.responseUrl);
// 'http://duckduckgo.com/robots.txt'
});
request.end();
```
## Options
@ -43,7 +43,7 @@ https.request({
Global options are set directly on the `follow-redirects` module:
```javascript
var followRedirects = require('follow-redirects');
const followRedirects = require('follow-redirects');
followRedirects.maxRedirects = 10;
followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB
```
@ -54,16 +54,23 @@ The following global options are supported:
- `maxBodyLength` (default: 10MB) sets the maximum size of the request body; if exceeded, an error will be emitted.
### Per-request options
Per-request options are set by passing an `options` object:
```javascript
var url = require('url');
var followRedirects = require('follow-redirects');
const url = require('url');
const { http, https } = require('follow-redirects');
var options = url.parse('http://bit.ly/900913');
const options = url.parse('http://bit.ly/900913');
options.maxRedirects = 10;
options.beforeRedirect = (options, { headers }) => {
// Use this to adjust the request options upon redirecting,
// to inspect the latest response headers,
// or to cancel the request by throwing an error
if (options.hostname === "example.com") {
options.auth = "user:password";
}
};
http.request(options);
```
@ -75,6 +82,8 @@ the following per-request options are supported:
- `maxBodyLength` (default: 10MB) sets the maximum size of the request body; if exceeded, an error will be emitted.
- `beforeRedirect` (default: `undefined`) optionally change the request `options` on redirects, or abort the request by throwing an error.
- `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() }`
- `trackRedirects` (default: `false`) whether to store the redirected response details into the `redirects` array on the response object.
@ -88,7 +97,7 @@ To enable features such as caching and/or intermediate request tracking,
you might instead want to wrap `follow-redirects` around custom protocol implementations:
```javascript
var followRedirects = require('follow-redirects').wrap({
const { http, https } = require('follow-redirects').wrap({
http: require('your-custom-http'),
https: require('your-custom-https'),
});
@ -96,42 +105,26 @@ var followRedirects = require('follow-redirects').wrap({
Such custom protocols only need an implementation of the `request` method.
## Browserify Usage
## Browser Usage
Due to the way `XMLHttpRequest` works, the `browserify` versions of `http` and `https` already follow redirects.
If you are *only* targeting the browser, then this library has little value for you. If you want to write cross
platform code for node and the browser, `follow-redirects` provides a great solution for making the native node
modules behave the same as they do in browserified builds in the browser. To avoid bundling unnecessary code
you should tell browserify to swap out `follow-redirects` with the standard modules when bundling.
To make this easier, you need to change how you require the modules:
Due to the way the browser works,
the `http` and `https` browser equivalents perform redirects by default.
By requiring `follow-redirects` this way:
```javascript
var http = require('follow-redirects/http');
var https = require('follow-redirects/https');
const http = require('follow-redirects/http');
const https = require('follow-redirects/https');
```
you can easily tell webpack and friends to replace
`follow-redirect` by the built-in versions:
You can then replace `follow-redirects` in your browserify configuration like so:
```javascript
"browser": {
```json
{
"follow-redirects/http" : "http",
"follow-redirects/https" : "https"
}
```
The `browserify-http` module has not kept pace with node development, and no long behaves identically to the native
module when running in the browser. If you are experiencing problems, you may want to check out
[browserify-http-2](https://www.npmjs.com/package/http-browserify-2). It is more actively maintained and
attempts to address a few of the shortcomings of `browserify-http`. In that case, your browserify config should
look something like this:
```javascript
"browser": {
"follow-redirects/http" : "browserify-http-2/http",
"follow-redirects/https" : "browserify-http-2/https"
}
```
## Contributing
Pull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues)
@ -146,10 +139,10 @@ Pull Requests are always welcome. Please [file an issue](https://github.com/foll
## Authors
- Olivier Lalonde (olalonde@gmail.com)
- James Talmage (james@talmage.io)
- [Ruben Verborgh](https://ruben.verborgh.org/)
- [Olivier Lalonde](mailto:olalonde@gmail.com)
- [James Talmage](mailto:james@talmage.io)
## License
[https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE](MIT License)
[MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE)