I need to change it to use the following logic: if the transfer-encoding header exists, then return what it is set to and do not look for content-length header. If there is no transfer-encoding header, then look for and read the content-length header.

Going by this: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 
If a message is received with both a Transfer-Encoding header field and a Content-Length header field, the latter MUST be ignored.

Just wanna get the logic right.