Is it possible to put semantic information in an HTTP argument phrase in a REST API?

For example, I might need to return the current resource sequence number with a 409 response to a HEAD request for a versioned resource, but I cannot provide it in the response object because HEAD does not resolve it. Another example: suppose a POST request for a transaction endpoint fails due to a version conflict. I can answer 409, but sometimes I can additionally inform the client that the transaction she made has exceeded the maximum number of attempts, and further attempts will not be successful. I could go back, for example. HTTP/1.1 409 Conflict/final

instead of just HTTP/1.1 409 Conflict

in this case. My question is, is this an acceptable practice? The HTTP 1.1 RFC does not provide a clear answer to this question.

I know I can put such information in the HTTP header, X-...

or include this information in the response object in some way (optional XML tag or JSON property, etc.). Assume that I cannot or do not want to do this if I can help.

+3


source to share


2 answers


The reason symptom is pretty for debugging; but what is it. It went through HTTP / 2 and may be lost by intermediaries and / or software libraries; don't rely on saving it.



+1


source


HTTP response format:

Status-Line = HTTP version SP Status-Code SP Reason-Phrase CRLF



According to the specification, here the phrase of reason can be custom. You can add your own version of the error message. Please check here http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html . He mentions that

The reason phrases provided here are guidelines only - they MAY be replaced with local equivalents without affecting the protocol.

-1


source







All Articles