Skip to content

Commit

Permalink
feat(electron-updater): Port support for downloads, Protocol support …
Browse files Browse the repository at this point in the history
…for generic backend

Use specified port when downloading file
  Pass protocol through, allowing http: for local testing. Default is still https:
  • Loading branch information
Frugality authored and develar committed Jan 18, 2017
1 parent 98c2c8e commit 8d883f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/electron-auto-updater/src/GenericProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GenericProvider implements Provider<UpdateInfo> {
const channelFile = getChannelFilename(this.channel)
const pathname = path.posix.resolve(this.baseUrl.pathname || "/", `${channelFile}`)
try {
result = await request<UpdateInfo>({hostname: this.baseUrl.hostname, port: this.baseUrl.port || "443", path: `${pathname}${this.baseUrl.search || ""}`})
result = await request<UpdateInfo>({hostname: this.baseUrl.hostname, port: this.baseUrl.port || "443", path: `${pathname}${this.baseUrl.search || ""}`, protocol: this.baseUrl.protocol})
}
catch (e) {
if (e instanceof HttpError && e.response.statusCode === 404) {
Expand Down
3 changes: 2 additions & 1 deletion packages/electron-auto-updater/src/electronHttpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ElectronHttpExecutor extends HttpExecutor<Electron.RequestOptions,
protocol: parsedUrl.protocol,
hostname: parsedUrl.hostname,
path: parsedUrl.path,
port: parsedUrl.port ? +parsedUrl.port : undefined,
headers: {
"User-Agent": "electron-builder"
},
Expand Down Expand Up @@ -80,7 +81,7 @@ export class ElectronHttpExecutor extends HttpExecutor<Electron.RequestOptions,
(<any>requestOptions.headers).authorization = token.startsWith("Basic") ? token : `token ${token}`
}

requestOptions.protocol = "https:"
requestOptions.protocol = options.Protocol || "https:"
return new BluebirdPromise<T>((resolve, reject, onCancel) => {
const request = net.request(options, response => {
try {
Expand Down

0 comments on commit 8d883f1

Please sign in to comment.