- java.lang.Object
-
- org.eclipse.jetty.client.util.AsyncRequestContent
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Request.Content,Request.Content.Subscription
- Direct Known Subclasses:
OutputStreamRequestContent
public class AsyncRequestContent extends java.lang.Object implements Request.Content, Request.Content.Subscription, java.io.Closeable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request.Content
Request.Content.Consumer, Request.Content.Subscription
-
-
Constructor Summary
Constructors Constructor Description AsyncRequestContent(java.lang.String contentType, java.nio.ByteBuffer... buffers)AsyncRequestContent(java.nio.ByteBuffer... buffers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddemand()Demands more content, which eventually results inRequest.Content.Consumer.onContent(ByteBuffer, boolean, Callback)to be invoked.voidfail(java.lang.Throwable failure)Fails this request content, possibly failing and discarding accumulated content that was not demanded.voidflush()java.lang.StringgetContentType()longgetLength()booleanisClosed()booleanoffer(java.nio.ByteBuffer buffer)booleanoffer(java.nio.ByteBuffer buffer, Callback callback)Request.Content.Subscriptionsubscribe(Request.Content.Consumer consumer, boolean emitInitialContent)Initializes this content producer with the content consumer, and with the indication of whether initial content, if present, must be emitted upon the initial demand of content (to support delaying the send of the request content in case ofExpect: 100-ContinuewhenemitInitialContentisfalse).java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.Request.Content
isReproducible
-
-
-
-
Method Detail
-
getContentType
public java.lang.String getContentType()
- Specified by:
getContentTypein interfaceRequest.Content- Returns:
- the content type string such as "application/octet-stream" or "application/json;charset=UTF8", or null if no content type must be set
-
getLength
public long getLength()
- Specified by:
getLengthin interfaceRequest.Content- Returns:
- the content length, if known, or -1 if the content length is unknown
-
subscribe
public Request.Content.Subscription subscribe(Request.Content.Consumer consumer, boolean emitInitialContent)
Description copied from interface:Request.ContentInitializes this content producer with the content consumer, and with the indication of whether initial content, if present, must be emitted upon the initial demand of content (to support delaying the send of the request content in case of
Expect: 100-ContinuewhenemitInitialContentisfalse).- Specified by:
subscribein interfaceRequest.Content- Parameters:
consumer- the content consumer to invoke when there is demand for contentemitInitialContent- whether to emit initial content, if present- Returns:
- the Subscription that links this producer to the consumer
-
demand
public void demand()
Description copied from interface:Request.Content.SubscriptionDemands more content, which eventually results in
Request.Content.Consumer.onContent(ByteBuffer, boolean, Callback)to be invoked.- Specified by:
demandin interfaceRequest.Content.Subscription
-
fail
public void fail(java.lang.Throwable failure)
Description copied from interface:Request.ContentFails this request content, possibly failing and discarding accumulated content that was not demanded.
The failure may be notified to the consumer at a later time, when the consumer demands for content.
Typical failure: the request being aborted by user code, or idle timeouts.
- Specified by:
failin interfaceRequest.Content- Specified by:
failin interfaceRequest.Content.Subscription- Parameters:
failure- the reason of the failure
-
offer
public boolean offer(java.nio.ByteBuffer buffer)
-
offer
public boolean offer(java.nio.ByteBuffer buffer, Callback callback)
-
flush
public void flush() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
isClosed
public boolean isClosed()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-