From 44fa378186d711f8efab2135247ffde980e94795 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 20 Sep 2022 13:59:10 +0200 Subject: [PATCH] Remove explicit `Transfer-Encoding: chunked` header (#4807) * Remove explicit `Transfer-Encoding: chunked` This header is not necessary and is ignored by essentially all HTTP servers when provided explicitly by the user. This is because the HTTP transport layer handles adding this header automatically as needed. Some variations of HTTP transport (like HTTP/2, which is enabled by default in Deno, Netlify, and CFW) have no notion of `Transfer-Encoding: chunked`, because all responses are streamed. * add changeset --- .changeset/sweet-ligers-push.md | 5 +++++ packages/astro/src/core/render/core.ts | 1 - packages/astro/src/core/render/result.ts | 8 +------- 3 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 .changeset/sweet-ligers-push.md diff --git a/.changeset/sweet-ligers-push.md b/.changeset/sweet-ligers-push.md new file mode 100644 index 000000000..6b50678e2 --- /dev/null +++ b/.changeset/sweet-ligers-push.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Remove explicit `Transfer-Encoding: chunked` header from streaming responses diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts index e5b604cba..c9efe02de 100644 --- a/packages/astro/src/core/render/core.ts +++ b/packages/astro/src/core/render/core.ts @@ -149,7 +149,6 @@ export async function render(opts: RenderOptions): Promise { site, scripts, ssr, - streaming, status, }); diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index dc5be4a07..9eb618cb3 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -27,7 +27,6 @@ function onlyAvailableInSSR(name: string) { export interface CreateResultArgs { adapterName: string | undefined; ssr: boolean; - streaming: boolean; logging: LogOptions; origin: string; markdown: MarkdownRenderingOptions; @@ -126,12 +125,7 @@ export function createResult(args: CreateResultArgs): SSRResult { const url = new URL(request.url); const headers = new Headers(); - if (args.streaming) { - headers.set('Transfer-Encoding', 'chunked'); - headers.set('Content-Type', 'text/html'); - } else { - headers.set('Content-Type', 'text/html'); - } + headers.set('Content-Type', 'text/html'); const response: ResponseInit = { status: args.status, statusText: 'OK',