Class InputStreamFixedLenProducer

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.AsyncEntityProducer, org.apache.hc.core5.http.nio.ResourceHolder

    public final class InputStreamFixedLenProducer
    extends Object
    implements org.apache.hc.core5.http.nio.AsyncEntityProducer, Closeable
    Minimal-copy streaming producer for a single-shot PUT/POST with a known Content-Length. Memory footprint is a single reusable byte[] buffer; data is never duplicated once inside user-space.
    • Constructor Detail

      • InputStreamFixedLenProducer

        public InputStreamFixedLenProducer​(InputStream source,
                                           long contentLength,
                                           int bufferSize)
        Parameters:
        source - Input stream to upload. Caller still owns the stream until this producer is closed or an error occurs.
        contentLength - Total number of bytes that will be read from source.
        bufferSize - Size of the reusable transfer buffer.
      • InputStreamFixedLenProducer

        public InputStreamFixedLenProducer​(InputStream source,
                                           long contentLength)
    • Method Detail

      • isRepeatable

        public boolean isRepeatable()
        Specified by:
        isRepeatable in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
      • isChunked

        public boolean isChunked()
        Specified by:
        isChunked in interface org.apache.hc.core5.http.EntityDetails
      • getContentLength

        public long getContentLength()
        Specified by:
        getContentLength in interface org.apache.hc.core5.http.EntityDetails
      • getContentType

        public String getContentType()
        Specified by:
        getContentType in interface org.apache.hc.core5.http.EntityDetails
      • getContentEncoding

        public String getContentEncoding()
        Specified by:
        getContentEncoding in interface org.apache.hc.core5.http.EntityDetails
      • getTrailerNames

        public Set<String> getTrailerNames()
        Specified by:
        getTrailerNames in interface org.apache.hc.core5.http.EntityDetails
      • available

        public int available()
        Specified by:
        available in interface org.apache.hc.core5.http.nio.AsyncDataProducer
      • produce

        public void produce​(org.apache.hc.core5.http.nio.DataStreamChannel channel)
                     throws IOException
        Called by the reactor whenever the socket can accept more bytes. Handles partial writes by retaining an outbound ByteBuffer.
        Specified by:
        produce in interface org.apache.hc.core5.http.nio.AsyncDataProducer
        Throws:
        IOException
      • failed

        public void failed​(Exception cause)
        Specified by:
        failed in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
      • releaseResources

        public void releaseResources()
        Specified by:
        releaseResources in interface org.apache.hc.core5.http.nio.ResourceHolder