1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-04 12:40:05 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

View File

@@ -25,11 +25,11 @@ function loadRemoteResource(uri, inlineRequest, inlineTimeout, callback) {
requestOptions.path = requestOptions.href;
}
fetch = (proxyProtocol && !isHttpsResource(proxyProtocol)) || isHttpResource(uri) ?
http.get :
https.get;
fetch = (proxyProtocol && !isHttpsResource(proxyProtocol)) || isHttpResource(uri)
? http.get
: https.get;
fetch(requestOptions, function (res) {
fetch(requestOptions, function(res) {
var chunks = [];
var movedUri;
@@ -39,36 +39,36 @@ function loadRemoteResource(uri, inlineRequest, inlineTimeout, callback) {
if (res.statusCode < 200 || res.statusCode > 399) {
return callback(res.statusCode, null);
} else if (res.statusCode > 299) {
} if (res.statusCode > 299) {
movedUri = url.resolve(uri, res.headers.location);
return loadRemoteResource(movedUri, inlineRequest, inlineTimeout, callback);
}
res.on('data', function (chunk) {
res.on('data', function(chunk) {
chunks.push(chunk.toString());
});
res.on('end', function () {
res.on('end', function() {
var body = chunks.join('');
callback(null, body);
});
})
.on('error', function (res) {
if (errorHandled) {
return;
}
.on('error', function(res) {
if (errorHandled) {
return;
}
errorHandled = true;
callback(res.message, null);
})
.on('timeout', function () {
if (errorHandled) {
return;
}
errorHandled = true;
callback(res.message, null);
})
.on('timeout', function() {
if (errorHandled) {
return;
}
errorHandled = true;
callback('timeout', null);
})
.setTimeout(inlineTimeout);
errorHandled = true;
callback('timeout', null);
})
.setTimeout(inlineTimeout);
}
module.exports = loadRemoteResource;