Compress when sending client-side extension tars
This commit is contained in:
parent
a8914b025f
commit
88cab27165
@ -119,7 +119,7 @@ index 2d8b725ff2..a8d93a17ca 100644
|
|||||||
unique-stream@^2.0.2:
|
unique-stream@^2.0.2:
|
||||||
version "2.2.1"
|
version "2.2.1"
|
||||||
diff --git a/package.json b/package.json
|
diff --git a/package.json b/package.json
|
||||||
index fde05321d2..1a7ed2fa47 100644
|
index fde05321d2..2427e7d4ae 100644
|
||||||
--- a/package.json
|
--- a/package.json
|
||||||
+++ b/package.json
|
+++ b/package.json
|
||||||
@@ -32,6 +32,9 @@
|
@@ -32,6 +32,9 @@
|
||||||
@ -128,7 +128,7 @@ index fde05321d2..1a7ed2fa47 100644
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
+ "@coder/logger": "^1.1.12",
|
+ "@coder/logger": "^1.1.12",
|
||||||
+ "@coder/node-browser": "^1.0.8",
|
+ "@coder/node-browser": "^1.0.8",
|
||||||
+ "@coder/requirefs": "^1.1.4",
|
+ "@coder/requirefs": "^1.1.5",
|
||||||
"applicationinsights": "1.0.8",
|
"applicationinsights": "1.0.8",
|
||||||
"chokidar": "3.2.3",
|
"chokidar": "3.2.3",
|
||||||
"graceful-fs": "4.1.11",
|
"graceful-fs": "4.1.11",
|
||||||
@ -3109,7 +3109,7 @@ index 82626a55c7..5d3ee1b69b 100644
|
|||||||
union-value@^1.0.0:
|
union-value@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
diff --git a/yarn.lock b/yarn.lock
|
diff --git a/yarn.lock b/yarn.lock
|
||||||
index a98533bad9..19e94f8c4a 100644
|
index a98533bad9..f4da0987c9 100644
|
||||||
--- a/yarn.lock
|
--- a/yarn.lock
|
||||||
+++ b/yarn.lock
|
+++ b/yarn.lock
|
||||||
@@ -140,6 +140,23 @@
|
@@ -140,6 +140,23 @@
|
||||||
@ -3126,10 +3126,10 @@ index a98533bad9..19e94f8c4a 100644
|
|||||||
+ resolved "https://registry.yarnpkg.com/@coder/node-browser/-/node-browser-1.0.8.tgz#c22f581b089ad7d95ad1362fd351c57b7fbc6e70"
|
+ resolved "https://registry.yarnpkg.com/@coder/node-browser/-/node-browser-1.0.8.tgz#c22f581b089ad7d95ad1362fd351c57b7fbc6e70"
|
||||||
+ integrity sha512-NLF9sYMRCN9WK1C224pHax1Cay3qKypg25BhVg7VfNbo3Cpa3daata8RF/rT8JK3lPsu8PmFgDRQjzGC9X1Lrw==
|
+ integrity sha512-NLF9sYMRCN9WK1C224pHax1Cay3qKypg25BhVg7VfNbo3Cpa3daata8RF/rT8JK3lPsu8PmFgDRQjzGC9X1Lrw==
|
||||||
+
|
+
|
||||||
+"@coder/requirefs@^1.1.4":
|
+"@coder/requirefs@^1.1.5":
|
||||||
+ version "1.1.4"
|
+ version "1.1.5"
|
||||||
+ resolved "https://registry.yarnpkg.com/@coder/requirefs/-/requirefs-1.1.4.tgz#ca59223a396021f2f606f71b833c43dbba06b10b"
|
+ resolved "https://registry.yarnpkg.com/@coder/requirefs/-/requirefs-1.1.5.tgz#259db370d563a79a96fb150bc9d69c7db6edc9fb"
|
||||||
+ integrity sha512-E+WB3Wvr31v7eqWdItBW4eVQ0tWr4iKH6qjzCMnRxTsbiiNzLgtDzRBYt/3KxnPrtWXXX6Fn02Ut933soZXJ+g==
|
+ integrity sha512-3jB47OFCql9+9FI6Vc4YX0cfFnG5rxBfrZUH45S4XYtYGOz+/Xl4h4d2iMk50b7veHkeSWGlB4VHC3UZ16zuYQ==
|
||||||
+ optionalDependencies:
|
+ optionalDependencies:
|
||||||
+ jszip "2.6.0"
|
+ jszip "2.6.0"
|
||||||
+
|
+
|
||||||
|
@ -174,7 +174,7 @@ export class VscodeHttpProvider extends HttpProvider {
|
|||||||
break
|
break
|
||||||
case "/tar":
|
case "/tar":
|
||||||
if (typeof route.query.path === "string") {
|
if (typeof route.query.path === "string") {
|
||||||
return this.getTarredResource(route.query.path)
|
return this.getTarredResource(request, route.query.path)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "/webview":
|
case "/webview":
|
||||||
|
@ -11,6 +11,7 @@ import { Readable } from "stream"
|
|||||||
import * as tarFs from "tar-fs"
|
import * as tarFs from "tar-fs"
|
||||||
import * as tls from "tls"
|
import * as tls from "tls"
|
||||||
import * as url from "url"
|
import * as url from "url"
|
||||||
|
import * as zlib from "zlib"
|
||||||
import { HttpCode, HttpError } from "../common/http"
|
import { HttpCode, HttpError } from "../common/http"
|
||||||
import { normalize, Options, plural, split } from "../common/util"
|
import { normalize, Options, plural, split } from "../common/util"
|
||||||
import { SocketProxyProvider } from "./socket"
|
import { SocketProxyProvider } from "./socket"
|
||||||
@ -222,9 +223,20 @@ export abstract class HttpProvider {
|
|||||||
/**
|
/**
|
||||||
* Tar up and stream a directory.
|
* Tar up and stream a directory.
|
||||||
*/
|
*/
|
||||||
protected async getTarredResource(...parts: string[]): Promise<HttpResponse> {
|
protected async getTarredResource(request: http.IncomingMessage, ...parts: string[]): Promise<HttpResponse> {
|
||||||
const filePath = path.join(...parts)
|
const filePath = path.join(...parts)
|
||||||
return { stream: tarFs.pack(filePath), filePath, mime: "application/tar", cache: true }
|
let stream: Readable = tarFs.pack(filePath)
|
||||||
|
const headers: http.OutgoingHttpHeaders = {}
|
||||||
|
if (request.headers["accept-encoding"] && request.headers["accept-encoding"].includes("gzip")) {
|
||||||
|
logger.debug("gzipping tar", field("filePath", filePath))
|
||||||
|
const compress = zlib.createGzip()
|
||||||
|
stream.pipe(compress)
|
||||||
|
stream.on("error", (error) => compress.destroy(error))
|
||||||
|
stream.on("close", () => compress.end())
|
||||||
|
stream = compress
|
||||||
|
headers["content-encoding"] = "gzip"
|
||||||
|
}
|
||||||
|
return { stream, filePath, mime: "application/gzip", cache: true, headers }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user