|
1104 | 1104 | meta_sources: {}, |
1105 | 1105 | vars_sources: {}, |
1106 | 1106 |
|
1107 | | - redirects: options.redirectsHistory || [], |
| 1107 | + redirects: options._redirectsInfo || [], |
1108 | 1108 | time: options?.totalTimer() |
1109 | 1109 | }; |
1110 | 1110 |
|
|
1376 | 1376 | var r = result[i]; |
1377 | 1377 | var redirect = r.error && r.error[SYS_ERRORS.redirect]; |
1378 | 1378 | if (typeof redirect === "string") { |
1379 | | - log(' -- plugin redirect (by "' + r.method.pluginId + '")', redirect); |
1380 | | - return redirect; |
| 1379 | + log(' -- plugin redirect (by "' + r.method.pluginId + '")', redirect, r.error.status); |
| 1380 | + return { |
| 1381 | + url: redirect, |
| 1382 | + status: r.error.status |
| 1383 | + }; |
1381 | 1384 | } else if (redirect && typeof redirect !== "string") { |
1382 | 1385 | log(' -- skip plugin redirect, not string (by "' + r.method.pluginId + '")', redirect); |
1383 | 1386 | } |
|
1829 | 1832 | getResultErrorMessages(result, allResults); |
1830 | 1833 |
|
1831 | 1834 | // Find redirect command. |
1832 | | - var redirect = findRedirectError(result); |
1833 | | - if (redirect) { |
| 1835 | + var redirect_data = findRedirectError(result); |
| 1836 | + if (redirect_data && redirect_data.url) { |
1834 | 1837 | abortCurrentRequest(); |
1835 | | - if (!redirect.match(/^https?:\/\//)) { |
1836 | | - redirect = urlLib.resolve(uri, redirect); |
| 1838 | + if (!redirect_data.url.match(/^https?:\/\//)) { |
| 1839 | + redirect_data.url = urlLib.resolve(uri, redirect_data.url); |
1837 | 1840 | } |
1838 | 1841 | options.redirectsCount = (options.redirectsCount || 0) + 1; |
1839 | 1842 | options.redirectsHistory = options.redirectsHistory || []; |
1840 | 1843 | options.redirectsHistory.push(uri); |
1841 | | - run(redirect, options, cb); |
| 1844 | + |
| 1845 | + if (options.debug_sources) { |
| 1846 | + options._redirectsInfo = options._redirectsInfo || []; |
| 1847 | + options._redirectsInfo.push(redirect_data); |
| 1848 | + } |
| 1849 | + |
| 1850 | + run(redirect_data.url, options, cb); |
1842 | 1851 | aborted = true; |
1843 | 1852 | return; |
1844 | 1853 | } |
|
0 commit comments