Skip to content

Commit c492d45

Browse files
committed
feat(http): support ServerResponse.appendHeader
1 parent f50bd51 commit c492d45

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/runtime/node/http/_response.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export class ServerResponse extends Writable implements http.ServerResponse {
1616
sendDate: boolean = false;
1717
finished: boolean = false;
1818
headersSent: boolean = false;
19+
strictContentLength = false;
1920
connection: Socket | null = null;
2021
socket: Socket | null = null;
22+
2123
req: http.IncomingMessage;
2224

2325
_headers: HeadersObject = {};
@@ -78,6 +80,17 @@ export class ServerResponse extends Writable implements http.ServerResponse {
7880
return this;
7981
}
8082

83+
appendHeader(name: string, value: string | string[]) {
84+
name = name.toLowerCase()
85+
const current = this._headers[name];
86+
const all = [
87+
...(Array.isArray(current) ? current : [current]),
88+
...(Array.isArray(value) ? value : [value]),
89+
].filter(Boolean) as string[];
90+
this._headers[name] = all.length > 1 ? all : all[0];
91+
return this;
92+
}
93+
8194
setHeader(
8295
name: string,
8396
value: number | string | ReadonlyArray<string>

src/runtime/node/util/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const _exceptionWithHostPort = notImplemented(
2828
"util._exceptionWithHostPort"
2929
);
3030
export const _extend = notImplemented("util._extend");
31+
32+
export const aborted: typeof util.aborted = notImplemented("util.aborted");
3133
export const callbackify: typeof util.callbackify =
3234
notImplemented("util.callbackify");
3335
export const getSystemErrorMap: typeof util.getSystemErrorMap = notImplemented(
@@ -51,6 +53,7 @@ export default <typeof util>{
5153
_errnoException,
5254
_exceptionWithHostPort,
5355
_extend,
56+
aborted,
5457
callbackify,
5558
deprecate,
5659
getSystemErrorMap,

0 commit comments

Comments
 (0)