From f632c7dfb3cb5069c5fb3a4993c3739f955c7eb8 Mon Sep 17 00:00:00 2001 From: wukko Date: Wed, 22 May 2024 01:20:54 +0600 Subject: [PATCH] stream/types: move closeResponse to shared --- src/modules/stream/shared.js | 5 +++++ src/modules/stream/types.js | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/stream/shared.js b/src/modules/stream/shared.js index 2f898c52..8555f8ba 100644 --- a/src/modules/stream/shared.js +++ b/src/modules/stream/shared.js @@ -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] } } \ No newline at end of file diff --git a/src/modules/stream/types.js b/src/modules/stream/types.js index 87c9f600..a1db0c60 100644 --- a/src/modules/stream/types.js +++ b/src/modules/stream/types.js @@ -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');