* 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)
| 9776 | * - if called with no arguments returns an object containing all headers. |
| 9777 | */ |
| 9778 | function headersGetter(headers) { |
| 9779 | var headersObj; |
| 9780 | |
| 9781 | return function(name) { |
| 9782 | if (!headersObj) headersObj = parseHeaders(headers); |
| 9783 | |
| 9784 | if (name) { |
| 9785 | var value = headersObj[lowercase(name)]; |
| 9786 | if (value === void 0) { |
| 9787 | value = null; |
| 9788 | } |
| 9789 | return value; |
| 9790 | } |
| 9791 | |
| 9792 | return headersObj; |
| 9793 | }; |
| 9794 | } |
| 9795 | |
| 9796 | |
| 9797 | /** |
no test coverage detected