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 HttpDatacopyOf(byte[] data) Creates a new instance from the specified byte array by first copying it.static HttpDatacopyOf(byte[] data, int offset, int length) Creates a new instance from the specified byte array,offsetandlengthby first copying it.static HttpDataCreates a new instance from the specifiedByteBufby first copying its content.static HttpDataempty()Returns an emptyHttpData.static HttpDataof(Charset charset, CharSequence text) Converts the specifiedtextinto anHttpData.static HttpDataConverts the specifiedtextinto anHttpData.static HttpDataConverts the specified formatted string into anHttpData.static HttpDataofAscii(CharSequence text) Converts the specifiedtextinto a US-ASCIIHttpData.static HttpDataConverts the specifiedtextinto a US-ASCIIHttpData.static HttpDataConverts the specified formatted string into a US-ASCIIHttpData.static HttpDataofUtf8(CharSequence text) Converts the specifiedtextinto a UTF-8HttpData.static HttpDataConverts the specifiedtextinto a UTF-8HttpData.static HttpDataConverts the specified formatted string into a UTF-8HttpData.default HttpDataReturns theHttpDatathat has the same content with this data and its HTTP/2endOfStreamflag set.withEndOfStream(boolean endOfStream) Returns theHttpDatathat has the same content with this data and its HTTP/2endOfStreamflag set with the specified value.static HttpDatawrap(byte[] data) Creates a new instance from the specified byte array.static HttpDatawrap(byte[] data, int offset, int length) Creates a new instance from the specified byte array,offsetandlength.static HttpDataMethods inherited from interface com.linecorp.armeria.common.Bytes
array, byteBuf, byteBuf, byteBuf, close, isEmpty, isPooled, length, toInputStream, toReader, toReaderAscii, toReaderUtf8, toString, toStringAscii, toStringUtf8, touchMethods 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,offsetandlength. The array is not copied; any changes made in the array later will be visible toHttpData.- Returns:
- a new
HttpData.empty()iflengthis 0. - Throws:
IndexOutOfBoundsException- ifoffsetandlengthare out of bounds
-
wrap
(Advanced users only) Converts the specified NettyByteBufinto 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,offsetandlengthby first copying it.- Returns:
- a new
HttpData.empty()iflengthis 0. - Throws:
ArrayIndexOutOfBoundsException- ifoffsetandlengthare out of bounds
-
copyOf
-
of
Converts the specifiedtextinto anHttpData. -
of
Converts the specifiedtextinto anHttpData. -
of
Converts the specified formatted string into anHttpData. The string is formatted byString.format(Locale, String, Object...)with English locale.- Parameters:
charset- theCharsetto 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()ifformatis empty.
-
ofUtf8
Converts the specifiedtextinto a UTF-8HttpData. -
ofUtf8
Converts the specifiedtextinto 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()ifformatis empty.
-
ofAscii
Converts the specifiedtextinto a US-ASCIIHttpData. -
ofAscii
Converts the specifiedtextinto 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()ifformatis empty.
-
withEndOfStream
Returns theHttpDatathat has the same content with this data and its HTTP/2endOfStreamflag set. If this data already hasendOfStreamset,thiswill be returned. -
withEndOfStream
Returns theHttpDatathat has the same content with this data and its HTTP/2endOfStreamflag set with the specified value. If this data already has the sameendOfStreamvalue set,thiswill be returned.
-