@UnstableApi public final class ByteBufHttpData extends AbstractHttpData implements io.netty.buffer.ByteBufHolder
HttpData that is backed by a ByteBuf for optimizing certain internal use cases. Not for
general use.EMPTY_DATA| Constructor and Description |
|---|
ByteBufHttpData(io.netty.buffer.ByteBuf buf,
boolean endOfStream)
Constructs a new
ByteBufHttpData. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
array()
Returns the underlying byte array of this data.
|
io.netty.buffer.ByteBuf |
content() |
ByteBufHttpData |
copy() |
ByteBufHttpData |
duplicate() |
protected byte |
getByte(int index)
Gets the
byte value at the given index. |
boolean |
isEmpty()
Returns whether the
HttpData.length() is 0. |
boolean |
isEndOfStream()
Tells whether the stream should be ended when writing this object.
|
int |
length()
Returns the length of this data.
|
int |
refCnt() |
boolean |
release() |
boolean |
release(int decrement) |
ByteBufHttpData |
replace(io.netty.buffer.ByteBuf content) |
ByteBufHttpData |
retain() |
ByteBufHttpData |
retain(int increment) |
ByteBufHttpData |
retainedDuplicate() |
InputStream |
toInputStream()
Returns a new
InputStream that is sourced from this data. |
String |
toString() |
String |
toString(Charset charset)
Decodes this data into a
String. |
ByteBufHttpData |
touch() |
ByteBufHttpData |
touch(Object hint) |
ByteBufHttpData |
withEndOfStream()
Returns a new
HttpData whose HTTP/2 endOfStream flag is set. |
equals, hashCodepublic ByteBufHttpData(io.netty.buffer.ByteBuf buf,
boolean endOfStream)
ByteBufHttpData. Ownership of buf is taken by this
ByteBufHttpData, which must not be mutated anymore.public boolean isEndOfStream()
HttpObjectHttpHeaders-only responses or to more efficiently close the stream along with the last piece of
HttpData. This only has meaning for HttpObject writers, not readers.isEndOfStream in interface HttpObjectpublic byte[] array()
HttpDatapublic int length()
HttpDatapublic boolean isEmpty()
HttpDataHttpData.length() is 0.public int refCnt()
refCnt in interface io.netty.util.ReferenceCountedpublic ByteBufHttpData retain()
retain in interface io.netty.buffer.ByteBufHolderretain in interface io.netty.util.ReferenceCountedpublic ByteBufHttpData retain(int increment)
retain in interface io.netty.buffer.ByteBufHolderretain in interface io.netty.util.ReferenceCountedpublic ByteBufHttpData touch()
touch in interface io.netty.buffer.ByteBufHoldertouch in interface io.netty.util.ReferenceCountedpublic ByteBufHttpData touch(Object hint)
touch in interface io.netty.buffer.ByteBufHoldertouch in interface io.netty.util.ReferenceCountedpublic boolean release()
release in interface io.netty.util.ReferenceCountedpublic boolean release(int decrement)
release in interface io.netty.util.ReferenceCountedpublic io.netty.buffer.ByteBuf content()
content in interface io.netty.buffer.ByteBufHolderpublic ByteBufHttpData copy()
copy in interface io.netty.buffer.ByteBufHolderpublic ByteBufHttpData duplicate()
duplicate in interface io.netty.buffer.ByteBufHolderpublic ByteBufHttpData retainedDuplicate()
retainedDuplicate in interface io.netty.buffer.ByteBufHolderpublic ByteBufHttpData replace(io.netty.buffer.ByteBuf content)
replace in interface io.netty.buffer.ByteBufHolderprotected byte getByte(int index)
AbstractHttpDatabyte value at the given index.getByte in class AbstractHttpDatapublic String toString(Charset charset)
HttpDataString.public InputStream toInputStream()
HttpDataInputStream that is sourced from this data.
Note, if this HttpData is pooled (e.g., it is the result of a call to
HttpResponse.aggregateWithPooledObjects(ByteBufAllocator)), then this InputStream will
increase the reference count of the underlying buffer. Make sure to call InputStream.close(),
usually using a try-with-resources invocation, to release this extra reference. And as usual, don't
forget to call ReferenceCountUtil.release(Object) on this HttpData itself too.
toInputStream in interface HttpDatapublic ByteBufHttpData withEndOfStream()
HttpDataHttpData whose HTTP/2 endOfStream flag is set.withEndOfStream in interface HttpDataCopyright © 2020 LeanCloud. All rights reserved.