Apps could set this even if they probably shouldn't. Avoiding the duplicate.
Aviod duplicate Transfer-Encoding: chunked when already set in headers
You also need to factor in the possibility of application setting the 'Transfer-Encoding: identity' header (which would indicate that message is terminated by closing the connection), in which case as per RFC2612 the 'Transfer-Encoding: chunked' is not necessary. Something like http://paste.debian.net/hidden/94c95cea/ is what I use.