public class BasicHttpEntity extends BasicHttpEntity
BasicHttpEntity
with additional features.
Provides the following features:
Suppliers
.
chunked, contentEncoding, contentType, OUTPUT_BUFFER_SIZE
Constructor and Description |
---|
BasicHttpEntity(Object content)
Creates a new basic entity.
|
BasicHttpEntity(Object content,
ContentType contentType,
ContentEncoding contentEncoding)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
asBytes()
Converts the contents of this entity as a byte array.
|
FluentByteArrayAssertion<BasicHttpEntity> |
assertBytes()
Returns an assertion on the contents of this entity.
|
FluentStringAssertion<BasicHttpEntity> |
assertString()
Returns an assertion on the contents of this entity.
|
String |
asString()
Converts the contents of this entity as a byte array.
|
BasicHttpEntity |
cache()
Specifies that the contents of this resource should be cached into an internal byte array so that it can
be read multiple times.
|
BasicHttpEntity |
cache(boolean value)
Specifies that the contents of this resource should be cached into an internal byte array so that it can
be read multiple times.
|
BasicHttpEntity |
chunked()
Shortcut for calling
AbstractHttpEntity.setChunked(boolean) with |
BasicHttpEntity |
chunked(boolean value)
Shortcut for calling
AbstractHttpEntity.setChunked(boolean) . |
BasicHttpEntity |
contentEncoding(Header value)
Shortcut for calling
AbstractHttpEntity.setContentEncoding(Header) . |
BasicHttpEntity |
contentEncoding(String value)
Shortcut for calling
AbstractHttpEntity.setContentEncoding(String) . |
BasicHttpEntity |
contentLength(long value)
Shortcut for calling
BasicHttpEntity.setContentLength(long) . |
BasicHttpEntity |
contentType(Header value)
Shortcut for calling
AbstractHttpEntity.setContentType(Header) . |
BasicHttpEntity |
contentType(String value)
Shortcut for calling
AbstractHttpEntity.setContentType(String) . |
InputStream |
getContent() |
long |
getContentLength() |
protected Object |
getRawContent()
Returns the raw content of this resource.
|
protected boolean |
isCacheable(Object o)
Returns
|
boolean |
isRepeatable() |
boolean |
isStreaming() |
static BasicHttpEntity |
of(Object content)
Creator.
|
static BasicHttpEntity |
of(Supplier<?> content)
Creator.
|
protected byte[] |
readBytes(Object o)
Reads the contents of the specified object as a byte array.
|
protected Object |
unwrap(Object o)
If the specified object is a
Supplier , returns the supplied value, otherwise the same value. |
void |
writeTo(OutputStream os) |
setContent, setContentLength
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType, toString
public BasicHttpEntity(Object content)
content
- The content.
Supplier
of anything on this list.
public BasicHttpEntity(Object content, ContentType contentType, ContentEncoding contentEncoding)
content
- The content.
Supplier
of anything on this list.
contentType
- The content type of the contents.
contentEncoding
- The content encoding of the contents.
public static BasicHttpEntity of(Object content)
content
- The content.
Supplier
of anything on this list.
BasicHttpEntity
object.public static BasicHttpEntity of(Supplier<?> content)
content
- The content.
Supplier
of anything on this list.
BasicHttpEntity
object.public BasicHttpEntity contentType(String value)
AbstractHttpEntity.setContentType(String)
.value
- The new public BasicHttpEntity contentType(Header value)
AbstractHttpEntity.setContentType(Header)
.value
- The new public BasicHttpEntity contentLength(long value)
BasicHttpEntity.setContentLength(long)
.value
- The new public BasicHttpEntity contentEncoding(String value)
AbstractHttpEntity.setContentEncoding(String)
.value
- The new public BasicHttpEntity contentEncoding(Header value)
AbstractHttpEntity.setContentEncoding(Header)
.value
- The new public BasicHttpEntity chunked()
AbstractHttpEntity.setChunked(boolean)
with getContentLength()
method returns a negative value, the HttpClient code will always
use chunked encoding.
public BasicHttpEntity chunked(boolean value)
AbstractHttpEntity.setChunked(boolean)
.
getContentLength()
method returns a negative value, the HttpClient code will always
use chunked encoding.
value
- The new value for this flag.public BasicHttpEntity cache()
public BasicHttpEntity cache(boolean value)
value
- The new value for this flag.public String asString() throws IOException
IOException
- If a problem occurred while trying to read the byte array.public byte[] asBytes() throws IOException
IOException
- If a problem occurred while trying to read the byte array.public FluentStringAssertion<BasicHttpEntity> assertString() throws IOException
IOException
- If a problem occurred while trying to read the byte array.public FluentByteArrayAssertion<BasicHttpEntity> assertBytes() throws IOException
IOException
- If a problem occurred while trying to read the byte array.public boolean isRepeatable()
isRepeatable
in interface HttpEntity
isRepeatable
in class BasicHttpEntity
public long getContentLength()
getContentLength
in interface HttpEntity
getContentLength
in class BasicHttpEntity
public InputStream getContent()
getContent
in interface HttpEntity
getContent
in class BasicHttpEntity
public void writeTo(OutputStream os) throws IOException
writeTo
in interface HttpEntity
writeTo
in class BasicHttpEntity
IOException
public boolean isStreaming()
isStreaming
in interface HttpEntity
isStreaming
in class BasicHttpEntity
protected Object getRawContent()
protected boolean isCacheable(Object o)
The default implementation returns
o
- The object to check.protected byte[] readBytes(Object o) throws IOException
o
- The object to read.IOException
- If object could not be read.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.