Skip to content

Commit

Permalink
Pass go headers through in updater/differential
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Mar 2, 2022
1 parent 637b67d commit da7a76e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ts/test-node/updater/differential_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion ts/updater/differential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')}`,
},
});
Expand Down

0 comments on commit da7a76e

Please sign in to comment.