Rewrite HTTP encoder to use gathering writes