stream/types: move closeResponse to shared

This commit is contained in:
wukko 2024-05-22 01:20:54 +06:00
parent b1ed1f5199
commit f632c7dfb3
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 6 additions and 6 deletions

View file

@ -16,6 +16,11 @@ const serviceHeaders = {
}
}
export function closeResponse(res) {
if (!res.headersSent) res.sendStatus(500);
return res.destroy();
}
export function getHeaders(service) {
return { ...defaultHeaders, ...serviceHeaders[service] }
}

View file

@ -6,7 +6,7 @@ import { create as contentDisposition } from "content-disposition-header";
import { metadataManager } from "../sub/utils.js";
import { destroyInternalStream } from "./manage.js";
import { env, ffmpegArgs } from "../config.js";
import { getHeaders } from "./shared.js";
import { getHeaders, closeResponse } from "./shared.js";
function toRawHeaders(headers) {
return Object.entries(headers)
@ -18,11 +18,6 @@ function closeRequest(controller) {
try { controller.abort() } catch {}
}
function closeResponse(res) {
if (!res.headersSent) res.sendStatus(500);
return res.destroy();
}
function killProcess(p) {
// ask the process to terminate itself gracefully
p?.kill('SIGTERM');