- All Superinterfaces:
HttpEntity
An object that can be fed after it was created. Implementers can leverage it for non-blocking streaming and for trailers
sending.
Feedable feedable = new FeedableImpl();
feedable.feed(firstFragment);
feedable.feed(secondFragment);
feedable.feed(thirdFragment);
feedable.complete();
- Since:
- 0.13
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidcomplete()Afterfeed(java.nio.ByteBuffer)ing all the data fragments, user must complete the entity by calling this method orcompleteWithTrailers(org.mule.runtime.api.util.MultiMap<java.lang.String, java.lang.String>).voidcompleteWithTrailers(org.mule.runtime.api.util.MultiMap<String, String> trailers) Afterfeed(java.nio.ByteBuffer)ing all the data fragments, user must complete the entity by calling this method orcomplete().voidSignals the entity with an error.voidfeed(ByteBuffer data) Writes a fragment of the body to this entity abstraction.Methods inherited from interface org.mule.sdk.api.http.domain.entity.HttpEntity
getBytes, getBytesLength, getContent, isReactive, isStreaming, onComplete, onData
-
Method Details
-
feed
Writes a fragment of the body to this entity abstraction.- Parameters:
data- buffer containing the data.- Throws:
IOException- if an error occurs while writing the data. For example, when the entity was already completed, both normally or with an error.
-
error
Signals the entity with an error. If this method is called instead of completing normally (withcomplete()), implementors may discard the previously fed data. Future calls tofeed(ByteBuffer)must fail.- Parameters:
exception- the error.- Throws:
IllegalStateException- if called after it was already completed, both normally or with an error.
-
complete
Afterfeed(java.nio.ByteBuffer)ing all the data fragments, user must complete the entity by calling this method orcompleteWithTrailers(org.mule.runtime.api.util.MultiMap<java.lang.String, java.lang.String>).- Throws:
IOException- if an error occurs during the completion of the entity.IllegalStateException- if called after it was already completed, both normally or with an error.
-
completeWithTrailers
void completeWithTrailers(org.mule.runtime.api.util.MultiMap<String, String> trailers) throws IOExceptionAfterfeed(java.nio.ByteBuffer)ing all the data fragments, user must complete the entity by calling this method orcomplete().- Parameters:
trailers- the trailers.- Throws:
IOException- if an error occurs during the completion of the entity.IllegalStateException- if called after it was already completed, both normally or with an error.
-