diff options
author | 2023-05-22 19:44:21 -0700 | |
---|---|---|
committer | 2023-05-22 19:44:21 -0700 | |
commit | 5cfa5edd63968582dddf64f4e7087d33c8d36cb7 (patch) | |
tree | 7f0d79af73aa646f802d801b44a0173812ce4e22 /src/bun.js | |
parent | fc40c690ea30a632a8d0d9490321c50ec898d8a5 (diff) | |
download | bun-5cfa5edd63968582dddf64f4e7087d33c8d36cb7.tar.gz bun-5cfa5edd63968582dddf64f4e7087d33c8d36cb7.tar.zst bun-5cfa5edd63968582dddf64f4e7087d33c8d36cb7.zip |
[node:http] Fix return type for `getHeader()` (#3007)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js')
-rw-r--r-- | src/bun.js/http.exports.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js index c05d70d9a..d9c44836b 100644 --- a/src/bun.js/http.exports.js +++ b/src/bun.js/http.exports.js @@ -56,6 +56,12 @@ function isValidTLSArray(obj) { } } +function getHeader(headers, name) { + if (!headers) return; + const result = headers.get(name); + return result == null ? undefined : result; +} + var FakeSocket = class Socket extends Duplex { bytesRead = 0; bytesWritten = 0; @@ -858,8 +864,7 @@ export class OutgoingMessage extends Writable { flushHeaders() {} getHeader(name) { - if (!this.#headers) return; - return this.#headers.get(name); + return getHeader(this.#headers, name); } getHeaders() { @@ -1092,13 +1097,13 @@ export class ServerResponse extends Writable { flushHeaders() {} getHeader(name) { - if (!this.#headers) return; - return this.#headers.get(name); + return getHeader(this.#headers, name); } getHeaders() { - if (!this.#headers) return kEmptyObject; - return this.#headers.toJSON(); + var headers = this.#headers; + if (!headers) return kEmptyObject; + return headers.toJSON(); } getHeaderNames() { |