Fix some issues with multi-line headers

These commits fix some issues to do with multi-line headers.  See the commit comments for details.

Note that the second commit fixes a bug that might have security implications, because it can lead to Content-Length and Transfer-Encoding header values being ignored.  But the practical risk is probably small because proxies and reverse proxies are supposed to normalize requests and responses these days.