Is there a maximum HTTP status code message length?

A little testing will go a long way, but you should be okay to do this and in fact the RFC says specifically:

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

The only possible concern you may have is header size (some servers may have limitations, but I think they are all relatively large) and how some older browsers may react to this. Frankly I think it makes more sense to use the response body since it's easier to interpret and clear, but there shouldn't be anything wrong with your approach.


I want to add, although there might be no limit in the specification, there is a real chance of implementations to truncate the status message, as I discovered, when I was trying something similar as the OP with Jetty 9.4.14 .

It took me some time to find the reason for the truncated message - there is a hard coded, not configurable limit of 1024 characters [see method getReasonBytes(String)].

(could not post this as comment due to lack of reputation)