* 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)
| 8482 | * - if called with no arguments returns an object containing all headers. |
| 8483 | */ |
| 8484 | function headersGetter(headers) { |
| 8485 | var headersObj = isObject(headers) ? headers : undefined; |
| 8486 | |
| 8487 | return function(name) { |
| 8488 | if (!headersObj) headersObj = parseHeaders(headers); |
| 8489 | |
| 8490 | if (name) { |
| 8491 | return headersObj[lowercase(name)] || null; |
| 8492 | } |
| 8493 | |
| 8494 | return headersObj; |
| 8495 | }; |
| 8496 | } |
| 8497 | |
| 8498 | |
| 8499 | /** |
no test coverage detected