All Superinterfaces:
AutoCloseable

public interface Body extends AutoCloseable
Generic HTTP request / response body. It is responsibility of the caller to close the body instance explicitly (or through GenericResponse instance) to release all associated resources.
  • Field Details

  • Method Details

    • from

      @Nullable static Body from(@Nullable InputStream body, @Nullable String contentType)
      Constructs the generic response body out of InputStream with assumed content type
      Parameters:
      body - response body stream
      contentType - content type
      Returns:
      generic response body instance
    • from

      @Nullable static Body from(@Nullable byte[] body, @Nullable String contentType)
      Constructs the generic response body out of InputStream with assumed content type
      Parameters:
      body - response body stream
      contentType - content type
      Returns:
      generic response body instance
    • contentType

      String contentType()
      Content type of this body
      Returns:
      content type
    • body

      InputStream body()
      Gets the body as InputStream
      Returns:
      body as InputStream
    • bodyAsString

      default String bodyAsString()
      Gets the body as String
      Returns:
      body as String
    • bodyAsBytes

      default byte[] bodyAsBytes()
      Gets the body as
      invalid reference
      byte[]
      Returns:
      body as
      invalid reference
      byte[]
    • close

      void close() throws IOException
      Releases all resources associated with this body stream.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException