* 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)
| 10186 | * - if called with no arguments returns an object containing all headers. |
| 10187 | */ |
| 10188 | function headersGetter(headers) { |
| 10189 | var headersObj; |
| 10190 | |
| 10191 | return function(name) { |
| 10192 | if (!headersObj) headersObj = parseHeaders(headers); |
| 10193 | |
| 10194 | if (name) { |
| 10195 | var value = headersObj[lowercase(name)]; |
| 10196 | if (value === void 0) { |
| 10197 | value = null; |
| 10198 | } |
| 10199 | return value; |
| 10200 | } |
| 10201 | |
| 10202 | return headersObj; |
| 10203 | }; |
| 10204 | } |
| 10205 | |
| 10206 | |
| 10207 | /** |
no test coverage detected