mirror of
https://github.com/tenrok/axios.git
synced 2026-06-05 16:42:32 +03:00
Adding support for beforeRedirect config option (#3852)
* Adding support for beforeRedirect config option * Adding tests for beforeRedirect * Update README.md Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com> * fix types Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -227,6 +227,9 @@ module.exports = function httpAdapter(config) {
|
||||
if (config.maxRedirects) {
|
||||
options.maxRedirects = config.maxRedirects;
|
||||
}
|
||||
if (config.beforeRedirect) {
|
||||
options.beforeRedirect = config.beforeRedirect;
|
||||
}
|
||||
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
||||
}
|
||||
|
||||
@@ -326,7 +329,7 @@ module.exports = function httpAdapter(config) {
|
||||
|
||||
// Handle errors
|
||||
req.on('error', function handleRequestError(err) {
|
||||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
|
||||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') reject(err);
|
||||
reject(enhanceError(err, config, null, req));
|
||||
});
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ module.exports = function mergeConfig(config1, config2) {
|
||||
'decompress': defaultToConfig2,
|
||||
'maxContentLength': defaultToConfig2,
|
||||
'maxBodyLength': defaultToConfig2,
|
||||
'beforeRedirect': defaultToConfig2,
|
||||
'transport': defaultToConfig2,
|
||||
'httpAgent': defaultToConfig2,
|
||||
'httpsAgent': defaultToConfig2,
|
||||
|
||||
Reference in New Issue
Block a user