Package org.forgerock.http.protocol
Class Response
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Message<Response>
A response message.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddTrailers(Header... trailers) Add one or more trailers, aka trailing headers, to the response.getCause()Returns the (possiblynull) cause of this error message (assuming it is a 4xx or a 5xx).Returns the response status.Returns the trailers, aka trailing headers.booleanIndicates that the response's content has to be considered as a streaming and thus some special treatments may apply on it.static Promise<Response,NeverThrowsException> newResponsePromise(Response response) Returns aPromiserepresenting theResponsefor an asynchronousRequestwhich has already completed.static PromiseImpl<Response,NeverThrowsException> putTrailers(Header... trailers) Put one or more trailers, aka trailing headers, to the response.Link a 'caused by' exception to this response.Sets the content of the entity to the provided value.Sets the response status code.setStreamingContent(boolean streamingContent) Set that the response's content has to be considered as a streaming and thus some special treatments may apply on it.setVersion(String version) Sets the protocol version.Methods inherited from class org.forgerock.http.protocol.MessageImpladdHeaders, close, getEntity, getHeaders, getVersion, modifyHeaders, putHeaders
- 
Constructor Details- 
ResponseCreates a defensive copy of the givenresponsemessage.- Parameters:
- response- response to be copied
- Throws:
- IOException- when entity cannot be cloned
 
- 
ResponseCreates a new response with a default status.- Parameters:
- status- The status to use for the Reponse.
 
 
- 
- 
Method Details- 
newResponsePromiseReturns aPromiserepresenting theResponsefor an asynchronousRequestwhich has already completed. Attempts to get theResponsewill immediately return without blocking, and any listeners registered against the returned promise will be immediately invoked in the same thread as the caller.- Parameters:
- response- The- Response.
- Returns:
- A Promiserepresenting theResponsefor an asynchronousRequestwhich has already completed.
 
- 
newResponsePromiseImplCreates a new pendingPromiseimplementation representing theResponsefor an asynchronousRequest. The returnedPromiseImplmust be completed once theResponseis received by invoking thehandleResultmethod.- Returns:
- A new pending Promiseimplementation representing theResponsefor an asynchronousRequest.
 
- 
getStatusReturns the response status.- Returns:
- the response status
 
- 
getCauseReturns the (possiblynull) cause of this error message (assuming it is a 4xx or a 5xx).- Returns:
- the (possibly null) cause of this error message (assuming it is a 4xx or a 5xx)
 
- 
setCauseLink a 'caused by' exception to this response. That can be used to determine if this error response was triggered by an exception (as opposed to obtained from a remote server). Note: this method does not change thestatusof this message, neither touch its content. It's up to the caller to ensure consistency (if required in the execution context).- Parameters:
- cause- Cause of this error response
- Returns:
- This response.
 
- 
setEntityDescription copied from interface:MessageSets the content of the entity to the provided value. Calling this method will close any existing streams associated with the entity. May also set theContent-Lengthheader, 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-Encodingheader.- Parameters:
- o- The object whose value should be stored in the entity.
- Returns:
- This message.
 
- 
setStatusSets the response status code.- Parameters:
- status- The response status code.
- Returns:
- This response.
 
- 
setVersionDescription copied from interface:MessageSets the protocol version. Default:HTTP/1.1.- Parameters:
- version- The protocol version.
- Returns:
- This message.
 
- 
hasStreamingContentpublic boolean hasStreamingContent()Indicates that the response's content has to be considered as a streaming and thus some special treatments may apply on it.- Returns:
- true if the response's content has to be considered as a streaming content.
 
- 
setStreamingContentSet that the response's content has to be considered as a streaming and thus some special treatments may apply on it.- Parameters:
- streamingContent- Is it a streamed content or not ?
- Returns:
- This response.
 
- 
getTrailersReturns the trailers, aka trailing headers.- Returns:
- The trailers.
 
- 
addTrailersAdd one or more trailers, aka trailing headers, to the response.- Parameters:
- trailers- The trailers to add (not null).
- Returns:
- This response.
 
- 
putTrailersPut one or more trailers, aka trailing headers, to the response. This will overwrite any existing trailers values for the names of the trailers provided.- Parameters:
- trailers- The trailers to put (not null).
- Returns:
- This response.
 
 
-