'use strict';
-const { IncomingMessage } = require('http');
+const { IncomingMessage } = require('node:http');
/**
* Welp, here we are, already into the crazy.
- * Per documentation (https://nodejs.org/docs/latest-v12.x/api/http.html#http_request_getheader_name)
- * this should exist, yet (as of 12.18.4) it does not. So let us change this pitch up, and patch
-*/
+ * This originally existed due to a misinterpretation of the documentation,
+ * but it's really quite useful, so it stays in our world.
+ */
/* istanbul ignore else */
if (typeof IncomingMessage.getHeader !== 'function') {
IncomingMessage.prototype.getHeader = function (name) {
if (typeof name !== 'string') {
throw new TypeError('\'name\' must be a string');
}
- return this.headers && this.headers[name.toLowerCase()];
+ return this.headers?.[name.toLowerCase()];
};
}