Class InputStreamRequestContent

All Implemented Interfaces:
Direct Known Subclasses:

public class InputStreamRequestContent extends AbstractRequestContent

A Request.Content that produces content from an InputStream.

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 InputStream passed to the constructor is by default closed when is it fully consumed.

  • Constructor Details

    • InputStreamRequestContent

      public InputStreamRequestContent(InputStream stream)
    • InputStreamRequestContent

      public InputStreamRequestContent(String contentType, InputStream stream)
    • InputStreamRequestContent

      public InputStreamRequestContent(InputStream stream, int bufferSize)
    • InputStreamRequestContent

      public InputStreamRequestContent(String contentType, InputStream stream, int bufferSize)
  • Method Details

    • newSubscription

      protected Request.Content.Subscription newSubscription(Request.Content.Consumer consumer, boolean emitInitialContent)
      Specified by:
      newSubscription in class AbstractRequestContent
    • fail

      public void fail(Throwable failure)
      Description copied from interface: Request.Content

      Fails 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.

      failure - the reason of the failure
    • onRead

      protected ByteBuffer onRead(byte[] buffer, int offset, int length)
    • onReadFailure

      protected void onReadFailure(Throwable failure)