* 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)
| 9467 | * - if called with no arguments returns an object containing all headers. |
| 9468 | */ |
| 9469 | function headersGetter(headers) { |
| 9470 | var headersObj; |
| 9471 | |
| 9472 | return function(name) { |
| 9473 | if (!headersObj) headersObj = parseHeaders(headers); |
| 9474 | |
| 9475 | if (name) { |
| 9476 | var value = headersObj[lowercase(name)]; |
| 9477 | if (value === void 0) { |
| 9478 | value = null; |
| 9479 | } |
| 9480 | return value; |
| 9481 | } |
| 9482 | |
| 9483 | return headersObj; |
| 9484 | }; |
| 9485 | } |
| 9486 | |
| 9487 | |
| 9488 | /** |
no test coverage detected