Question

Is it valid to return different text in the response header than the usual fare?

For example if the request is invalid, could I respond with:

HTTP/1.1 400 Here be Dragons

And have that header properly handled by proxies, etc?

Was it helpful?

Solution

Yes, it conforms to the HTTP protocol to have arbitrary text on the response line. No, proxies aren't required to forward that as-is (but typically will).

OTHER TIPS

The HTTP spec says:

The Status-Code is intended for use by automata and the Reason-Phrase is intended for the human user. The client is not required to examine or display the Reason-Phrase.

and:

The reason phrases listed here are only recommendations -- they MAY be replaced by local equivalents without affecting the protocol.

So yes, it's valid to use any text you'd like as the Reason-Phrase AKA "Status text" or "Status name".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top