|
|
@ -102,7 +102,7 @@ function get(url) {
|
|
|
|
const { get } = url.protocol === 'http:' ? http : https
|
|
|
|
const { get } = url.protocol === 'http:' ? http : https
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) =>
|
|
|
|
return new Promise((resolve, reject) =>
|
|
|
|
get(url.href, (response) => {
|
|
|
|
get(url, { rejectUnauthorized: false }, (response) => {
|
|
|
|
if (response.statusCode >= 400) {
|
|
|
|
if (response.statusCode >= 400) {
|
|
|
|
return reject(
|
|
|
|
return reject(
|
|
|
|
new Error(`${response.statusCode} ${response.statusMessage}`)
|
|
|
|
new Error(`${response.statusCode} ${response.statusMessage}`)
|
|
|
@ -116,7 +116,7 @@ function get(url) {
|
|
|
|
response.on('data', (data) => (body += data))
|
|
|
|
response.on('data', (data) => (body += data))
|
|
|
|
response.on('error', (error) => reject(new Error(error.message)))
|
|
|
|
response.on('error', (error) => reject(new Error(error.message)))
|
|
|
|
response.on('end', () => resolve(body))
|
|
|
|
response.on('end', () => resolve(body))
|
|
|
|
})
|
|
|
|
}).on('error', (error) => reject(new Error(error.message)))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error(`Invalid protocol: ${url.protocol}`)
|
|
|
|
throw new Error(`Invalid protocol: ${url.protocol}`)
|
|
|
|