* 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)
| 10931 | * - if called with no arguments returns an object containing all headers. |
| 10932 | */ |
| 10933 | function headersGetter(headers) { |
| 10934 | var headersObj; |
| 10935 | |
| 10936 | return function(name) { |
| 10937 | if (!headersObj) headersObj = parseHeaders(headers); |
| 10938 | |
| 10939 | if (name) { |
| 10940 | var value = headersObj[lowercase(name)]; |
| 10941 | if (value === undefined) { |
| 10942 | value = null; |
| 10943 | } |
| 10944 | return value; |
| 10945 | } |
| 10946 | |
| 10947 | return headersObj; |
| 10948 | }; |
| 10949 | } |
| 10950 | |
| 10951 | |
| 10952 | /** |
no test coverage detected