* 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)
| 11439 | * - if called with no arguments returns an object containing all headers. |
| 11440 | */ |
| 11441 | function headersGetter(headers) { |
| 11442 | var headersObj; |
| 11443 | |
| 11444 | return function(name) { |
| 11445 | if (!headersObj) headersObj = parseHeaders(headers); |
| 11446 | |
| 11447 | if (name) { |
| 11448 | var value = headersObj[lowercase(name)]; |
| 11449 | if (value === undefined) { |
| 11450 | value = null; |
| 11451 | } |
| 11452 | return value; |
| 11453 | } |
| 11454 | |
| 11455 | return headersObj; |
| 11456 | }; |
| 11457 | } |
| 11458 | |
| 11459 | |
| 11460 | /** |
no test coverage detected