Class OutputStreamContentProvider
- java.lang.Object
 - 
- org.eclipse.jetty.client.util.OutputStreamContentProvider
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.lang.AutoCloseable,java.lang.Iterable<java.nio.ByteBuffer>,ContentProvider,AsyncContentProvider,Callback,Invocable
@Deprecated(since="2021-05-27") public class OutputStreamContentProvider extends java.lang.Object implements AsyncContentProvider, Callback, java.io.Closeable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.AContentProviderthat provides content asynchronously through anOutputStreamsimilar toDeferredContentProvider.OutputStreamContentProvidercan only be used in conjunction withRequest.send(Response.CompleteListener)(and not with its blocking counterpartRequest.send()) because it provides content asynchronously.The deferred content is provided once by writing to the
output streamand then fully consumed. Invocations to theiterator()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 ofiterator()by overridingwrite(ByteBuffer)andclose(), copying the bytes and making them available for subsequent invocations.Content must be provided by writing to the
output stream, that must beclosedwhen 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 Summary
- 
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.AsyncContentProvider
AsyncContentProvider.Listener 
- 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback
Callback.Completable, Callback.Completing, Callback.Nested 
- 
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.ContentProvider
ContentProvider.Typed 
- 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.InvocationType 
 - 
 
- 
Field Summary
- 
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking 
 - 
 
- 
Constructor Summary
Constructors Constructor Description OutputStreamContentProvider()Deprecated. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Deprecated.voidfailed(java.lang.Throwable failure)Deprecated.Callback invoked when the operation fails.Invocable.InvocationTypegetInvocationType()Deprecated.longgetLength()Deprecated.java.io.OutputStreamgetOutputStream()Deprecated.java.util.Iterator<java.nio.ByteBuffer>iterator()Deprecated.voidsetListener(AsyncContentProvider.Listener listener)Deprecated.voidsucceeded()Deprecated.Callback invoked when the operation completes.- 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.eclipse.jetty.client.api.ContentProvider
isReproducible 
 - 
 
 - 
 
- 
- 
Method Detail
- 
getInvocationType
public Invocable.InvocationType getInvocationType()
Deprecated.- Specified by:
 getInvocationTypein interfaceInvocable- Returns:
 - The InvocationType of this object
 
 
- 
getLength
public long getLength()
Deprecated.- Specified by:
 getLengthin interfaceContentProvider- Returns:
 - the content length, if known, or -1 if the content length is unknown
 
 
- 
iterator
public java.util.Iterator<java.nio.ByteBuffer> iterator()
Deprecated.- Specified by:
 iteratorin interfacejava.lang.Iterable<java.nio.ByteBuffer>
 
- 
setListener
public void setListener(AsyncContentProvider.Listener listener)
Deprecated.- Specified by:
 setListenerin interfaceAsyncContentProvider- Parameters:
 listener- the listener to be notified of content availability
 
- 
getOutputStream
public java.io.OutputStream getOutputStream()
Deprecated. 
- 
close
public void close()
Deprecated.- Specified by:
 closein interfacejava.lang.AutoCloseable- Specified by:
 closein interfacejava.io.Closeable
 
- 
succeeded
public void succeeded()
Deprecated.Description copied from interface:CallbackCallback invoked when the operation completes.
- Specified by:
 succeededin interfaceCallback- See Also:
 Callback.failed(Throwable)
 
 - 
 
 -