stream: move closeRequest to shared functions

This commit is contained in:
dumbmoron 2024-06-23 13:51:47 +00:00
parent a6733ef0cc
commit 0d82c3e524
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View File

@ -16,6 +16,10 @@ const serviceHeaders = {
} }
} }
export function closeRequest(controller) {
try { controller.abort() } catch {}
}
export function closeResponse(res) { export function closeResponse(res) {
if (!res.headersSent) { if (!res.headersSent) {
res.sendStatus(500); res.sendStatus(500);

View File

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