forked from waja/action-debian-package
node_modules: update
This commit is contained in:
parent
4a21c51f2f
commit
b91baffed3
107 changed files with 3886 additions and 2943 deletions
81
node_modules/follow-redirects/README.md
generated
vendored
81
node_modules/follow-redirects/README.md
generated
vendored
|
@ -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.
|
||||
|
||||
[](https://www.npmjs.com/package/follow-redirects)
|
||||
[](https://travis-ci.org/follow-redirects/follow-redirects)
|
||||
[](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)
|
||||
[](https://david-dm.org/follow-redirects/follow-redirects)
|
||||
[](https://www.npmjs.com/package/follow-redirects)
|
||||
[](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)
|
||||
|
|
9
node_modules/follow-redirects/debug.js
generated
vendored
Normal file
9
node_modules/follow-redirects/debug.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
var debug;
|
||||
try {
|
||||
/* eslint global-require: off */
|
||||
debug = require("debug")("follow-redirects");
|
||||
}
|
||||
catch (error) {
|
||||
debug = function () { /* */ };
|
||||
}
|
||||
module.exports = debug;
|
356
node_modules/follow-redirects/index.js
generated
vendored
356
node_modules/follow-redirects/index.js
generated
vendored
|
@ -1,44 +1,50 @@
|
|||
var url = require("url");
|
||||
var URL = url.URL;
|
||||
var http = require("http");
|
||||
var https = require("https");
|
||||
var assert = require("assert");
|
||||
var Writable = require("stream").Writable;
|
||||
var debug = require("debug")("follow-redirects");
|
||||
|
||||
// RFC7231§4.2.1: Of the request methods defined by this specification,
|
||||
// the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
|
||||
var SAFE_METHODS = { GET: true, HEAD: true, OPTIONS: true, TRACE: true };
|
||||
var assert = require("assert");
|
||||
var debug = require("./debug");
|
||||
|
||||
// Create handlers that pass events from native requests
|
||||
var eventHandlers = Object.create(null);
|
||||
["abort", "aborted", "error", "socket", "timeout"].forEach(function (event) {
|
||||
eventHandlers[event] = function (arg) {
|
||||
this._redirectable.emit(event, arg);
|
||||
["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) {
|
||||
eventHandlers[event] = function (arg1, arg2, arg3) {
|
||||
this._redirectable.emit(event, arg1, arg2, arg3);
|
||||
};
|
||||
});
|
||||
|
||||
// Error types with codes
|
||||
var RedirectionError = createErrorType(
|
||||
"ERR_FR_REDIRECTION_FAILURE",
|
||||
""
|
||||
);
|
||||
var TooManyRedirectsError = createErrorType(
|
||||
"ERR_FR_TOO_MANY_REDIRECTS",
|
||||
"Maximum number of redirects exceeded"
|
||||
);
|
||||
var MaxBodyLengthExceededError = createErrorType(
|
||||
"ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
|
||||
"Request body larger than maxBodyLength limit"
|
||||
);
|
||||
var WriteAfterEndError = createErrorType(
|
||||
"ERR_STREAM_WRITE_AFTER_END",
|
||||
"write after end"
|
||||
);
|
||||
|
||||
// An HTTP(S) request that can be redirected
|
||||
function RedirectableRequest(options, responseCallback) {
|
||||
// Initialize the request
|
||||
Writable.call(this);
|
||||
options.headers = options.headers || {};
|
||||
this._sanitizeOptions(options);
|
||||
this._options = options;
|
||||
this._ended = false;
|
||||
this._ending = false;
|
||||
this._redirectCount = 0;
|
||||
this._redirects = [];
|
||||
this._requestBodyLength = 0;
|
||||
this._requestBodyBuffers = [];
|
||||
|
||||
// Since http.request treats host as an alias of hostname,
|
||||
// but the url module interprets host as hostname plus port,
|
||||
// eliminate the host property to avoid confusion.
|
||||
if (options.host) {
|
||||
// Use hostname if set, because it has precedence
|
||||
if (!options.hostname) {
|
||||
options.hostname = options.host;
|
||||
}
|
||||
delete options.host;
|
||||
}
|
||||
|
||||
// Attach a callback if passed
|
||||
if (responseCallback) {
|
||||
this.on("response", responseCallback);
|
||||
|
@ -50,18 +56,6 @@ function RedirectableRequest(options, responseCallback) {
|
|||
self._processResponse(response);
|
||||
};
|
||||
|
||||
// Complete the URL object when necessary
|
||||
if (!options.pathname && options.path) {
|
||||
var searchPos = options.path.indexOf("?");
|
||||
if (searchPos < 0) {
|
||||
options.pathname = options.path;
|
||||
}
|
||||
else {
|
||||
options.pathname = options.path.substring(0, searchPos);
|
||||
options.search = options.path.substring(searchPos);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the first request
|
||||
this._performRequest();
|
||||
}
|
||||
|
@ -69,9 +63,14 @@ RedirectableRequest.prototype = Object.create(Writable.prototype);
|
|||
|
||||
// Writes buffered data to the current native request
|
||||
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
||||
// Writing is not allowed if end has been called
|
||||
if (this._ending) {
|
||||
throw new WriteAfterEndError();
|
||||
}
|
||||
|
||||
// Validate input and shift parameters if necessary
|
||||
if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
|
||||
throw new Error("data should be a string, Buffer or Uint8Array");
|
||||
throw new TypeError("data should be a string, Buffer or Uint8Array");
|
||||
}
|
||||
if (typeof encoding === "function") {
|
||||
callback = encoding;
|
||||
|
@ -94,7 +93,7 @@ RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
|||
}
|
||||
// Error when we exceed the maximum body length
|
||||
else {
|
||||
this.emit("error", new Error("Request body larger than maxBodyLength limit"));
|
||||
this.emit("error", new MaxBodyLengthExceededError());
|
||||
this.abort();
|
||||
}
|
||||
};
|
||||
|
@ -111,11 +110,20 @@ RedirectableRequest.prototype.end = function (data, encoding, callback) {
|
|||
encoding = null;
|
||||
}
|
||||
|
||||
// Write data and end
|
||||
var currentRequest = this._currentRequest;
|
||||
this.write(data || "", encoding, function () {
|
||||
currentRequest.end(null, null, callback);
|
||||
});
|
||||
// Write data if needed and end
|
||||
if (!data) {
|
||||
this._ended = this._ending = true;
|
||||
this._currentRequest.end(null, null, callback);
|
||||
}
|
||||
else {
|
||||
var self = this;
|
||||
var currentRequest = this._currentRequest;
|
||||
this.write(data, encoding, function () {
|
||||
self._ended = true;
|
||||
currentRequest.end(null, null, callback);
|
||||
});
|
||||
this._ending = true;
|
||||
}
|
||||
};
|
||||
|
||||
// Sets a header value on the current native request
|
||||
|
@ -130,10 +138,43 @@ RedirectableRequest.prototype.removeHeader = function (name) {
|
|||
this._currentRequest.removeHeader(name);
|
||||
};
|
||||
|
||||
// Global timeout for all underlying requests
|
||||
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
||||
if (callback) {
|
||||
this.once("timeout", callback);
|
||||
}
|
||||
|
||||
if (this.socket) {
|
||||
startTimer(this, msecs);
|
||||
}
|
||||
else {
|
||||
var self = this;
|
||||
this._currentRequest.once("socket", function () {
|
||||
startTimer(self, msecs);
|
||||
});
|
||||
}
|
||||
|
||||
this.once("response", clearTimer);
|
||||
this.once("error", clearTimer);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
function startTimer(request, msecs) {
|
||||
clearTimeout(request._timeout);
|
||||
request._timeout = setTimeout(function () {
|
||||
request.emit("timeout");
|
||||
}, msecs);
|
||||
}
|
||||
|
||||
function clearTimer() {
|
||||
clearTimeout(this._timeout);
|
||||
}
|
||||
|
||||
// Proxy all other public ClientRequest methods
|
||||
[
|
||||
"abort", "flushHeaders", "getHeader",
|
||||
"setNoDelay", "setSocketKeepAlive", "setTimeout",
|
||||
"setNoDelay", "setSocketKeepAlive",
|
||||
].forEach(function (method) {
|
||||
RedirectableRequest.prototype[method] = function (a, b) {
|
||||
return this._currentRequest[method](a, b);
|
||||
|
@ -147,13 +188,44 @@ RedirectableRequest.prototype.removeHeader = function (name) {
|
|||
});
|
||||
});
|
||||
|
||||
RedirectableRequest.prototype._sanitizeOptions = function (options) {
|
||||
// Ensure headers are always present
|
||||
if (!options.headers) {
|
||||
options.headers = {};
|
||||
}
|
||||
|
||||
// Since http.request treats host as an alias of hostname,
|
||||
// but the url module interprets host as hostname plus port,
|
||||
// eliminate the host property to avoid confusion.
|
||||
if (options.host) {
|
||||
// Use hostname if set, because it has precedence
|
||||
if (!options.hostname) {
|
||||
options.hostname = options.host;
|
||||
}
|
||||
delete options.host;
|
||||
}
|
||||
|
||||
// Complete the URL object when necessary
|
||||
if (!options.pathname && options.path) {
|
||||
var searchPos = options.path.indexOf("?");
|
||||
if (searchPos < 0) {
|
||||
options.pathname = options.path;
|
||||
}
|
||||
else {
|
||||
options.pathname = options.path.substring(0, searchPos);
|
||||
options.search = options.path.substring(searchPos);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Executes the next native request (initial or redirect)
|
||||
RedirectableRequest.prototype._performRequest = function () {
|
||||
// Load the native protocol
|
||||
var protocol = this._options.protocol;
|
||||
var nativeProtocol = this._options.nativeProtocols[protocol];
|
||||
if (!nativeProtocol) {
|
||||
this.emit("error", new Error("Unsupported protocol " + protocol));
|
||||
this.emit("error", new TypeError("Unsupported protocol " + protocol));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -183,14 +255,29 @@ RedirectableRequest.prototype._performRequest = function () {
|
|||
if (this._isRedirect) {
|
||||
// Write the request entity and end.
|
||||
var i = 0;
|
||||
var self = this;
|
||||
var buffers = this._requestBodyBuffers;
|
||||
(function writeNext() {
|
||||
if (i < buffers.length) {
|
||||
var buffer = buffers[i++];
|
||||
request.write(buffer.data, buffer.encoding, writeNext);
|
||||
}
|
||||
else {
|
||||
request.end();
|
||||
(function writeNext(error) {
|
||||
// Only write if this request has not been redirected yet
|
||||
/* istanbul ignore else */
|
||||
if (request === self._currentRequest) {
|
||||
// Report any write errors
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
self.emit("error", error);
|
||||
}
|
||||
// Write the next buffer if there are still left
|
||||
else if (i < buffers.length) {
|
||||
var buffer = buffers[i++];
|
||||
/* istanbul ignore else */
|
||||
if (!request.finished) {
|
||||
request.write(buffer.data, buffer.encoding, writeNext);
|
||||
}
|
||||
}
|
||||
// End the request if `end` has been called on us
|
||||
else if (self._ended) {
|
||||
request.end();
|
||||
}
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
@ -199,11 +286,12 @@ RedirectableRequest.prototype._performRequest = function () {
|
|||
// Processes a response from the current native request
|
||||
RedirectableRequest.prototype._processResponse = function (response) {
|
||||
// Store the redirected response
|
||||
var statusCode = response.statusCode;
|
||||
if (this._options.trackRedirects) {
|
||||
this._redirects.push({
|
||||
url: this._currentUrl,
|
||||
headers: response.headers,
|
||||
statusCode: response.statusCode,
|
||||
statusCode: statusCode,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -215,52 +303,75 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|||
// even if the specific status code is not understood.
|
||||
var location = response.headers.location;
|
||||
if (location && this._options.followRedirects !== false &&
|
||||
response.statusCode >= 300 && response.statusCode < 400) {
|
||||
statusCode >= 300 && statusCode < 400) {
|
||||
// Abort the current request
|
||||
this._currentRequest.removeAllListeners();
|
||||
this._currentRequest.on("error", noop);
|
||||
this._currentRequest.abort();
|
||||
// Discard the remainder of the response to avoid waiting for data
|
||||
response.destroy();
|
||||
|
||||
// RFC7231§6.4: A client SHOULD detect and intervene
|
||||
// in cyclical redirections (i.e., "infinite" redirection loops).
|
||||
if (++this._redirectCount > this._options.maxRedirects) {
|
||||
this.emit("error", new Error("Max redirects exceeded."));
|
||||
this.emit("error", new TooManyRedirectsError());
|
||||
return;
|
||||
}
|
||||
|
||||
// RFC7231§6.4: Automatic redirection needs to done with
|
||||
// care for methods not known to be safe […],
|
||||
// since the user might not wish to redirect an unsafe request.
|
||||
// RFC7231§6.4.7: The 307 (Temporary Redirect) status code indicates
|
||||
// that the target resource resides temporarily under a different URI
|
||||
// and the user agent MUST NOT change the request method
|
||||
// if it performs an automatic redirection to that URI.
|
||||
var header;
|
||||
var headers = this._options.headers;
|
||||
if (response.statusCode !== 307 && !(this._options.method in SAFE_METHODS)) {
|
||||
// care for methods not known to be safe, […]
|
||||
// RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
|
||||
// the request method from POST to GET for the subsequent request.
|
||||
if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
|
||||
// RFC7231§6.4.4: The 303 (See Other) status code indicates that
|
||||
// the server is redirecting the user agent to a different resource […]
|
||||
// A user agent can perform a retrieval request targeting that URI
|
||||
// (a GET or HEAD request if using HTTP) […]
|
||||
(statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
|
||||
this._options.method = "GET";
|
||||
// Drop a possible entity and headers related to it
|
||||
this._requestBodyBuffers = [];
|
||||
for (header in headers) {
|
||||
if (/^content-/i.test(header)) {
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
removeMatchingHeaders(/^content-/i, this._options.headers);
|
||||
}
|
||||
|
||||
// Drop the Host header, as the redirect might lead to a different host
|
||||
if (!this._isRedirect) {
|
||||
for (header in headers) {
|
||||
if (/^host$/i.test(header)) {
|
||||
delete headers[header];
|
||||
}
|
||||
var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||
|
||||
url.parse(this._currentUrl).hostname;
|
||||
|
||||
// Create the redirected request
|
||||
var redirectUrl = url.resolve(this._currentUrl, location);
|
||||
debug("redirecting to", redirectUrl);
|
||||
this._isRedirect = true;
|
||||
var redirectUrlParts = url.parse(redirectUrl);
|
||||
Object.assign(this._options, redirectUrlParts);
|
||||
|
||||
// Drop the Authorization header if redirecting to another host
|
||||
if (redirectUrlParts.hostname !== previousHostName) {
|
||||
removeMatchingHeaders(/^authorization$/i, this._options.headers);
|
||||
}
|
||||
|
||||
// Evaluate the beforeRedirect callback
|
||||
if (typeof this._options.beforeRedirect === "function") {
|
||||
var responseDetails = { headers: response.headers };
|
||||
try {
|
||||
this._options.beforeRedirect.call(null, this._options, responseDetails);
|
||||
}
|
||||
catch (err) {
|
||||
this.emit("error", err);
|
||||
return;
|
||||
}
|
||||
this._sanitizeOptions(this._options);
|
||||
}
|
||||
|
||||
// Perform the redirected request
|
||||
var redirectUrl = url.resolve(this._currentUrl, location);
|
||||
debug("redirecting to", redirectUrl);
|
||||
Object.assign(this._options, url.parse(redirectUrl));
|
||||
this._isRedirect = true;
|
||||
this._performRequest();
|
||||
|
||||
// Discard the remainder of the response to avoid waiting for data
|
||||
response.destroy();
|
||||
try {
|
||||
this._performRequest();
|
||||
}
|
||||
catch (cause) {
|
||||
var error = new RedirectionError("Redirected request failed: " + cause.message);
|
||||
error.cause = cause;
|
||||
this.emit("error", error);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The response is not a redirect; return it as-is
|
||||
|
@ -289,27 +400,46 @@ function wrap(protocols) {
|
|||
var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
|
||||
|
||||
// Executes a request, following redirects
|
||||
wrappedProtocol.request = function (options, callback) {
|
||||
if (typeof options === "string") {
|
||||
options = url.parse(options);
|
||||
options.maxRedirects = exports.maxRedirects;
|
||||
wrappedProtocol.request = function (input, options, callback) {
|
||||
// Parse parameters
|
||||
if (typeof input === "string") {
|
||||
var urlStr = input;
|
||||
try {
|
||||
input = urlToOptions(new URL(urlStr));
|
||||
}
|
||||
catch (err) {
|
||||
/* istanbul ignore next */
|
||||
input = url.parse(urlStr);
|
||||
}
|
||||
}
|
||||
else if (URL && (input instanceof URL)) {
|
||||
input = urlToOptions(input);
|
||||
}
|
||||
else {
|
||||
options = Object.assign({
|
||||
protocol: protocol,
|
||||
maxRedirects: exports.maxRedirects,
|
||||
maxBodyLength: exports.maxBodyLength,
|
||||
}, options);
|
||||
callback = options;
|
||||
options = input;
|
||||
input = { protocol: protocol };
|
||||
}
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
// Set defaults
|
||||
options = Object.assign({
|
||||
maxRedirects: exports.maxRedirects,
|
||||
maxBodyLength: exports.maxBodyLength,
|
||||
}, input, options);
|
||||
options.nativeProtocols = nativeProtocols;
|
||||
|
||||
assert.equal(options.protocol, protocol, "protocol mismatch");
|
||||
debug("options", options);
|
||||
return new RedirectableRequest(options, callback);
|
||||
};
|
||||
|
||||
// Executes a GET request, following redirects
|
||||
wrappedProtocol.get = function (options, callback) {
|
||||
var request = wrappedProtocol.request(options, callback);
|
||||
wrappedProtocol.get = function (input, options, callback) {
|
||||
var request = wrappedProtocol.request(input, options, callback);
|
||||
request.end();
|
||||
return request;
|
||||
};
|
||||
|
@ -317,6 +447,52 @@ function wrap(protocols) {
|
|||
return exports;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function noop() { /* empty */ }
|
||||
|
||||
// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
||||
function urlToOptions(urlObject) {
|
||||
var options = {
|
||||
protocol: urlObject.protocol,
|
||||
hostname: urlObject.hostname.startsWith("[") ?
|
||||
/* istanbul ignore next */
|
||||
urlObject.hostname.slice(1, -1) :
|
||||
urlObject.hostname,
|
||||
hash: urlObject.hash,
|
||||
search: urlObject.search,
|
||||
pathname: urlObject.pathname,
|
||||
path: urlObject.pathname + urlObject.search,
|
||||
href: urlObject.href,
|
||||
};
|
||||
if (urlObject.port !== "") {
|
||||
options.port = Number(urlObject.port);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function removeMatchingHeaders(regex, headers) {
|
||||
var lastValue;
|
||||
for (var header in headers) {
|
||||
if (regex.test(header)) {
|
||||
lastValue = headers[header];
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
function createErrorType(code, defaultMessage) {
|
||||
function CustomError(message) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.message = message || defaultMessage;
|
||||
}
|
||||
CustomError.prototype = new Error();
|
||||
CustomError.prototype.constructor = CustomError;
|
||||
CustomError.prototype.name = "Error [" + code + "]";
|
||||
CustomError.prototype.code = code;
|
||||
return CustomError;
|
||||
}
|
||||
|
||||
// Exports
|
||||
module.exports = wrap({ http: http, https: https });
|
||||
module.exports.wrap = wrap;
|
||||
|
|
54
node_modules/follow-redirects/package.json
generated
vendored
54
node_modules/follow-redirects/package.json
generated
vendored
|
@ -1,26 +1,26 @@
|
|||
{
|
||||
"_from": "follow-redirects@1.5.10",
|
||||
"_id": "follow-redirects@1.5.10",
|
||||
"_from": "follow-redirects@^1.10.0",
|
||||
"_id": "follow-redirects@1.13.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||
"_integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
|
||||
"_location": "/follow-redirects",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "follow-redirects@1.5.10",
|
||||
"raw": "follow-redirects@^1.10.0",
|
||||
"name": "follow-redirects",
|
||||
"escapedName": "follow-redirects",
|
||||
"rawSpec": "1.5.10",
|
||||
"rawSpec": "^1.10.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.5.10"
|
||||
"fetchSpec": "^1.10.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/axios"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||
"_shasum": "7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a",
|
||||
"_spec": "follow-redirects@1.5.10",
|
||||
"_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
|
||||
"_shasum": "b42e8d93a2a7eea5ed88633676d6597bc8e384db",
|
||||
"_spec": "follow-redirects@^1.10.0",
|
||||
"_where": "/home/dawidd6/github/dawidd6/action-debian-package/node_modules/axios",
|
||||
"author": {
|
||||
"name": "Ruben Verborgh",
|
||||
|
@ -42,27 +42,27 @@
|
|||
"email": "james@talmage.io"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "=3.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "HTTP and HTTPS modules that follow redirects.",
|
||||
"devDependencies": {
|
||||
"concat-stream": "^1.6.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"eslint": "^4.19.1",
|
||||
"express": "^4.16.2",
|
||||
"mocha": "^5.0.0",
|
||||
"nyc": "^11.8.0"
|
||||
"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"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"create.js",
|
||||
"http.js",
|
||||
"https.js"
|
||||
"*.js"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/follow-redirects/follow-redirects",
|
||||
"keywords": [
|
||||
|
@ -77,12 +77,6 @@
|
|||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "follow-redirects",
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
|
||||
|
@ -92,5 +86,5 @@
|
|||
"mocha": "nyc mocha",
|
||||
"test": "npm run lint && npm run mocha"
|
||||
},
|
||||
"version": "1.5.10"
|
||||
"version": "1.13.0"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue