Class BuiltResponse
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
BuiltResponseEntityNotBacked,ClientResponse,ServerResponse
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
AbstractBuiltResponse.InputStreamWrapper<T extends BuiltResponse>Nested classes/interfaces inherited from class jakarta.ws.rs.core.Response
Response.ResponseBuilder, Response.Status, Response.StatusType -
Field Summary
Fields inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
annotations, bufferedEntity, entity, entityClass, genericType, is, isClosed, metadata, processor, reason, status, streamFullyRead, streamRead -
Constructor Summary
ConstructorsConstructorDescriptionBuiltResponse(int status, String reason, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations) BuiltResponse(int status, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations) -
Method Summary
Modifier and TypeMethodDescriptionbooleanBuffer the message entity data.protected InputStreamprotected InputStream<T> TreadEntity(Class<T> type, Type genericType, Annotation[] anns) protected <T> ObjectreadFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations) voidRelease underlying connection but do not close.voidreleaseConnection(boolean consumeInputStream) Release underlying connection but do not close.protected voidMethods inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
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, toHeaderStringMethods inherited from class jakarta.ws.rs.core.Response
accepted, accepted, created, fromResponse, getHeaders, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, status, temporaryRedirect
-
Constructor Details
-
BuiltResponse
public BuiltResponse() -
BuiltResponse
public BuiltResponse(int status, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations) -
BuiltResponse
public BuiltResponse(int status, String reason, Headers<Object> metadata, Object entity, Annotation[] entityAnnotations)
-
-
Method Details
-
readEntity
- Specified by:
readEntityin classAbstractBuiltResponse
-
readFrom
protected <T> Object readFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations) -
getEntityStream
- Specified by:
getEntityStreamin classAbstractBuiltResponse
-
setInputStream
- Specified by:
setInputStreamin classAbstractBuiltResponse
-
getInputStream
- Specified by:
getInputStreamin classAbstractBuiltResponse
-
releaseConnection
Description copied from class:AbstractBuiltResponseRelease underlying connection but do not close.- Specified by:
releaseConnectionin classAbstractBuiltResponse- Throws:
IOException- if I/O error occurred
-
releaseConnection
Description copied from class:AbstractBuiltResponseRelease underlying connection but do not close.- Specified by:
releaseConnectionin classAbstractBuiltResponse- Parameters:
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.
- Throws:
IOException- if I/O error occured
-
bufferEntity
public boolean bufferEntity()Description copied from class:ResponseBuffer the message entity data.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
bufferEntitymethod is ignored and the method returnsfalse.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 thebufferEntity()method is consistent across all invocations of the method on the sameResponseinstance.Buffering the message entity data allows for multiple invocations of
readEntity(...)methods on the response instance. Note however, that once the response instance itself isclosed, 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 anIllegalStateExceptionbeing thrown.- Specified by:
bufferEntityin classResponse- Returns:
trueif the message entity input stream was available and was buffered successfully, returnsfalseif the entity stream was not available.
-