Class Response
java.lang.Object
com.yahoo.application.container.handler.Response
A response for use with
JDisc.handleRequest(Request)
.- Author:
- Einar M R Rosenvinge
- See Also:
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Response
public Response()Creates a Response with an empty body, and 200 (OK) response code. -
Response
public Response(byte[] body) Creates a Response with a message body, and 200 (OK) response code.- Parameters:
body
- the body of the response
-
Response
public Response(int status, byte[] body) Creates a Response with a message body, and the given response code.- Parameters:
status
- the status code of the responsebody
- the body of the response- Since:
- 5.1.28
-
-
Method Details
-
getStatus
public int getStatus()Returns the status code of this response. This is an integer result code of the attempt to understand and satisfy the corresponding
Request
.- Returns:
- The status code.
- Since:
- 5.1.28
-
getBody
public byte[] getBody()Returns the body of this Response.- Returns:
- the body of this Response
-
getBodyAsString
Attempts to decode the buffer returned bygetBody()
as a String in a best-effort manner. This is done using the Content-Type header - and defaults to UTF-8 encoding if the header is unparseable or not found. Note that this may very well throw aCharacterCodingException
.- Returns:
- a String with the decoded contents of the body buffer
- Throws:
CharacterCodingException
- if the body buffer was not well-formed
-
getHeaders
Returns a mutable multi-map of headers for this Response.- Returns:
- a mutable multi-map of headers for this Response
-
toString
-