mirror of
https://github.com/aljazceru/satshkd-vercel.git
synced 2025-12-17 13:14:25 +01:00
update node_modules
This commit is contained in:
61
node_modules/axios/lib/adapters/http.js
generated
vendored
61
node_modules/axios/lib/adapters/http.js
generated
vendored
@@ -13,7 +13,7 @@ var zlib = require('zlib');
|
||||
var VERSION = require('./../env/data').version;
|
||||
var createError = require('../core/createError');
|
||||
var enhanceError = require('../core/enhanceError');
|
||||
var defaults = require('../defaults');
|
||||
var transitionalDefaults = require('../defaults/transitional');
|
||||
var Cancel = require('../cancel/Cancel');
|
||||
|
||||
var isHttps = /https:?/;
|
||||
@@ -60,8 +60,10 @@ module.exports = function httpAdapter(config) {
|
||||
done();
|
||||
resolvePromise(value);
|
||||
};
|
||||
var rejected = false;
|
||||
var reject = function reject(value) {
|
||||
done();
|
||||
rejected = true;
|
||||
rejectPromise(value);
|
||||
};
|
||||
var data = config.data;
|
||||
@@ -99,6 +101,10 @@ module.exports = function httpAdapter(config) {
|
||||
));
|
||||
}
|
||||
|
||||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
||||
return reject(createError('Request body larger than maxBodyLength limit', config));
|
||||
}
|
||||
|
||||
// Add Content-Length header if data exists
|
||||
if (!headerNames['content-length']) {
|
||||
headers['Content-Length'] = data.length;
|
||||
@@ -132,6 +138,16 @@ module.exports = function httpAdapter(config) {
|
||||
var isHttpsRequest = isHttps.test(protocol);
|
||||
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
||||
|
||||
try {
|
||||
buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
|
||||
} catch (err) {
|
||||
var customErr = new Error(err.message);
|
||||
customErr.config = config;
|
||||
customErr.url = config.url;
|
||||
customErr.exists = true;
|
||||
reject(customErr);
|
||||
}
|
||||
|
||||
var options = {
|
||||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||||
method: config.method.toUpperCase(),
|
||||
@@ -269,27 +285,40 @@ module.exports = function httpAdapter(config) {
|
||||
|
||||
// make sure the content length is not over the maxContentLength if specified
|
||||
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
||||
// stream.destoy() emit aborted event before calling reject() on Node.js v16
|
||||
rejected = true;
|
||||
stream.destroy();
|
||||
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
||||
config, null, lastRequest));
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('aborted', function handlerStreamAborted() {
|
||||
if (rejected) {
|
||||
return;
|
||||
}
|
||||
stream.destroy();
|
||||
reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
|
||||
});
|
||||
|
||||
stream.on('error', function handleStreamError(err) {
|
||||
if (req.aborted) return;
|
||||
reject(enhanceError(err, config, null, lastRequest));
|
||||
});
|
||||
|
||||
stream.on('end', function handleStreamEnd() {
|
||||
var responseData = Buffer.concat(responseBuffer);
|
||||
if (config.responseType !== 'arraybuffer') {
|
||||
responseData = responseData.toString(config.responseEncoding);
|
||||
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
||||
responseData = utils.stripBOM(responseData);
|
||||
try {
|
||||
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
|
||||
if (config.responseType !== 'arraybuffer') {
|
||||
responseData = responseData.toString(config.responseEncoding);
|
||||
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
||||
responseData = utils.stripBOM(responseData);
|
||||
}
|
||||
}
|
||||
response.data = responseData;
|
||||
} catch (err) {
|
||||
reject(enhanceError(err, config, err.code, response.request, response));
|
||||
}
|
||||
|
||||
response.data = responseData;
|
||||
settle(resolve, reject, response);
|
||||
});
|
||||
}
|
||||
@@ -301,6 +330,12 @@ module.exports = function httpAdapter(config) {
|
||||
reject(enhanceError(err, config, null, req));
|
||||
});
|
||||
|
||||
// set tcp keep alive to prevent drop connection by peer
|
||||
req.on('socket', function handleRequestSocket(socket) {
|
||||
// default interval of sending ack packet is 1 minute
|
||||
socket.setKeepAlive(true, 1000 * 60);
|
||||
});
|
||||
|
||||
// Handle request timeout
|
||||
if (config.timeout) {
|
||||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
||||
@@ -324,9 +359,15 @@ module.exports = function httpAdapter(config) {
|
||||
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
||||
req.setTimeout(timeout, function handleRequestTimeout() {
|
||||
req.abort();
|
||||
var transitional = config.transitional || defaults.transitional;
|
||||
var timeoutErrorMessage = '';
|
||||
if (config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||||
} else {
|
||||
timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
|
||||
}
|
||||
var transitional = config.transitional || transitionalDefaults;
|
||||
reject(createError(
|
||||
'timeout of ' + timeout + 'ms exceeded',
|
||||
timeoutErrorMessage,
|
||||
config,
|
||||
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
||||
req
|
||||
|
||||
Reference in New Issue
Block a user