@datatruck/cli 0.36.7 → 0.36.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.schema.json
CHANGED
|
@@ -67,6 +67,7 @@ function createDatatruckRepositoryServer(inOptions, config = {}) {
|
|
|
67
67
|
let responseError;
|
|
68
68
|
req.on("error", (error) => (requestError = error));
|
|
69
69
|
res.on("error", (error) => (responseError = error));
|
|
70
|
+
res.setHeader("X-Accel-Buffering", "no");
|
|
70
71
|
try {
|
|
71
72
|
const { repository, action, params } = parseUrl(url);
|
|
72
73
|
if (!repository || !action)
|
|
@@ -93,7 +94,9 @@ function createDatatruckRepositoryServer(inOptions, config = {}) {
|
|
|
93
94
|
else if (action === "download") {
|
|
94
95
|
const [target] = params;
|
|
95
96
|
const path = fs.resolvePath(target);
|
|
96
|
-
await (0, http_1.sendFile)(req, res, path
|
|
97
|
+
await (0, http_1.sendFile)(req, res, path, {
|
|
98
|
+
contentLength: options.contentLength ?? true,
|
|
99
|
+
});
|
|
97
100
|
}
|
|
98
101
|
else if (action === "writeFile") {
|
|
99
102
|
const data = await (0, http_1.readRequestData)(req);
|
package/lib/utils/http.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare function fetchJson<T = any>(url: string, options?: RequestInit):
|
|
|
10
10
|
export declare function post(url: string, data: string, options?: Omit<RequestInit, "method" | "body">): Promise<Response>;
|
|
11
11
|
export declare function parseContentLength(value: string | undefined): number;
|
|
12
12
|
export declare function sendFile(req: IncomingMessage, res: ServerResponse, path: string, options?: {
|
|
13
|
+
contentLength?: boolean;
|
|
13
14
|
end?: boolean;
|
|
14
15
|
checksum?: boolean;
|
|
15
16
|
}): Promise<void>;
|
package/lib/utils/http.js
CHANGED
|
@@ -62,7 +62,7 @@ async function sendFile(req, res, path, options = {}) {
|
|
|
62
62
|
try {
|
|
63
63
|
file = (0, fs_1.createReadStream)(path);
|
|
64
64
|
const fileStat = await (0, promises_1.stat)(path);
|
|
65
|
-
res.setHeader("Content-Length", fileStat.size);
|
|
65
|
+
res.setHeader(options.contentLength ?? true ? "Content-Length" : "x-content-length", fileStat.size);
|
|
66
66
|
if (options.checksum)
|
|
67
67
|
res.setHeader("x-checksum", await (0, crypto_1.calcFileHash)(path, "sha1"));
|
|
68
68
|
file.pipe(res);
|
|
@@ -111,7 +111,9 @@ async function downloadFile(url, output, options = {}) {
|
|
|
111
111
|
...fetchOptions,
|
|
112
112
|
signal: AbortSignal.timeout(timeout ?? 3600 * 1000), // 60m
|
|
113
113
|
});
|
|
114
|
-
length.total = parseContentLength(res.headers.get("content-length") ??
|
|
114
|
+
length.total = parseContentLength(res.headers.get("content-length") ??
|
|
115
|
+
res.headers.get("x-content-length") ??
|
|
116
|
+
undefined);
|
|
115
117
|
checksum = res.headers.get("x-checksum") ?? undefined;
|
|
116
118
|
const body = stream_1.Readable.fromWeb(res.body);
|
|
117
119
|
const progress = onProgress &&
|