- All Known Implementing Classes:
LoggingChunkedRestResponseBody
public interface ChunkedRestResponseBody
The body of a rest response that uses chunked HTTP encoding. Implementations are used to avoid materializing full responses on heap and
instead serialize only as much of the response as can be flushed to the network right away.
-
Method Summary
Modifier and TypeMethodDescriptionencodeChunk
(int sizeHint, Recycler<org.apache.lucene.util.BytesRef> recycler) Serializes approximately as many bytes of the response as request bysizeHint
to aReleasableBytesReference
that is created from buffers backed by the givenrecycler
.static ChunkedRestResponseBody
fromXContent
(ChunkedToXContent chunkedToXContent, ToXContent.Params params, RestChannel channel) Create a chunked response body to be written to a specificRestChannel
from aChunkedToXContent
.boolean
isDone()
-
Method Details
-
isDone
boolean isDone()- Returns:
- true once this response has been written fully.
-
encodeChunk
ReleasableBytesReference encodeChunk(int sizeHint, Recycler<org.apache.lucene.util.BytesRef> recycler) throws IOException Serializes approximately as many bytes of the response as request bysizeHint
to aReleasableBytesReference
that is created from buffers backed by the givenrecycler
.- Parameters:
sizeHint
- how many bytes to approximately serialize for the given chunkrecycler
- recycler used to acquire buffers- Returns:
- serialized chunk
- Throws:
IOException
- on serialization failure
-
getResponseContentTypeString
String getResponseContentTypeString()- Returns:
- the response Content-Type header value for this response body
-
fromXContent
static ChunkedRestResponseBody fromXContent(ChunkedToXContent chunkedToXContent, ToXContent.Params params, RestChannel channel) throws IOException Create a chunked response body to be written to a specificRestChannel
from aChunkedToXContent
.- Parameters:
chunkedToXContent
- chunked x-content instance to serializeparams
- parameters to use for serializationchannel
- channel the response will be written to- Returns:
- chunked rest response body
- Throws:
IOException
-