Set status and headers as soon as we have them so they're available if there is an error.