Skip to content

Commit

Permalink
fix(node): preserve http number header type with setHeader (#119)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
Hebilicious and pi0 authored Aug 2, 2023
1 parent b872b02 commit bd09775
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/runtime/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function createFetch(call: CallHandle, _fetch = global.fetch) {
headers: Object.fromEntries(
Object.entries(r.headers).map(([name, value]) => [
name,
Array.isArray(value) ? value.join(",") : value || "",
Array.isArray(value) ? value.join(",") : String(value) || "",
]),
),
});
Expand Down
9 changes: 3 additions & 6 deletions src/runtime/node/http/_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ServerResponse extends Writable implements http.ServerResponse {

req: http.IncomingMessage;

_headers: HeadersObject = {};
_headers: Record<string, number | string | string[] | undefined> = {};

constructor(req: http.IncomingMessage) {
super();
Expand Down Expand Up @@ -91,11 +91,8 @@ export class ServerResponse extends Writable implements http.ServerResponse {
return this;
}

setHeader(
name: string,
value: number | string | ReadonlyArray<string>,
): this {
this._headers[name.toLowerCase()] = value + "";
setHeader(name: string, value: number | string | string[]): this {
this._headers[name.toLowerCase()] = value;
return this;
}

Expand Down

0 comments on commit bd09775

Please sign in to comment.