* 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
(headers)
| 10466 | * - if called with no arguments returns an object containing all headers. |
| 10467 | */ |
| 10468 | function headersGetter(headers) { |
| 10469 | var headersObj; |
| 10470 | |
| 10471 | return function (name) { |
| 10472 | if (!headersObj) headersObj = parseHeaders(headers); |
| 10473 | |
| 10474 | if (name) { |
| 10475 | var value = headersObj[lowercase(name)]; |
| 10476 | if (value === void 0) { |
| 10477 | value = null; |
| 10478 | } |
| 10479 | return value; |
| 10480 | } |
| 10481 | |
| 10482 | return headersObj; |
| 10483 | }; |
| 10484 | } |
| 10485 | |
| 10486 | /** |
| 10487 | * Chain all given functions |
no test coverage detected