correct handling of chunked encoding