From fd43687bf96aefe9cb9d3508834c627c6f789727 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 21 Apr 2025 16:53:15 -0400 Subject: [PATCH 15/17] option to only use http/1.1 client on videoplayback requests --- src/lib/helpers/config.ts | 6 ++++++ src/routes/videoPlaybackProxy.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts index acb04bb..602e460 100644 --- a/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts @@ -46,6 +46,12 @@ export const ConfigSchema = z.object({ max_proxy_retries: z.number().default( Number(Deno.env.get("MAX_PROXY_RETIRES") || 5), ), + h1VPClient: z.boolean().default( + Deno.env.get("NETWORKING_H1VPCLIENT") === + "false" + ? false + : true, + ), }).strict().default({}), jobs: z.object({ youtube_session: z.object({ diff --git a/src/routes/videoPlaybackProxy.ts b/src/routes/videoPlaybackProxy.ts index 0f707d9..2af343e 100644 --- a/src/routes/videoPlaybackProxy.ts +++ b/src/routes/videoPlaybackProxy.ts @@ -18,6 +18,11 @@ const { getFetchClient } = await import(getFetchClientLocation); const videoPlaybackProxy = new Hono(); +const h1client = Deno.createHttpClient({ + http1: true, + http2: false, +}); + videoPlaybackProxy.options("/", () => { const headersForResponse: Record = { "access-control-allow-origin": "*", @@ -134,6 +139,7 @@ videoPlaybackProxy.get("/", async (c) => { method: "POST", body: new Uint8Array([0x78, 0]), // protobuf: { 15: 0 } (no idea what it means but this is what YouTube uses), headers: headersToSend, + client: config.networking.h1VPClient ? h1client : undefined, }, ); -- 2.49.0