How does the RESTEasy javax.ws.rs.core.Response
and javax.ws.rs.core.ResponseBuilder
related to the w3c HTTP (section 6.1) response spec?
W2C defines the HTTP response as:
Response = Status-Line ; Section 6.1
*(( general-header ; Section 4.5
| response-header ; Section 6.2
| entity-header ) CRLF) ; Section 7.1
CRLF
[ message-body ] ; Section 7.2
and RESTEasy defines these methods (among others) on the ResponseBuilder object:
The header
method I understand allows you to enter custom headers into the response. status
populates the Status-Code
header and type
, the Content-Type
header.
However, I don't understand the role of entity
does it populate the entity-header or the message-body or what?? Also does the header
method allow you to populate standard headers?? And if I am returning a message describing the reason for the error should this be in the entity-header, message-body or should I populate the Reason-Phrase
header?
The entity() populates the message-body. The header() allows you to populate any response header (standard op proprietary). I'm not aware of a possibility to set the reason phrase (which is not a header).