Class BufferedHttpEntity
- All Implemented Interfaces:
Closeable
,AutoCloseable
,EntityDetails
,HttpEntity
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBufferedHttpEntity
(HttpEntity entity) Creates a new buffered entity wrapper. -
Method Summary
Modifier and TypeMethodDescriptionReturns a content stream of the entity.long
Returns length of the entity, if known.boolean
Tells that this entity does not have to be chunked.boolean
Tells that this entity is repeatable.boolean
Tells whether this entity depends on an underlying stream.void
writeTo
(OutputStream outStream) Writes the entity content out to the output stream.Methods inherited from class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
close, getContentEncoding, getContentType, getTrailerNames, getTrailers, toString
-
Field Details
-
buffer
private final byte[] buffer
-
-
Constructor Details
-
BufferedHttpEntity
Creates a new buffered entity wrapper.- Parameters:
entity
- the entity to wrap, not null- Throws:
IllegalArgumentException
- if wrapped is nullIOException
-
-
Method Details
-
getContentLength
public long getContentLength()Description copied from interface:EntityDetails
Returns length of the entity, if known.- Specified by:
getContentLength
in interfaceEntityDetails
- Overrides:
getContentLength
in classHttpEntityWrapper
-
getContent
Description copied from interface:HttpEntity
Returns a content stream of the entity.Repeatable
entities are expected to create a new instance ofInputStream
for each invocation of this method and therefore can be consumed multiple times. Entities that are notrepeatable
are expected to return the sameInputStream
instance and therefore may not be consumed more than once.If this entity belongs to an incoming HTTP message, calling
InputStream.close()
on the returnedInputStream
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: Please note all entity implementations must ensure that all allocated resources are properly deallocated after the
InputStream.close()
method is invoked.- Specified by:
getContent
in interfaceHttpEntity
- Overrides:
getContent
in classHttpEntityWrapper
- Returns:
- content stream of the entity.
- Throws:
IOException
- if the stream could not be created- See Also:
-
isChunked
public boolean isChunked()Tells that this entity does not have to be chunked.- Specified by:
isChunked
in interfaceEntityDetails
- Overrides:
isChunked
in classHttpEntityWrapper
- Returns:
false
-
isRepeatable
public boolean isRepeatable()Tells that this entity is repeatable.- Specified by:
isRepeatable
in interfaceHttpEntity
- Overrides:
isRepeatable
in classHttpEntityWrapper
- Returns:
true
-
writeTo
Description copied from interface:HttpEntity
Writes the entity content out to the output stream.IMPORTANT: Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.
- Specified by:
writeTo
in interfaceHttpEntity
- Overrides:
writeTo
in classHttpEntityWrapper
- Parameters:
outStream
- the output stream to write entity content to- Throws:
IOException
- if an I/O error occurs
-
isStreaming
public boolean isStreaming()Description copied from interface:HttpEntity
Tells whether this entity depends on an underlying stream. Streamed entities that read data directly from the socket should returntrue
. Self-contained entities should returnfalse
. Wrapping entities should delegate this call to the wrapped entity.- Specified by:
isStreaming
in interfaceHttpEntity
- Overrides:
isStreaming
in classHttpEntityWrapper
- Returns:
true
if the entity content is streamed,false
otherwise
-