public abstract class HttpContentProducer extends Object
send
methods in HttpServiceResponder
.Constructor and Description |
---|
HttpContentProducer() |
Modifier and Type | Method and Description |
---|---|
long |
getContentLength()
Returns the length of the content or
-1L if the length is unknown. |
abstract ByteBuffer |
nextChunk(Transactional transactional)
This method provides a new chunk of data to be sent to the client.
|
abstract void |
onError(Throwable failureCause)
This method will get invoked when there is an error while sending body chunks.
|
abstract void |
onFinish()
This method will get invoked after the last chunk of data is sent.
|
public long getContentLength()
-1L
if the length is unknown.public abstract ByteBuffer nextChunk(Transactional transactional) throws Exception
ByteBuffer
instance across multiple calls to this method.
Access to transactional Datasets
must be done through the Transactional.execute(TxRunnable)
method.
transactional
- for executing a TxRunnable
in a single transaction.ByteBuffer
containing the next chunk of bytes to be sent to the client. If
the returned ByteBuffer
is empty (Buffer.hasRemaining()
== false
), it signals that's the end of the response body.Exception
- if there is any errorpublic abstract void onFinish() throws Exception
TransactionPolicy(TransactionControl
.Exception
- if there is any errorpublic abstract void onError(Throwable failureCause)
Exceptions
raised from either
nextChunk(Transactional)
or onFinish()
methods will have this method
invoked.
This method is always executed inside a single transaction unless annotated with TransactionPolicy(TransactionControl
.failureCause
- the reason of the failureCopyright © 2024 Cask Data, Inc. Licensed under the Apache License, Version 2.0.