diff options
-rw-r--r-- | editors/code/src/net.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 747c02db9..5c48c74e8 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -127,17 +127,19 @@ async function downloadFile( | |||
127 | httpProxy: string | null | undefined, | 127 | httpProxy: string | null | undefined, |
128 | onProgress: (readBytes: number, totalBytes: number) => void | 128 | onProgress: (readBytes: number, totalBytes: number) => void |
129 | ): Promise<void> { | 129 | ): Promise<void> { |
130 | const urlString = url.toString(); | ||
131 | |||
130 | const res = await (() => { | 132 | const res = await (() => { |
131 | if (httpProxy) { | 133 | if (httpProxy) { |
132 | log.debug(`Downloading ${url.path} via proxy: ${httpProxy}`); | 134 | log.debug(`Downloading ${urlString} via proxy: ${httpProxy}`); |
133 | return fetch(url.path, { agent: new HttpsProxyAgent(httpProxy) }); | 135 | return fetch(urlString, { agent: new HttpsProxyAgent(httpProxy) }); |
134 | } | 136 | } |
135 | 137 | ||
136 | return fetch(url.path); | 138 | return fetch(urlString); |
137 | })(); | 139 | })(); |
138 | 140 | ||
139 | if (!res.ok) { | 141 | if (!res.ok) { |
140 | log.error("Error", res.status, "while downloading file from", url.path); | 142 | log.error("Error", res.status, "while downloading file from", urlString); |
141 | log.error({ body: await res.text(), headers: res.headers }); | 143 | log.error({ body: await res.text(), headers: res.headers }); |
142 | 144 | ||
143 | throw new Error(`Got response ${res.status} when trying to download a file.`); | 145 | throw new Error(`Got response ${res.status} when trying to download a file.`); |
@@ -146,7 +148,7 @@ async function downloadFile( | |||
146 | const totalBytes = Number(res.headers.get('content-length')); | 148 | const totalBytes = Number(res.headers.get('content-length')); |
147 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); | 149 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); |
148 | 150 | ||
149 | log.debug("Downloading file of", totalBytes, "bytes size from", url.path, "to", destFilePath.path); | 151 | log.debug("Downloading file of", totalBytes, "bytes size from", urlString, "to", destFilePath.path); |
150 | 152 | ||
151 | let readBytes = 0; | 153 | let readBytes = 0; |
152 | res.body.on("data", (chunk: Buffer) => { | 154 | res.body.on("data", (chunk: Buffer) => { |