Class StreamedHttpContent


  • public class StreamedHttpContent
    extends HttpContent
    Represents a streamed http content which is not fully loaded into memory.
    It requires special handling in the executor to support this type of content.
    It is fully backwards compatible if the executor does not support this feature by reading the entire stream into memory.
    All built-in executors support this type of content.
    • Constructor Detail

      • StreamedHttpContent

        public StreamedHttpContent​(ContentType contentType,
                                   java.io.InputStream inputStream,
                                   int contentLength)
    • Method Detail

      • wrap

        public static StreamedHttpContent wrap​(HttpContent other)
                                        throws java.io.IOException
        Wrap the given http content into a streamed content.
        This will read the entire content into memory.
        Parameters:
        other - The content to wrap
        Returns:
        The wrapped content
        Throws:
        java.io.IOException - If an error occurs reading the content
        See Also:
        HttpRequestUtils.readFromStream(InputStream)
      • getInputStream

        public java.io.InputStream getInputStream()
        Returns:
        The input stream
      • getBufferSize

        public int getBufferSize()
        Returns:
        The buffer size for reading the stream
      • setBufferSize

        public StreamedHttpContent setBufferSize​(int bufferSize)
        Set the buffer size for reading the stream.
        This option may be ignored depending on the executor implementation.
        Parameters:
        bufferSize - The buffer size
        Returns:
        This instance for chaining
      • compute

        @Nonnull
        protected byte[] compute()
                          throws java.io.IOException
        Specified by:
        compute in class HttpContent
        Returns:
        The content
        Throws:
        java.io.IOException - If an I/O error occurs