Rework http error validation so it can be reused r=kgrandon