Pass go headers through in updater/differential

This commit is contained in:
Fedor Indutny 2022-03-02 10:06:58 -08:00 committed by GitHub
parent 637b67d9a5
commit da7a76e03f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -76,6 +76,12 @@ describe('updater/differential', () => {
beforeEach(callback => {
server = http.createServer(async (req, res) => {
if (!req.headers['user-agent']?.includes('Signal-Desktop')) {
res.writeHead(403);
res.end(`Invalid user agent: "${req.headers['user-agent']}"`);
return;
}
const file = req.url?.slice(1) ?? '';
if (!allowedFiles.has(file)) {
res.writeHead(404);

View file

@ -350,9 +350,11 @@ export async function downloadRanges(
diffByRange.set(`${readOffset}-${readOffset + size - 1}`, diff);
}
const gotOptions = getGotOptions();
const stream = got.stream(`${url}`, {
...getGotOptions(),
...gotOptions,
headers: {
...gotOptions.headers,
range: `bytes=${Array.from(diffByRange.keys()).join(',')}`,
},
});