* Returns a function that provides access to parsed headers. * * Headers are lazy parsed when first requested. * @see parseHeaders * * @param {(string|Object)} headers Headers to provide access to. * @returns {function(string=)} Returns a getter function which if called with: * * - if call
(headers)
| 8689 | * - if called with no arguments returns an object containing all headers. |
| 8690 | */ |
| 8691 | function headersGetter(headers) { |
| 8692 | var headersObj = isObject(headers) ? headers : undefined; |
| 8693 | |
| 8694 | return function(name) { |
| 8695 | if (!headersObj) headersObj = parseHeaders(headers); |
| 8696 | |
| 8697 | if (name) { |
| 8698 | var value = headersObj[lowercase(name)]; |
| 8699 | if (value === void 0) { |
| 8700 | value = null; |
| 8701 | } |
| 8702 | return value; |
| 8703 | } |
| 8704 | |
| 8705 | return headersObj; |
| 8706 | }; |
| 8707 | } |
| 8708 | |
| 8709 | |
| 8710 | /** |
no test coverage detected