* 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)
| 12081 | * - if called with no arguments returns an object containing all headers. |
| 12082 | */ |
| 12083 | function headersGetter(headers) { |
| 12084 | var headersObj; |
| 12085 | |
| 12086 | return function(name) { |
| 12087 | if (!headersObj) headersObj = parseHeaders(headers); |
| 12088 | |
| 12089 | if (name) { |
| 12090 | var value = headersObj[lowercase(name)]; |
| 12091 | if (value === undefined) { |
| 12092 | value = null; |
| 12093 | } |
| 12094 | return value; |
| 12095 | } |
| 12096 | |
| 12097 | return headersObj; |
| 12098 | }; |
| 12099 | } |
| 12100 | |
| 12101 | |
| 12102 | /** |
no test coverage detected