Skip to content

Commit 4f2dcd4

Browse files
committed
Fix content-length header being required
This broke downloading the binary through a reverse proxy.
1 parent 5363f17 commit 4f2dcd4

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Open any workspace with a single click.",
66
"repository": "https://github.com/coder/vscode-coder",
77
"preview": true,
8-
"version": "0.1.3",
8+
"version": "0.1.4",
99
"engines": {
1010
"vscode": "^1.73.0"
1111
},

src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
8686
await remote.setup(vscodeProposed.env.remoteAuthority)
8787
} catch (ex) {
8888
await vscodeProposed.window.showErrorMessage("Failed to open workspace", {
89-
detail: typeof ex === "string" ? ex : JSON.stringify(ex),
89+
detail: (ex as string).toString(),
9090
modal: true,
9191
useCustom: true,
9292
})

src/storage.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ export class Storage {
165165
cancelled = true
166166
})
167167

168-
const contentLengthPretty = prettyBytes(contentLength)
168+
let contentLengthPretty = ""
169+
// Reverse proxies might not always send a content length!
170+
if (!Number.isNaN(contentLength)) {
171+
contentLengthPretty = " / " + prettyBytes(contentLength)
172+
}
173+
169174
const writeStream = createWriteStream(binPath, {
170175
autoClose: true,
171176
mode: 0o755,
@@ -175,7 +180,7 @@ export class Storage {
175180
writeStream.write(buffer, () => {
176181
written += buffer.byteLength
177182
progress.report({
178-
message: `${prettyBytes(written)} / ${contentLengthPretty}`,
183+
message: `${prettyBytes(written)}${contentLengthPretty}`,
179184
increment: (buffer.byteLength / contentLength) * 100,
180185
})
181186
})

0 commit comments

Comments
 (0)