mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-10-09 09:59:45 +07:00
node_modules: update (#338)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
1 parent
e1936242ed
commit
a9c5eb6c35
39 files changed
+799
-388
No files matched your search
+34
-59
@@ -47,6 +47,10 @@ const node_net_1 = __importDefault(require("node:net"));
|
||||
const errors = __importStar(require("../errors.js"));
|
||||
const objects_js_1 = require("../shared/objects.js");
|
||||
const MAX_REDIRECTS = 5;
|
||||
// a stalled server would otherwise hold the request, and whatever waits on it, open forever
|
||||
const DEFAULT_TIMEOUT = 60 * 1000;
|
||||
// the body is usually buffered in memory by the caller, so an unbounded download is refused
|
||||
const DEFAULT_MAX_BYTES = 64 * 1024 * 1024;
|
||||
// Only genuine TLS settings are taken from options.tls. That object reaches us straight
|
||||
// from a user supplied attachment (content.tls), so keys like host, port, path, socketPath
|
||||
// or lookup would otherwise repoint the request at a destination that never went through
|
||||
@@ -252,28 +256,22 @@ function nmfetch(url, options) {
|
||||
});
|
||||
return fetchRes;
|
||||
}
|
||||
if (options.timeout) {
|
||||
req.setTimeout(options.timeout, () => {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
req.abort();
|
||||
const err = new Error('Request Timeout');
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
});
|
||||
}
|
||||
req.on('error', (err) => {
|
||||
// reports the first failure of this request on fetchRes and releases the request
|
||||
const fail = (err, sourceUrl = url) => {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
err.sourceUrl = sourceUrl;
|
||||
fetchRes.emit('error', err);
|
||||
});
|
||||
req.abort();
|
||||
};
|
||||
const timeout = typeof options.timeout === 'number' && options.timeout >= 0 ? options.timeout : DEFAULT_TIMEOUT;
|
||||
if (timeout) {
|
||||
req.setTimeout(timeout, () => fail(new Error('Request Timeout')));
|
||||
}
|
||||
req.on('error', (err) => fail(err));
|
||||
req.on('response', res => {
|
||||
let inflate;
|
||||
if (finished) {
|
||||
@@ -294,13 +292,7 @@ function nmfetch(url, options) {
|
||||
// redirect
|
||||
options.redirects++;
|
||||
if (options.redirects > options.maxRedirects) {
|
||||
finished = true;
|
||||
const err = new Error('Maximum redirect count exceeded');
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
req.abort();
|
||||
return;
|
||||
return fail(new Error('Maximum redirect count exceeded'));
|
||||
}
|
||||
// redirect does not include POST body
|
||||
options.method = 'GET';
|
||||
@@ -320,13 +312,7 @@ function nmfetch(url, options) {
|
||||
// call: that call gets its own `finished` flag and no handle on this
|
||||
// request, so this one would stay open and could emit a second error on
|
||||
// the shared fetchRes once it times out. Callers listen with req.once().
|
||||
finished = true;
|
||||
const err = new Error('Unsupported protocol for URL ' + redirectUrl);
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = redirectUrl;
|
||||
fetchRes.emit('error', err);
|
||||
req.abort();
|
||||
return;
|
||||
return fail(new Error('Unsupported protocol for URL ' + redirectUrl), redirectUrl);
|
||||
}
|
||||
// Do not forward credentials when the redirect leaves the original
|
||||
// security context: a different host, or a downgrade from https to
|
||||
@@ -343,41 +329,33 @@ function nmfetch(url, options) {
|
||||
}
|
||||
});
|
||||
}
|
||||
// this request is done with, release it so its socket and timeout do not
|
||||
// outlive it and report a late error on the shared fetchRes
|
||||
finished = true;
|
||||
res.resume();
|
||||
req.abort();
|
||||
return nmfetch(redirectUrl, options);
|
||||
}
|
||||
fetchRes.statusCode = res.statusCode;
|
||||
fetchRes.headers = res.headers;
|
||||
if (res.statusCode >= 300 && !options.allowErrorResponse) {
|
||||
finished = true;
|
||||
const err = new Error('Invalid status code ' + res.statusCode);
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
req.abort();
|
||||
return;
|
||||
return fail(new Error('Invalid status code ' + res.statusCode));
|
||||
}
|
||||
res.on('error', (err) => {
|
||||
if (finished) {
|
||||
res.on('error', (err) => fail(err));
|
||||
const maxBytes = typeof options.maxBytes === 'number' && options.maxBytes > 0 ? options.maxBytes : DEFAULT_MAX_BYTES;
|
||||
const source = inflate || res;
|
||||
let received = 0;
|
||||
source.on('data', (chunk) => {
|
||||
received += chunk.length;
|
||||
if (received <= maxBytes || finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
req.abort();
|
||||
source.unpipe(fetchRes);
|
||||
fail(new Error('Response size exceeds the allowed ' + maxBytes + ' bytes'));
|
||||
});
|
||||
if (inflate) {
|
||||
res.pipe(inflate).pipe(fetchRes);
|
||||
inflate.on('error', (err) => {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
req.abort();
|
||||
});
|
||||
inflate.on('error', (err) => fail(err));
|
||||
}
|
||||
else {
|
||||
res.pipe(fetchRes);
|
||||
@@ -392,11 +370,7 @@ function nmfetch(url, options) {
|
||||
req.write(body);
|
||||
}
|
||||
catch (err) {
|
||||
finished = true;
|
||||
err.code = errors.EFETCH;
|
||||
err.sourceUrl = url;
|
||||
fetchRes.emit('error', err);
|
||||
return;
|
||||
return fail(err);
|
||||
}
|
||||
}
|
||||
req.end();
|
||||
@@ -404,6 +378,7 @@ function nmfetch(url, options) {
|
||||
return fetchRes;
|
||||
}
|
||||
nmfetch.Cookies = cookies_js_1.default;
|
||||
nmfetch.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
||||
exports.default = nmfetch;
|
||||
module.exports = exports.default;
|
||||
Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
|
||||
Reference in new issue
Block a user