Class RepeatableInputStreamRequestEntity

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.HttpEntity

    public class RepeatableInputStreamRequestEntity
    extends org.apache.hc.core5.http.io.entity.HttpEntityWrapper
    Custom implementation of HttpEntity that delegates to an InputStreamEntity, with the one notable difference, that if the underlying InputStream supports being reset, this RequestEntity will report that it is repeatable and will reset the stream on all subsequent attempts to write out the request.
    • Constructor Detail

      • RepeatableInputStreamRequestEntity

        public RepeatableInputStreamRequestEntity​(HttpExecuteRequest request)
    • Method Detail

      • isChunked

        public boolean isChunked()
        Specified by:
        isChunked in interface org.apache.hc.core5.http.EntityDetails
        Overrides:
        isChunked in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      • isRepeatable

        public boolean isRepeatable()
        Returns true if the underlying InputStream supports marking/resetting or if the underlying InputStreamRequestEntity is repeatable.
        Specified by:
        isRepeatable in interface org.apache.hc.core5.http.HttpEntity
        Overrides:
        isRepeatable in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      • writeTo

        public void writeTo​(OutputStream output)
                     throws IOException
        Resets the underlying InputStream if this isn't the first attempt to write out the request, otherwise simply delegates to InputStreamRequestEntity to write out the data.

        If an error is encountered the first time we try to write the request entity, we remember the original exception, and report that as the root cause if we continue to encounter errors, rather than masking the original error.

        Specified by:
        writeTo in interface org.apache.hc.core5.http.HttpEntity
        Overrides:
        writeTo in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
        Throws:
        IOException