mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix: fixed missed dispatchBeforeRedirect argument (#5778)
Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This commit is contained in:
+1
-1
@@ -396,7 +396,7 @@ declare namespace axios {
|
|||||||
maxBodyLength?: number;
|
maxBodyLength?: number;
|
||||||
maxRedirects?: number;
|
maxRedirects?: number;
|
||||||
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
||||||
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
|
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
|
||||||
socketPath?: string | null;
|
socketPath?: string | null;
|
||||||
transport?: any;
|
transport?: any;
|
||||||
httpAgent?: any;
|
httpAgent?: any;
|
||||||
|
|||||||
Vendored
+1
-1
@@ -337,7 +337,7 @@ export interface AxiosRequestConfig<D = any> {
|
|||||||
maxBodyLength?: number;
|
maxBodyLength?: number;
|
||||||
maxRedirects?: number;
|
maxRedirects?: number;
|
||||||
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
||||||
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void;
|
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
|
||||||
socketPath?: string | null;
|
socketPath?: string | null;
|
||||||
transport?: any;
|
transport?: any;
|
||||||
httpAgent?: any;
|
httpAgent?: any;
|
||||||
|
|||||||
@@ -53,12 +53,12 @@ const supportedProtocols = platform.protocols.map(protocol => {
|
|||||||
*
|
*
|
||||||
* @returns {Object<string, any>}
|
* @returns {Object<string, any>}
|
||||||
*/
|
*/
|
||||||
function dispatchBeforeRedirect(options) {
|
function dispatchBeforeRedirect(options, responseDetails) {
|
||||||
if (options.beforeRedirects.proxy) {
|
if (options.beforeRedirects.proxy) {
|
||||||
options.beforeRedirects.proxy(options);
|
options.beforeRedirects.proxy(options);
|
||||||
}
|
}
|
||||||
if (options.beforeRedirects.config) {
|
if (options.beforeRedirects.config) {
|
||||||
options.beforeRedirects.config(options);
|
options.beforeRedirects.config(options, responseDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ describe('supports http with nodejs', function () {
|
|||||||
}).listen(4444, function () {
|
}).listen(4444, function () {
|
||||||
axios.get('http://localhost:4444/', {
|
axios.get('http://localhost:4444/', {
|
||||||
maxRedirects: 3,
|
maxRedirects: 3,
|
||||||
beforeRedirect: function (options) {
|
beforeRedirect: function (options, responseDetails) {
|
||||||
if (options.path === '/foo') {
|
if (options.path === '/foo' && responseDetails.headers.location === '/foo') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Provided path is not allowed'
|
'Provided path is not allowed'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user