894ca65428d79e9ff2ba7decd844d2573c7944d8
[squeep-api-dingus] / lib / patches / incoming-message.js
1 'use strict';
2 const { IncomingMessage } = require('http');
3
4 /**
5 * Welp, here we are, already into the crazy.
6 * Per documentation (https://nodejs.org/docs/latest-v12.x/api/http.html#http_request_getheader_name)
7 * this should exist, yet (as of 12.18.4) it does not. So let us change this pitch up, and patch
8 */
9 /* istanbul ignore else */
10 if (typeof IncomingMessage.getHeader !== 'function') {
11 IncomingMessage.prototype.getHeader = function (name) {
12 if (typeof name !== 'string') {
13 throw new TypeError('\'name\' must be a string');
14 }
15 return this.headers && this.headers[name.toLowerCase()];
16 };
17 }