fix enforcing node's http requests for sync

This commit is contained in:
zadam 2020-06-15 18:24:43 +02:00
parent 00faf758e8
commit 85d986534d

View file

@ -9,12 +9,13 @@ const syncOptions = require('./sync_options');
// this allows to support system proxy
function exec(opts) {
const client = getClient(opts);
// hack for cases where electron.net does not work but we don't want to set proxy
if (opts.proxy === 'noproxy') {
opts.proxy = null;
}
const client = getClient(opts);
const proxyAgent = getProxyAgent(opts);
const parsedTargetUrl = url.parse(opts.url);
@ -111,6 +112,8 @@ async function getImage(imageUrl) {
request.on('error', err => reject(generateError(opts, err)));
request.on('abort', err => reject(generateError(opts, err)));
request.on('response', response => {
if (![200, 201, 204].includes(response.statusCode)) {
reject(generateError(opts, response.statusCode + ' ' + response.statusMessage));