Backport some cookie parsing improvements from 55f8e7c163524c27648d15748014354361a61551