Skip to content

Commit 8d883f1

Browse files
Frugalitydevelar
authored andcommitted
feat(electron-updater): Port support for downloads, Protocol support for generic backend
Use specified port when downloading file Pass protocol through, allowing http: for local testing. Default is still https:
1 parent 98c2c8e commit 8d883f1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/electron-auto-updater/src/GenericProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class GenericProvider implements Provider<UpdateInfo> {
1616
const channelFile = getChannelFilename(this.channel)
1717
const pathname = path.posix.resolve(this.baseUrl.pathname || "/", `${channelFile}`)
1818
try {
19-
result = await request<UpdateInfo>({hostname: this.baseUrl.hostname, port: this.baseUrl.port || "443", path: `${pathname}${this.baseUrl.search || ""}`})
19+
result = await request<UpdateInfo>({hostname: this.baseUrl.hostname, port: this.baseUrl.port || "443", path: `${pathname}${this.baseUrl.search || ""}`, protocol: this.baseUrl.protocol})
2020
}
2121
catch (e) {
2222
if (e instanceof HttpError && e.response.statusCode === 404) {

packages/electron-auto-updater/src/electronHttpExecutor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ElectronHttpExecutor extends HttpExecutor<Electron.RequestOptions,
4141
protocol: parsedUrl.protocol,
4242
hostname: parsedUrl.hostname,
4343
path: parsedUrl.path,
44+
port: parsedUrl.port ? +parsedUrl.port : undefined,
4445
headers: {
4546
"User-Agent": "electron-builder"
4647
},
@@ -80,7 +81,7 @@ export class ElectronHttpExecutor extends HttpExecutor<Electron.RequestOptions,
8081
(<any>requestOptions.headers).authorization = token.startsWith("Basic") ? token : `token ${token}`
8182
}
8283

83-
requestOptions.protocol = "https:"
84+
requestOptions.protocol = options.Protocol || "https:"
8485
return new BluebirdPromise<T>((resolve, reject, onCancel) => {
8586
const request = net.request(options, response => {
8687
try {

0 commit comments

Comments
 (0)