public final class Response extends MessageImpl<Response>
| Constructor and Description |
|---|
Response()
Creates a new response.
|
Response(Response response)
Creates a defensive copy of the given
response message. |
Response(Status status)
Creates a new response with a default status.
|
| Modifier and Type | Method and Description |
|---|---|
Exception |
getCause()
Returns the (possibly
null) cause of this error message (assuming it is a 4xx or a 5xx). |
Status |
getStatus()
Returns the response status.
|
static Promise<Response,NeverThrowsException> |
newResponsePromise(Response response)
Returns a
Promise representing the Response for an
asynchronous Request which has already completed. |
static PromiseImpl<Response,NeverThrowsException> |
newResponsePromiseImpl()
|
Response |
setCause(Exception cause)
Link a 'caused by' exception to this response.
|
Response |
setEntity(Object o)
Sets the content of the entity to the provided value.
|
Response |
setStatus(Status status)
Sets the response status code.
|
Response |
setVersion(String version)
Sets the protocol version.
|
close, getEntity, getHeaders, getVersionpublic Response()
public Response(Response response) throws IOException
response message.response - response to be copiedIOException - when entity cannot be clonedpublic Response(Status status)
status - The status to use for the Reponse.public static Promise<Response,NeverThrowsException> newResponsePromise(Response response)
Promise representing the Response for an
asynchronous Request which has already completed. Attempts to get
the Response will immediately return without blocking, and any
listeners registered against the returned promise will be immediately
invoked in the same thread as the caller.response - The Response.Promise representing the Response for an
asynchronous Request which has already completed.public static PromiseImpl<Response,NeverThrowsException> newResponsePromiseImpl()
Promise implementation representing the
Response for an asynchronous Request. The returned
PromiseImpl must be completed once the Response is
received by invoking the handleResult method.Promise implementation representing the
Response for an asynchronous Request.public Status getStatus()
public Exception getCause()
null) cause of this error message (assuming it is a 4xx or a 5xx).null) cause of this error message (assuming it is a 4xx or a 5xx).public Response setCause(Exception cause)
status of this message, neither touch its content.
It's up to the caller to ensure consistency (if required in the execution context).cause - Cause of this error responsepublic Response setEntity(Object o)
MessageContent-Length header, overwriting any existing header.
This method is intended mostly as a convenience method within scripts. The parameter will be handled depending on its type as follows:
BranchingInputStream - equivalent to calling
Entity.setRawContentInputStream(org.forgerock.http.io.BranchingInputStream)
byte[] - equivalent to calling Entity.setBytes(byte[])
String - equivalent to calling Entity.setString(java.lang.String)
Object - equivalent to calling Entity.setJson(java.lang.Object).
Note: This method does not attempt to encode the entity based-on any
codings specified in the Content-Encoding header.
o - The object whose value should be stored in the entity.public Response setStatus(Status status)
status - The response status code.Copyright © 2025 Open Identity Platform Community. All rights reserved.