Class OutputStreamContentProvider
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Iterable<ByteBuffer>,- ContentProvider,- AsyncContentProvider,- Callback,- Invocable
ContentProvider that provides content asynchronously through an OutputStream
 similar to DeferredContentProvider.
 
 OutputStreamContentProvider can only be used in conjunction with
 Request.send(Response.CompleteListener) (and not with its blocking counterpart Request.send())
 because it provides content asynchronously.
 
 The deferred content is provided once by writing to the output stream
 and then fully consumed.
 Invocations to the iterator() method after the first will return an "empty" iterator
 because the stream has been consumed on the first invocation.
 However, it is possible for subclasses to support multiple invocations of iterator()
 by overriding write(ByteBuffer) and close(), copying the bytes and making them
 available for subsequent invocations.
 
 Content must be provided by writing to the output stream, that must be
 closed when all content has been provided.
 
Example usage:
 HttpClient httpClient = ...;
 // Use try-with-resources to autoclose the output stream
 OutputStreamContentProvider content = new OutputStreamContentProvider();
 try (OutputStream output = content.getOutputStream())
 {
     httpClient.newRequest("localhost", 8080)
             .content(content)
             .send(new Response.CompleteListener()
             {
                 @Override
                 public void onComplete(Result result)
                 {
                     // Your logic here
                 }
             });
     // At a later time...
     output.write("some content".getBytes());
 }
 - 
Nested Class SummaryNested classes/interfaces inherited from interface org.eclipse.jetty.client.AsyncContentProviderAsyncContentProvider.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.CallbackCallback.Completable, Callback.Completing, Callback.NestedNested classes/interfaces inherited from interface org.eclipse.jetty.client.api.ContentProviderContentProvider.TypedNested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.InvocableInvocable.InvocationType, Invocable.ReadyTask, Invocable.Task
- 
Field SummaryFields inherited from interface org.eclipse.jetty.util.thread.Invocable__nonBlocking
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Deprecated.voidDeprecated.Callback invoked when the operation fails.Deprecated.longDeprecated.Deprecated.iterator()Deprecated.voidsetListener(AsyncContentProvider.Listener listener) Deprecated.voidDeprecated.Callback invoked when the operation completes.protected voidwrite(ByteBuffer buffer) Deprecated.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.CallbackcompleteWithMethods inherited from interface org.eclipse.jetty.client.api.ContentProviderisReproducibleMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
OutputStreamContentProviderpublic OutputStreamContentProvider()Deprecated.
 
- 
- 
Method Details- 
getInvocationTypeDeprecated.- Specified by:
- getInvocationTypein interface- Invocable
- Returns:
- The InvocationType of this object
 
- 
getLengthpublic long getLength()Deprecated.- Specified by:
- getLengthin interface- ContentProvider
- Returns:
- the content length, if known, or -1 if the content length is unknown
 
- 
iteratorDeprecated.- Specified by:
- iteratorin interface- Iterable<ByteBuffer>
 
- 
setListenerDeprecated.- Specified by:
- setListenerin interface- AsyncContentProvider
- Parameters:
- listener- the listener to be notified of content availability
 
- 
getOutputStreamDeprecated.
- 
writeDeprecated.
- 
closepublic void close()Deprecated.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
succeededpublic void succeeded()Deprecated.Description copied from interface:CallbackCallback invoked when the operation completes. 
- 
failedDeprecated.Description copied from interface:CallbackCallback invoked when the operation fails. 
 
- 
OutputStreamRequestContentinstead