Interface HttpBody.Stream

All Superinterfaces:
AutoCloseable, Closeable, HttpBody, Releasable
Enclosing interface:
HttpBody

public static non-sealed interface HttpBody.Stream extends HttpBody
Stream is a lazy-loaded content. Stream supports only single handler, this handler must be set before requesting next chunk.
  • Method Details

    • handler

      Returns current handler
    • addTracingHandler

      void addTracingHandler(HttpBody.ChunkHandler chunkHandler)
      Adds tracing chunk handler. Tracing handler will be invoked before main handler, and should never release or call for next chunk. It should be used for monitoring and logging purposes.
    • setHandler

      void setHandler(HttpBody.ChunkHandler chunkHandler)
      Sets handler that can handle next chunk
    • next

      void next()
      Request next chunk of data from the network. The size of the chunk depends on following factors. If request is not compressed then chunk size will be up to HttpTransportSettings.SETTING_HTTP_MAX_CHUNK_SIZE. If request is compressed then chunk size will be up to max_chunk_size * compression_ratio. Multiple calls can be deduplicated when next chunk is not yet available. It's recommended to call "next" once for every chunk.
       
           stream.setHandler((chunk, isLast) -> {
               processChunk(chunk);
               if (isLast == false) {
                   stream.next();
               }
           });