fix(anime): preserve HLS playlist rewriting and fetch timeouts

- Force identity encoding for upstream playlist responses
- Keep inactivity timeouts active while streaming response bodies
This commit is contained in:
2026-08-16 14:20:08 -07:00
parent f6993ae507
commit 1d1575f414
3 changed files with 38 additions and 12 deletions
+10 -10
View File
@@ -7,22 +7,23 @@ interface ClientRequestLifecycle {
closed: boolean;
}
const DROPPED_REQUEST_HEADERS = new Set([
'accept-encoding',
'connection',
'keep-alive',
'transfer-encoding',
'content-length',
]);
export function forwardableRequestHeaders(
headers: http.IncomingHttpHeaders,
): http.OutgoingHttpHeaders {
const result: http.OutgoingHttpHeaders = {};
for (const [name, value] of Object.entries(headers)) {
if (
value === undefined ||
name.toLowerCase() === 'connection' ||
name.toLowerCase() === 'keep-alive' ||
name.toLowerCase() === 'transfer-encoding' ||
name.toLowerCase() === 'content-length'
) {
continue;
}
if (value === undefined || DROPPED_REQUEST_HEADERS.has(name.toLowerCase())) continue;
result[name] = value;
}
result['accept-encoding'] = 'identity';
return result;
}
@@ -75,7 +76,6 @@ function requestAttempt(
};
upstream.once('end', clearActiveRequest);
upstream.once('close', clearActiveRequest);
upstreamRequest.setTimeout(0);
const status = upstream.statusCode ?? 502;
if (status === 404 || status >= 500) {
if (mayRetry) {