* 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)
| 7467 | * - if called with no arguments returns an object containing all headers. |
| 7468 | */ |
| 7469 | function headersGetter(headers) { |
| 7470 | var headersObj = isObject(headers) ? headers : undefined; |
| 7471 | |
| 7472 | return function(name) { |
| 7473 | if (!headersObj) headersObj = parseHeaders(headers); |
| 7474 | |
| 7475 | if (name) { |
| 7476 | return headersObj[lowercase(name)] || null; |
| 7477 | } |
| 7478 | |
| 7479 | return headersObj; |
| 7480 | }; |
| 7481 | } |
| 7482 | |
| 7483 | |
| 7484 | /** |
no test coverage detected