mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Fixing proxy beforeRedirect regression (#4708)
This commit is contained in:
+14
-3
@@ -20,6 +20,15 @@ var isHttps = /https:?/;
|
||||
|
||||
var supportedProtocols = [ 'http:', 'https:', 'file:' ];
|
||||
|
||||
function dispatchBeforeRedirect(options) {
|
||||
if (options.beforeRedirects.proxy) {
|
||||
options.beforeRedirects.proxy(options);
|
||||
}
|
||||
if (options.beforeRedirects.config) {
|
||||
options.beforeRedirects.config(options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {http.ClientRequestArgs} options
|
||||
@@ -59,7 +68,7 @@ function setProxy(options, configProxy, location) {
|
||||
}
|
||||
}
|
||||
|
||||
options.beforeRedirect = function beforeRedirect(redirectOptions) {
|
||||
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
||||
// Configure proxy for redirected request, passing the original config proxy to apply
|
||||
// the exact same logic as if the redirected request was performed by axios directly.
|
||||
setProxy(redirectOptions, configProxy, redirectOptions.href);
|
||||
@@ -190,7 +199,9 @@ module.exports = function httpAdapter(config) {
|
||||
headers: headers,
|
||||
agents: { http: config.httpAgent, https: config.httpsAgent },
|
||||
auth: auth,
|
||||
protocol: protocol
|
||||
protocol: protocol,
|
||||
beforeRedirect: dispatchBeforeRedirect,
|
||||
beforeRedirects: {}
|
||||
};
|
||||
|
||||
if (config.socketPath) {
|
||||
@@ -213,7 +224,7 @@ module.exports = function httpAdapter(config) {
|
||||
options.maxRedirects = config.maxRedirects;
|
||||
}
|
||||
if (config.beforeRedirect) {
|
||||
options.beforeRedirect = config.beforeRedirect;
|
||||
options.beforeRedirects.config = config.beforeRedirect;
|
||||
}
|
||||
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user