Skip to content

Commit

Permalink
feat: teach Downloader to respect redirects (puppeteer#1741)
Browse files Browse the repository at this point in the history
This patch adds support for redirects to downloader.

Fixes puppeteer#1740
  • Loading branch information
gucong3000 authored and aslushnikov committed Jan 9, 2018
1 parent d7d9623 commit 71089b0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ function httpRequest(url, method, response) {
}

const driver = options.protocol === 'https:' ? 'https' : 'http';
const request = require(driver).request(options, response);
const request = require(driver).request(options, res => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location)
httpRequest(res.headers.location, method, response);
else
response(res);
});
request.end();
return request;
}

0 comments on commit 71089b0

Please sign in to comment.