Namespace class that contains the definitions of a content source,
a content sink and a content chunk.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA chunk of content indicating whether it is the last chunk.static interfaceA content sink that writes the content to its implementation (a socket, a file, etc.).static interfaceA source of content that can be read with a read/demand model. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopy(Content.Source source, Content.Sink sink, Content.Chunk.Processor chunkProcessor, org.eclipse.jetty.util.Callback callback) Copies the given content source to the given content sink, notifying the given callback when the copy is complete.static voidcopy(Content.Source source, Content.Sink sink, org.eclipse.jetty.util.Callback callback) Copies the given content source to the given content sink, notifying the given callback when the copy is complete (either succeeded or failed).
-
Method Details
-
copy
public static void copy(Content.Source source, Content.Sink sink, org.eclipse.jetty.util.Callback callback) Copies the given content source to the given content sink, notifying the given callback when the copy is complete (either succeeded or failed).
In case of failures, the content source is
failedtoo.- Parameters:
source- the source to copy fromsink- the sink to copy tocallback- the callback to notify when the copy is complete
-
copy
public static void copy(Content.Source source, Content.Sink sink, Content.Chunk.Processor chunkProcessor, org.eclipse.jetty.util.Callback callback) Copies the given content source to the given content sink, notifying the given callback when the copy is complete.
The optional
chunkHandlerparameter is a predicate whose code may inspect the chunk and handle it differently from how the implementation would handle it.If the predicate returns
true, it means that the chunk is handled externally and its callback completed, or eventually completed.If the predicate returns
false, it means that the chunk is not handled, its callback will not be completed, and the implementation will handle the chunk and its callback.- Parameters:
source- the source to copy fromsink- the sink to copy tochunkProcessor- a (possiblynull) predicate to handle the current chunk and its callbackcallback- the callback to notify when the copy is complete
-