Class InputStreamRequestContent

  • All Implemented Interfaces:
    Request.Content
    Direct Known Subclasses:
    ProxyServlet.ProxyInputStreamRequestContent

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

      • fail

        public void fail​(java.lang.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.

        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)