* 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)
| 9301 | * - if called with no arguments returns an object containing all headers. |
| 9302 | */ |
| 9303 | function headersGetter(headers) { |
| 9304 | var headersObj; |
| 9305 | |
| 9306 | return function(name) { |
| 9307 | if (!headersObj) headersObj = parseHeaders(headers); |
| 9308 | |
| 9309 | if (name) { |
| 9310 | var value = headersObj[lowercase(name)]; |
| 9311 | if (value === void 0) { |
| 9312 | value = null; |
| 9313 | } |
| 9314 | return value; |
| 9315 | } |
| 9316 | |
| 9317 | return headersObj; |
| 9318 | }; |
| 9319 | } |
| 9320 | |
| 9321 | |
| 9322 | /** |
no test coverage detected