Replace terrible chunked encoding handling with a better method.

Signed-off-by: Fenny Fatal <Fenny@FennyFatal.com>