Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
fix: refuse a redirect without a Location during link probing (#177)
Rudy Mizrahi Celekli3eba463bbb52
diff --git a/e2e/probeRedirects.spec.ts b/e2e/probeRedirects.spec.tsindex 4016a5d..a128628 100644--- a/e2e/probeRedirects.spec.ts+++ b/e2e/probeRedirects.spec.ts@@ -31,4 +31,15 @@ test.describe('probe redirect limits @smoke', () => {await expect(plexo.api.probeUrl(origin.url(path))).rejects.toThrow(/Too many redirects/)})}++ test('a redirect without a Location is refused, not offered as the file', async ({+ plexo,+ serve+ }) => {+ const origin = await serve({ size: 3 * BLOCK })+ origin.setRule(({ path }) =>+ path === '/moved' ? { status: 302, headers: { 'Content-Length': '0' } } : 'ok'+ )+ await expect(plexo.api.probeUrl(origin.url('/moved'))).rejects.toThrow(/status 302/)+ })})diff --git a/src/main/download/probe.ts b/src/main/download/probe.tsindex 2e637d6..81d795a 100644--- a/src/main/download/probe.ts+++ b/src/main/download/probe.ts@@ -188,7 +188,8 @@ export async function probeUrl(rawUrl: string, browser?: BrowserContext): Promis}}- if (!response || response.statusCode === 0 || response.statusCode >= 400) {+ // A redirect still standing here had no Location to follow: it isn't the file.+ if (!response || response.statusCode === 0 || response.statusCode >= 300) {throw new Error(`Server responded with status ${response?.statusCode || 'unknown'}`)}