Top Description Fields Constructors Methods
org.apache.hc.core5.http.io.entity

public Class HttpEntityWrapper

extends Object
implements HttpEntity
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.HttpEntity, java.io.Closeable, java.lang.AutoCloseable, org.apache.hc.core5.http.EntityDetails
Known Direct Subclasses
org.apache.hc.core5.http.io.entity.BufferedHttpEntity
Annotations
@Contract
threading:IMMUTABLE_CONDITIONAL
Imports
java.io.IOException, .InputStream, .OutputStream, java.util.List, .Set, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.function.Supplier, org.apache.hc.core5.http.Header, .HttpEntity, org.apache.hc.core5.util.Args

Base class for wrapping entities that delegates all calls to the wrapped entity. Implementations can derive from this class and override only those methods that should not be delegated to the wrapped entity.
Since
4.0

Field Summary

Modifier and TypeField and Description
private final HttpEntity
wrappedEntity

The wrapped entity.

Constructor Summary

AccessConstructor and Description
public
HttpEntityWrapper(final HttpEntity
the entity to wrap.
wrappedEntity
)

Creates a new entity wrapper.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public InputStream
getContent()

Implements org.apache.hc.core5.http.HttpEntity.getContent.

Returns a content stream of the entity.
public String
getContentEncoding()

Implements org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Returns content encoding of the entity, if known.
public long
getContentLength()

Implements org.apache.hc.core5.http.EntityDetails.getContentLength.

Returns length of the entity, if known.
public String
getContentType()

Implements org.apache.hc.core5.http.EntityDetails.getContentType.

Returns content type of the entity, if known.
public Set<String>
getTrailerNames()

Implements org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Preliminary declaration of trailing headers.
public Supplier<List<? extends Header>>
getTrailers()

Implements org.apache.hc.core5.http.HttpEntity.getTrailers.

Returns supplier of message trailers - headers sent after message body.
public boolean
isChunked()

Implements org.apache.hc.core5.http.EntityDetails.isChunked.

Returns chunked transfer hint for this entity.
public boolean
isRepeatable()

Implements org.apache.hc.core5.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once.
public boolean
isStreaming()

Implements org.apache.hc.core5.http.HttpEntity.isStreaming.

Tells whether this entity depends on an underlying stream.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

wrappedEntityback to summary
private final HttpEntity wrappedEntity

The wrapped entity.

Constructor Detail

HttpEntityWrapperback to summary
public HttpEntityWrapper(final HttpEntity wrappedEntity)

Creates a new entity wrapper.

Parameters
wrappedEntity:HttpEntity

the entity to wrap.

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getContentback to summary
public InputStream getContent() throws IOException

Implements org.apache.hc.core5.http.HttpEntity.getContent.

Doc from org.apache.hc.core5.http.HttpEntity.getContent.

Returns a content stream of the entity. Repeatable entities are expected to create a new instance of InputStream for each invocation of this method and therefore can be consumed multiple times. Entities that are not repeatable are expected to return the same InputStream instance and therefore may not be consumed more than once.

If this entity belongs to an incoming HTTP message, calling InputStream#close() on the returned InputStream will try to consume the complete entity content to keep the connection alive. In cases where this is undesired, e.g. when only a small part of the content is relevant and consuming the complete entity content would be too inefficient, only the HTTP message from which this entity was obtained should be closed (if supported).

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated after the InputStream#close() method is invoked.

Returns:InputStream

content stream of the entity.

Annotations
@Override
Exceptions
IOException:
if the stream could not be created
getContentEncodingback to summary
public String getContentEncoding()

Implements org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Doc from org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Returns content encoding of the entity, if known.

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Implements org.apache.hc.core5.http.EntityDetails.getContentLength.

Doc from org.apache.hc.core5.http.EntityDetails.getContentLength.

Returns length of the entity, if known.

Annotations
@Override
getContentTypeback to summary
public String getContentType()

Implements org.apache.hc.core5.http.EntityDetails.getContentType.

Doc from org.apache.hc.core5.http.EntityDetails.getContentType.

Returns content type of the entity, if known.

Annotations
@Override
getTrailerNamesback to summary
public Set<String> getTrailerNames()

Implements org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Doc from org.apache.hc.core5.http.EntityDetails.getTrailerNames.

Preliminary declaration of trailing headers.

Annotations
@Override
getTrailersback to summary
public Supplier<List<? extends Header>> getTrailers()

Implements org.apache.hc.core5.http.HttpEntity.getTrailers.

Doc from org.apache.hc.core5.http.HttpEntity.getTrailers.

Returns supplier of message trailers - headers sent after message body. May return null if trailers are not available.

Annotations
@Override
isChunkedback to summary
public boolean isChunked()

Implements org.apache.hc.core5.http.EntityDetails.isChunked.

Doc from org.apache.hc.core5.http.EntityDetails.isChunked.

Returns chunked transfer hint for this entity.

The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.

Annotations
@Override
isRepeatableback to summary
public boolean isRepeatable()

Implements org.apache.hc.core5.http.HttpEntity.isRepeatable.

Doc from org.apache.hc.core5.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.

Returns:boolean

true if the entity is repeatable, false otherwise.

Annotations
@Override
isStreamingback to summary
public boolean isStreaming()

Implements org.apache.hc.core5.http.HttpEntity.isStreaming.

Doc from org.apache.hc.core5.http.HttpEntity.isStreaming.

Tells whether this entity depends on an underlying stream. Streamed entities that read data directly from the socket should return true. Self-contained entities should return false. Wrapping entities should delegate this call to the wrapped entity.

Returns:boolean

true if the entity content is streamed, false otherwise

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeToback to summary
public void writeTo(final OutputStream outStream) throws IOException

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Doc from org.apache.hc.core5.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

Parameters
outStream:OutputStream

the output stream to write entity content to

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs