public class BuiltResponse extends AbstractBuiltResponse
AbstractBuiltResponse.InputStreamWrapper<T extends BuiltResponse>
Response.ResponseBuilder, Response.Status, Response.StatusType
annotations, bufferedEntity, entity, entityClass, genericType, is, isClosed, metadata, processor, reason, status, streamFullyRead, streamRead
Constructor and Description |
---|
BuiltResponse() |
BuiltResponse(int status,
Headers<Object> metadata,
Object entity,
Annotation[] entityAnnotations) |
BuiltResponse(int status,
String reason,
Headers<Object> metadata,
Object entity,
Annotation[] entityAnnotations) |
Modifier and Type | Method and Description |
---|---|
boolean |
bufferEntity()
Buffer the message entity data.
|
protected InputStream |
getEntityStream() |
protected InputStream |
getInputStream() |
<T> T |
readEntity(Class<T> type,
Type genericType,
Annotation[] anns) |
protected <T> Object |
readFrom(Class<T> type,
Type genericType,
MediaType media,
Annotation[] annotations) |
void |
releaseConnection()
Release underlying connection but do not close.
|
void |
releaseConnection(boolean consumeInputStream)
Release underlying connection but do not close.
|
protected void |
setInputStream(InputStream is) |
abortIfClosed, addMethodAnnotations, close, getAllowedMethods, getAnnotations, getCookies, getDate, getEntity, getEntityClass, getEntityTag, getGenericType, getHeaderString, getHeaderValueProcessor, getLanguage, getLastModified, getLength, getLink, getLinkBuilder, getLinks, getLocation, getMediaType, getMetadata, getReasonPhrase, getStatus, getStatusInfo, getStringHeaders, hasEntity, hasLink, isClosed, readEntity, readEntity, readEntity, readEntity, resetEntity, setAnnotations, setEntity, setEntityClass, setGenericType, setMetadata, setReasonPhrase, setStatus, setStreamFullyRead, setStreamRead, toHeaderString
accepted, accepted, created, fromResponse, getHeaders, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, status, temporaryRedirect
public BuiltResponse()
public BuiltResponse(int status, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations)
public BuiltResponse(int status, String reason, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations)
public <T> T readEntity(Class<T> type, Type genericType, Annotation[] anns)
readEntity
in class AbstractBuiltResponse
protected <T> Object readFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations)
protected InputStream getEntityStream()
getEntityStream
in class AbstractBuiltResponse
protected void setInputStream(InputStream is)
setInputStream
in class AbstractBuiltResponse
protected InputStream getInputStream()
getInputStream
in class AbstractBuiltResponse
public void releaseConnection() throws IOException
AbstractBuiltResponse
releaseConnection
in class AbstractBuiltResponse
IOException
- if I/O error occurredpublic void releaseConnection(boolean consumeInputStream) throws IOException
AbstractBuiltResponse
releaseConnection
in class AbstractBuiltResponse
consumeInputStream
- boolean to indicate either the underlying input stream must be fully read before releasing the connection or not.
For most HTTP connection implementations, consuming the underlying input stream before releasing the connection will help to ensure connection reusability with respect of Keep-Alive policy.
IOException
- if I/O error occuredpublic boolean bufferEntity()
Response
In case the message entity is backed by an unconsumed entity input stream,
all the bytes of the original entity input stream are read and stored in a
local buffer. The original entity input stream is consumed and automatically
closed as part of the operation and the method returns true
.
In case the response entity instance is not backed by an unconsumed input stream
an invocation of bufferEntity
method is ignored and the method returns
false
.
This operation is idempotent, i.e. it can be invoked multiple times with
the same effect which also means that calling the bufferEntity()
method on an already buffered (and thus closed) message instance is legal
and has no further effect. Also, the result returned by the bufferEntity()
method is consistent across all invocations of the method on the same
Response
instance.
Buffering the message entity data allows for multiple invocations of
readEntity(...)
methods on the response instance. Note however, that
once the response instance itself is closed
, the implementations
are expected to release the buffered message entity data too. Therefore any subsequent
attempts to read a message entity stream on such closed response will result in an
IllegalStateException
being thrown.
bufferEntity
in class Response
true
if the message entity input stream was available and
was buffered successfully, returns false
if the entity stream
was not available.Copyright © 2021 JBoss by Red Hat. All rights reserved.