mirror of
https://github.com/coder/code-server.git
synced 2025-07-28 20:43:24 +08:00
Make client-side extensions work at any base
This commit is contained in:
@ -8,10 +8,8 @@ import * as path from "path"
|
||||
import * as querystring from "querystring"
|
||||
import safeCompare from "safe-compare"
|
||||
import { Readable } from "stream"
|
||||
import * as tarFs from "tar-fs"
|
||||
import * as tls from "tls"
|
||||
import * as url from "url"
|
||||
import * as zlib from "zlib"
|
||||
import { HttpCode, HttpError } from "../common/http"
|
||||
import { normalize, Options, plural, split } from "../common/util"
|
||||
import { SocketProxyProvider } from "./socket"
|
||||
@ -233,25 +231,6 @@ export abstract class HttpProvider {
|
||||
return { content: await fs.readFile(filePath, "utf8"), filePath }
|
||||
}
|
||||
|
||||
/**
|
||||
* Tar up and stream a directory.
|
||||
*/
|
||||
protected async getTarredResource(request: http.IncomingMessage, ...parts: string[]): Promise<HttpResponse> {
|
||||
const filePath = path.join(...parts)
|
||||
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/x-tar", cache: true, headers }
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to error on invalid methods (default GET).
|
||||
*/
|
||||
|
Reference in New Issue
Block a user