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

Commit 9f4ba28

Browse files
committed
Fix request.cf.clientAcceptEncoding type to string, closes #362
1 parent 119a90a commit 9f4ba28

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/core/src/standards/cf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface IncomingRequestCfProperties {
2626
asn: number;
2727
botManagement?: IncomingRequestCfPropertiesBotManagement;
2828
city?: string;
29-
clientAcceptEncoding?: string | string[];
29+
clientAcceptEncoding?: string;
3030
clientTcpRtt: number;
3131
clientTrustScore?: number;
3232
colo: string;

packages/http-server/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ export async function convertNodeRequest(
114114
req.headers["cf-visitor"] ??= `{"scheme":"${proto}"}`;
115115
req.headers["host"] = url.host;
116116

117-
// Keep it to use later
117+
// Store original `Accept-Encoding` for `request.cf.clientAcceptEncoding`
118118
const clientAcceptEncoding = req.headers["accept-encoding"];
119-
// This should be fixed
119+
// Only the `Set-Cookie` header is an array: https://nodejs.org/api/http.html#messageheaders
120+
assert(!Array.isArray(clientAcceptEncoding));
121+
// The Workers runtime will always set `Accept-Encoding` to `gzip`:
122+
// https://github.com/cloudflare/miniflare/issues/180
120123
req.headers["accept-encoding"] = "gzip";
121124

122125
// Build Headers object from request

0 commit comments

Comments
 (0)