Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are multiple status code headers allowed in a single HTTP response?

I have a web app which sends HTTP status codes. In some instances, a 404 code is sent as a header, but then a 200 error is sent as well, in the same response.

HTTP/1.0 404 Not Found
HTTP/1.0 200 Ok

I can't change the execution order to prevent the first status code from being sent, so the second code is attempting to override it.

Chrome ignores the first code and assumes the status to be Ok. Does this conform to the HTTP standard, and should I rely on it?

like image 409
Jonathan Holvey Avatar asked Oct 28 '25 00:10

Jonathan Holvey


1 Answers

No, it does not conform to the standard, and you should not rely on it. See https://www.greenbytes.de/tech/webdav/rfc7230.html#rfc.section.5.6:

More than one response message per request only occurs when one or more informational responses (1xx, see Section 6.2 of [RFC7231]) precede a final answer to the same request.

like image 78
Julian Reschke Avatar answered Oct 30 '25 23:10

Julian Reschke