Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4064fbf

Browse files
authored
Use 'automatic' rather than 'auto' for 'encodeBody' (#358)
1 parent 16a12e4 commit 4064fbf

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/core/src/standards/http.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export function withImmutableHeaders<Body extends Request | Response>(
489489
}
490490

491491
export interface ResponseInit extends BaseResponseInit {
492-
readonly encodeBody?: "auto" | "manual";
492+
readonly encodeBody?: "automatic" | "manual";
493493
readonly webSocket?: WebSocket;
494494
}
495495

@@ -528,7 +528,7 @@ export class Response<
528528

529529
// https://developers.cloudflare.com/workers/runtime-apis/response#properties
530530
// noinspection TypeScriptFieldCanBeMadeReadonly
531-
#encodeBody: "auto" | "manual";
531+
#encodeBody: "automatic" | "manual";
532532
// noinspection TypeScriptFieldCanBeMadeReadonly
533533
#status?: number;
534534
readonly #webSocket?: WebSocket;
@@ -584,8 +584,8 @@ export class Response<
584584
super(new BaseResponse(body, init));
585585
}
586586

587-
encodeBody ??= "auto";
588-
if (encodeBody !== "auto" && encodeBody !== "manual") {
587+
encodeBody ??= "automatic";
588+
if (encodeBody !== "automatic" && encodeBody !== "manual") {
589589
throw new TypeError(`encodeBody: unexpected value: ${encodeBody}`);
590590
}
591591
this.#encodeBody = encodeBody;
@@ -625,7 +625,7 @@ export class Response<
625625
return clone;
626626
}
627627

628-
get encodeBody(): "auto" | "manual" {
628+
get encodeBody(): "automatic" | "manual" {
629629
return this.#encodeBody;
630630
}
631631

packages/core/test/standards/http.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ test("Response: supports non-standard properties", (t) => {
695695
});
696696
test("Response: encodeBody defaults to auto", (t) => {
697697
const res = new Response(null);
698-
t.is(res.encodeBody, "auto");
698+
t.is(res.encodeBody, "automatic");
699699
});
700700
test("Response: requires status 101 for WebSocket response", (t) => {
701701
const pair = new WebSocketPair();

packages/http-server/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function writeResponse(
176176
// If a Content-Encoding is set, and the user hasn't encoded the body,
177177
// we're responsible for doing so.
178178
const encoders: Transform[] = [];
179-
if (headers["content-encoding"] && response.encodeBody === "auto") {
179+
if (headers["content-encoding"] && response.encodeBody === "automatic") {
180180
// Reverse of https://github.com/nodejs/undici/blob/48d9578f431cbbd6e74f77455ba92184f57096cf/lib/fetch/index.js#L1660
181181
const codings = headers["content-encoding"]
182182
.toString()
@@ -207,7 +207,7 @@ async function writeResponse(
207207
// response, and it's HTML
208208
const liveReloadEnabled =
209209
liveReload &&
210-
response.encodeBody === "auto" &&
210+
response.encodeBody === "automatic" &&
211211
response.headers.get("content-type")?.toLowerCase().includes("text/html");
212212

213213
// If Content-Length is specified, and we're live-reloading, we'll

0 commit comments

Comments
 (0)