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,org.eclipse.jetty.util.Callback,org.eclipse.jetty.util.thread.Invocable
@Deprecated public class OutputStreamContentProvider extends java.lang.Object implements AsyncContentProvider, org.eclipse.jetty.util.Callback, java.io.Closeable
Deprecated.useOutputStreamRequestContentinsteadAContentProviderthat 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
org.eclipse.jetty.util.Callback.Completable, org.eclipse.jetty.util.Callback.Completing, org.eclipse.jetty.util.Callback.InvocableCallback, org.eclipse.jetty.util.Callback.Nested
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.ContentProvider
ContentProvider.Typed
-
-
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.org.eclipse.jetty.util.thread.Invocable.InvocationTypegetInvocationType()Deprecated.longgetLength()Deprecated.java.io.OutputStreamgetOutputStream()Deprecated.java.util.Iterator<java.nio.ByteBuffer>iterator()Deprecated.voidsetListener(AsyncContentProvider.Listener listener)Deprecated.voidsucceeded()Deprecated.protected voidwrite(java.nio.ByteBuffer buffer)Deprecated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.ContentProvider
isReproducible
-
-
-
-
Method Detail
-
getInvocationType
public org.eclipse.jetty.util.thread.Invocable.InvocationType getInvocationType()
Deprecated.- Specified by:
getInvocationTypein interfaceorg.eclipse.jetty.util.thread.Invocable
-
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.
-
write
protected void write(java.nio.ByteBuffer buffer)
Deprecated.
-
close
public void close()
Deprecated.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
succeeded
public void succeeded()
Deprecated.- Specified by:
succeededin interfaceorg.eclipse.jetty.util.Callback
-
failed
public void failed(java.lang.Throwable failure)
Deprecated.- Specified by:
failedin interfaceorg.eclipse.jetty.util.Callback
-
-