17 lines
605 B
TypeScript
17 lines
605 B
TypeScript
import { app, net } from 'electron'
|
|
|
|
export async function fetchUpdate(url: string): Promise<Response> {
|
|
// Сетевой стек Chromium учитывает системный прокси и доверенные сертификаты.
|
|
const response: Response = await net.fetch(url, {
|
|
headers: {
|
|
'User-Agent': `AeroMail/${app.getVersion()}`,
|
|
'Cache-Control': 'no-cache'
|
|
},
|
|
credentials: 'omit'
|
|
})
|
|
if (!response.ok) {
|
|
await response.body?.cancel()
|
|
throw new Error(`Сервер обновлений вернул HTTP ${response.status}`)
|
|
}
|
|
return response
|
|
}
|