Interface Body

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
RandomAccessBody
All Known Implementing Classes:
ByteArrayBodyGenerator.ByteBody, FileBodyGenerator.FileBody, InputStreamBodyGenerator.ISBody, MultipartBody

public interface Body extends Closeable
A request body.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets the length of the body.
    long
    read(ByteBuffer buffer)
    Reads the next chunk of bytes from the body.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • getContentLength

      long getContentLength()
      Gets the length of the body.
      Returns:
      The length of the body in bytes, or negative if unknown.
    • read

      long read(ByteBuffer buffer) throws IOException
      Reads the next chunk of bytes from the body.
      Parameters:
      buffer - The buffer to store the chunk in, must not be null.
      Returns:
      The non-negative number of bytes actually read or -1 if the body has been read completely.
      Throws:
      IOException - If the chunk could not be read.