Package com.linecorp.armeria.common
Interface HttpData
- All Superinterfaces:
AutoCloseable
,Bytes
,HttpObject
,SafeCloseable
HTTP/2 data that contains a chunk of bytes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpData
copyOf
(byte[] data) Creates a new instance from the specified byte array by first copying it.static HttpData
copyOf
(byte[] data, int offset, int length) Creates a new instance from the specified byte array,offset
andlength
by first copying it.static HttpData
Creates a new instance from the specifiedByteBuf
by first copying its content.static HttpData
empty()
Returns an emptyHttpData
.static HttpData
of
(Charset charset, CharSequence text) Converts the specifiedtext
into anHttpData
.static HttpData
Converts the specifiedtext
into anHttpData
.static HttpData
Converts the specified formatted string into anHttpData
.static HttpData
ofAscii
(CharSequence text) Converts the specifiedtext
into a US-ASCIIHttpData
.static HttpData
Converts the specifiedtext
into a US-ASCIIHttpData
.static HttpData
Converts the specified formatted string into a US-ASCIIHttpData
.static HttpData
ofUtf8
(CharSequence text) Converts the specifiedtext
into a UTF-8HttpData
.static HttpData
Converts the specifiedtext
into a UTF-8HttpData
.static HttpData
Converts the specified formatted string into a UTF-8HttpData
.default HttpData
Returns theHttpData
that has the same content with this data and its HTTP/2endOfStream
flag set.withEndOfStream
(boolean endOfStream) Returns theHttpData
that has the same content with this data and its HTTP/2endOfStream
flag set with the specified value.static HttpData
wrap
(byte[] data) Creates a new instance from the specified byte array.static HttpData
wrap
(byte[] data, int offset, int length) Creates a new instance from the specified byte array,offset
andlength
.static HttpData
Methods inherited from interface com.linecorp.armeria.common.Bytes
array, byteBuf, byteBuf, byteBuf, close, isEmpty, isPooled, length, toInputStream, toReader, toReaderAscii, toReaderUtf8, toString, toStringAscii, toStringUtf8, touch
Methods inherited from interface com.linecorp.armeria.common.HttpObject
isEndOfStream
-
Method Details
-
empty
Returns an emptyHttpData
. -
wrap
Creates a new instance from the specified byte array. The array is not copied; any changes made in the array later will be visible toHttpData
. -
wrap
Creates a new instance from the specified byte array,offset
andlength
. The array is not copied; any changes made in the array later will be visible toHttpData
.- Returns:
- a new
HttpData
.empty()
iflength
is 0. - Throws:
IndexOutOfBoundsException
- ifoffset
andlength
are out of bounds
-
wrap
(Advanced users only) Converts the specified NettyByteBuf
into a pooledHttpData
. The buffer is not copied; any changes made to it will be visible toHttpData
. The ownership of the buffer is transferred to theHttpData
. If you still need to use it after calling this method, make sure to callByteBuf.retain()
first. -
copyOf
Creates a new instance from the specified byte array by first copying it. -
copyOf
Creates a new instance from the specified byte array,offset
andlength
by first copying it.- Returns:
- a new
HttpData
.empty()
iflength
is 0. - Throws:
ArrayIndexOutOfBoundsException
- ifoffset
andlength
are out of bounds
-
copyOf
-
of
Converts the specifiedtext
into anHttpData
. -
of
Converts the specifiedtext
into anHttpData
. -
of
Converts the specified formatted string into anHttpData
. The string is formatted byString.format(Locale, String, Object...)
with English locale.- Parameters:
charset
- theCharset
to use for encoding stringformat
- the format string of the response contentargs
- the arguments referenced by the format specifiers in the format string- Returns:
- a new
HttpData
.empty()
ifformat
is empty.
-
ofUtf8
Converts the specifiedtext
into a UTF-8HttpData
. -
ofUtf8
Converts the specifiedtext
into a UTF-8HttpData
. -
ofUtf8
Converts the specified formatted string into a UTF-8HttpData
. The string is formatted byString.format(Locale, String, Object...)
with English locale.- Parameters:
format
- the format string of the response contentargs
- the arguments referenced by the format specifiers in the format string- Returns:
- a new
HttpData
.empty()
ifformat
is empty.
-
ofAscii
Converts the specifiedtext
into a US-ASCIIHttpData
. -
ofAscii
Converts the specifiedtext
into a US-ASCIIHttpData
. -
ofAscii
Converts the specified formatted string into a US-ASCIIHttpData
. The string is formatted byString.format(Locale, String, Object...)
with English locale.- Parameters:
format
- the format string of the response contentargs
- the arguments referenced by the format specifiers in the format string- Returns:
- a new
HttpData
.empty()
ifformat
is empty.
-
withEndOfStream
Returns theHttpData
that has the same content with this data and its HTTP/2endOfStream
flag set. If this data already hasendOfStream
set,this
will be returned. -
withEndOfStream
Returns theHttpData
that has the same content with this data and its HTTP/2endOfStream
flag set with the specified value. If this data already has the sameendOfStream
value set,this
will be returned.
-