Interface AvailableByteBody

All Superinterfaces:
ByteBody
All Known Subinterfaces:
CloseableAvailableByteBody
All Known Implementing Classes:
AvailableByteArrayBody, AvailableNettyByteBody

public interface AvailableByteBody extends ByteBody
This is an extension of ByteBody when the entire body is immediately available (without waiting). It has the same semantics as ByteBody, but it adds a few other primary operations for convenience.
Since:
4.5.0
Author:
Jonas Konrad
  • Method Details

    • split

      @NonNull CloseableAvailableByteBody split()
      For immediate buffers, backpressure is not relevant, so the backpressure modes passed to split(SplitBackpressureMode) are ignored. You can use this method always.
      Specified by:
      split in interface ByteBody
      Returns:
      A body with the same content as this one
      See Also:
    • split

      @Deprecated default @NonNull CloseableAvailableByteBody split(@NonNull ByteBody.SplitBackpressureMode backpressureMode)
      Deprecated.
      This method is unnecessary for AvailableByteBody. Use split() directly.
      This method is equivalent to split(), the backpressure parameter is ignored.
      Specified by:
      split in interface ByteBody
      Parameters:
      backpressureMode - ignored
      Returns:
      A body with the same content as this one
    • allowDiscard

      @Deprecated default @NonNull AvailableByteBody allowDiscard()
      Deprecated.
      This method is unnecessary for AvailableByteBody, it does nothing.
      Signal that the upstream may discard any remaining body data. Only if all consumers of the body allow discarding will the body be discarded, otherwise it will still be sent to all consumers. It is an optional operation.

      Discarding may be implemented e.g. by closing the input side of an HTTP/2 stream.

      This method must be called before any primary operation.

      Specified by:
      allowDiscard in interface ByteBody
      Returns:
      This body
    • length

      long length()
      The length in bytes of the body.
      Returns:
      The length
      See Also:
    • expectedLength

      @Deprecated default @NonNull OptionalLong expectedLength()
      Deprecated.
      This method is unnecessary for AvailableByteBody. Use length() directly.
      The length in bytes of the body. Never returns OptionalLong.empty() for AvailableByteBody. Use length() directly instead.
      Specified by:
      expectedLength in interface ByteBody
      Returns:
      The length
    • toByteArray

      byte @NonNull [] toByteArray()
      Get this body as a byte array.

      This is a primary operation. After this operation, no other primary operation or split() may be done.

      Returns:
      The bytes
    • toReadBuffer

      default @NonNull ReadBuffer toReadBuffer()
      Get this body as a ReadBuffer.

      This is a primary operation. After this operation, no other primary operation or split() may be done.

      Returns:
      The bytes
    • toByteBuffer

      default @NonNull ByteBuffer<?> toByteBuffer()
      Get this body as a ByteBuffer. Note that the buffer may be reference counted, and the caller must take care of releasing it.

      This is a primary operation. After this operation, no other primary operation or split() may be done.

      Returns:
      The bytes
    • toInputStream

      default @NonNull InputStream toInputStream()
      Description copied from interface: ByteBody
      Get this body as an InputStream.

      This is a primary operation. After this operation, no other primary operation or ByteBody.split() may be done.

      Specified by:
      toInputStream in interface ByteBody
      Returns:
      The streamed bytes
    • toString

      default @NonNull String toString(@NonNull Charset charset)
      Convert this body to a string with the given charset.

      This is a primary operation. After this operation, no other primary operation or split() may be done.

      Parameters:
      charset - The charset to convert the body
      Returns:
      The body as a string
    • toByteBufferPublisher

      @Deprecated default @NonNull Publisher<ByteBuffer<?>> toByteBufferPublisher()
      Deprecated.
      This method is unnecessary for AvailableByteBody. Use toByteBuffer() directly.
      Get this body as a reactive stream of ByteBuffers. Note that the buffers may be reference counted, and the caller must take care of releasing them.

      This is a primary operation. After this operation, no other primary operation or ByteBody.split() may be done.

      Specified by:
      toByteBufferPublisher in interface ByteBody
      Returns:
      The streamed bytes
    • toByteArrayPublisher

      @Deprecated default @NonNull Publisher<byte[]> toByteArrayPublisher()
      Deprecated.
      This method is unnecessary for AvailableByteBody. Use toByteArray() directly.
      Get this body as a reactive stream of byte arrays.

      This is a primary operation. After this operation, no other primary operation or ByteBody.split() may be done.

      Specified by:
      toByteArrayPublisher in interface ByteBody
      Returns:
      The streamed bytes
    • toReadBufferPublisher

      @Deprecated default @NonNull Publisher<ReadBuffer> toReadBufferPublisher()
      Deprecated.
      This method is unnecessary for AvailableByteBody. Use toReadBuffer() directly.
      Get this body as a reactive stream of ReadBuffers. Note that the caller must take care to release the returned buffers.

      This is a primary operation. After this operation, no other primary operation or ByteBody.split() may be done.

      Specified by:
      toReadBufferPublisher in interface ByteBody
      Returns:
      The streamed bytes