Make sure headers are only written once when aggregating bytes in memory