stream: fix handling of chunked encoding in client