public interface Message extends Closeable
A message is a resource container, and thus needs to be closed in order to free-up acquired resources.
Please carefully note the following regarding closing a message:
the asynchronous nature of both Handler
and Filter
that produce
promises of Response
make it impossible to know,
for the producer of the message, when it can be closed. Thus, the responsibility of closing the message
is on the final consumer: the point after which the message is no longer used.
Example of such situations:
Filter
: Production and forwarding of a new Response
instance
in one of the callbacks (Function
/ AsyncFunction
)
attached to a promise, instead of the given response
parameter.response
because a different type
(not Response
) has to be returned.Utils.closeSilently(Closeable...)
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources associated with the entity.
|
Entity |
getEntity()
Returns the entity.
|
Headers |
getHeaders()
Returns the headers.
|
String |
getVersion()
Returns the protocol version.
|
Message |
setEntity(Object o)
Sets the content of the entity to the provided value.
|
Message |
setVersion(String version)
Sets the protocol version.
|
Entity getEntity()
Headers getHeaders()
String getVersion()
HTTP/1.1
.Message setEntity(Object o)
Content-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.Message setVersion(String version)
HTTP/1.1
.version
- The protocol version.void close()
close
in interface AutoCloseable
close
in interface Closeable
Entity.close()
Copyright © 2025 Open Identity Platform Community. All rights reserved.