Module org.eclipse.jetty.client
Package org.eclipse.jetty.client.util
Class InputStreamRequestContent
- java.lang.Object
-
- org.eclipse.jetty.client.util.AbstractRequestContent
-
- org.eclipse.jetty.client.util.InputStreamRequestContent
-
- All Implemented Interfaces:
Request.Content
public class InputStreamRequestContent extends AbstractRequestContent
A
Request.Contentthat produces content from anInputStream.The input stream is read once and therefore fully consumed.
It is possible to specify, at the constructor, a buffer size used to read content from the stream, by default 1024 bytes.
The
InputStreampassed to the constructor is by default closed when is it fully consumed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.client.util.AbstractRequestContent
AbstractRequestContent.AbstractSubscription, AbstractRequestContent.Producer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request.Content
Request.Content.Consumer, Request.Content.Subscription
-
-
Constructor Summary
Constructors Constructor Description InputStreamRequestContent(java.io.InputStream stream)InputStreamRequestContent(java.io.InputStream stream, int bufferSize)InputStreamRequestContent(java.lang.String contentType, java.io.InputStream stream)InputStreamRequestContent(java.lang.String contentType, java.io.InputStream stream, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfail(java.lang.Throwable failure)Fails this request content, possibly failing and discarding accumulated content that was not demanded.protected Request.Content.SubscriptionnewSubscription(Request.Content.Consumer consumer, boolean emitInitialContent)protected java.nio.ByteBufferonRead(byte[] buffer, int offset, int length)protected voidonReadFailure(java.lang.Throwable failure)-
Methods inherited from class org.eclipse.jetty.client.util.AbstractRequestContent
getContentType, subscribe
-
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.Request.Content
getLength, isReproducible
-
-
-
-
Constructor Detail
-
InputStreamRequestContent
public InputStreamRequestContent(java.io.InputStream stream)
-
InputStreamRequestContent
public InputStreamRequestContent(java.lang.String contentType, java.io.InputStream stream)
-
InputStreamRequestContent
public InputStreamRequestContent(java.io.InputStream stream, int bufferSize)
-
InputStreamRequestContent
public InputStreamRequestContent(java.lang.String contentType, java.io.InputStream stream, int bufferSize)
-
-
Method Detail
-
newSubscription
protected Request.Content.Subscription newSubscription(Request.Content.Consumer consumer, boolean emitInitialContent)
- Specified by:
newSubscriptionin classAbstractRequestContent
-
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.
- Parameters:
failure- the reason of the failure
-
onRead
protected java.nio.ByteBuffer onRead(byte[] buffer, int offset, int length)
-
onReadFailure
protected void onReadFailure(java.lang.Throwable failure)
-
-