in writeHeader, set key to lowercase. fixes #5036

Fixes #5036, by setting the header key to lower case (as is done in setHeader).