follow-redirects 1.12.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of follow-redirects might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/README.md +5 -3
  2. package/index.js +2 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,13 +28,14 @@ You can inspect the final redirected URL through the `responseUrl` property on t
28
28
  If no redirection happened, `responseUrl` is the original request URL.
29
29
 
30
30
  ```javascript
31
- https.request({
31
+ const request = https.request({
32
32
  host: 'bitly.com',
33
33
  path: '/UHfDGO',
34
34
  }, response => {
35
35
  console.log(response.responseUrl);
36
36
  // 'http://duckduckgo.com/robots.txt'
37
37
  });
38
+ request.end();
38
39
  ```
39
40
 
40
41
  ## Options
@@ -62,8 +63,9 @@ const { http, https } = require('follow-redirects');
62
63
 
63
64
  const options = url.parse('http://bit.ly/900913');
64
65
  options.maxRedirects = 10;
65
- options.beforeRedirect = options => {
66
- // Use this function to adjust the options upon redirecting,
66
+ options.beforeRedirect = (options, { headers }) => {
67
+ // Use this to adjust the request options upon redirecting,
68
+ // to inspect the latest response headers,
67
69
  // or to cancel the request by throwing an error
68
70
  if (options.hostname === "example.com") {
69
71
  options.auth = "user:password";
package/index.js CHANGED
@@ -352,8 +352,9 @@ RedirectableRequest.prototype._processResponse = function (response) {
352
352
 
353
353
  // Evaluate the beforeRedirect callback
354
354
  if (typeof this._options.beforeRedirect === "function") {
355
+ var responseDetails = { headers: response.headers };
355
356
  try {
356
- this._options.beforeRedirect.call(null, this._options);
357
+ this._options.beforeRedirect.call(null, this._options, responseDetails);
357
358
  }
358
359
  catch (err) {
359
360
  this.emit("error", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "follow-redirects",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "HTTP and HTTPS modules that follow redirects.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",