Remove duplicated code between HttpIO and ChunkedIO

The following discussion from !18169 (merged) should be addressed:

Edited by Shinya Maeda