Interface Body

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface Body
    extends java.lang.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.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.io.InputStream body()
      Gets the body as InputStream
      default byte[] bodyAsBytes()
      Gets the body as byte
      default java.lang.String bodyAsString()
      Gets the body as String
      void close()
      Releases all resources associated with this body stream.
      java.lang.String contentType()
      Content type of this body
      static Body from​(byte[] body, java.lang.String contentType)
      Constructs the generic response body out of InputStream with assumed content type
      static Body from​(java.io.InputStream body, java.lang.String contentType)
      Constructs the generic response body out of InputStream with assumed content type
    • Method Detail

      • from

        @Nullable
        static Body from​(@Nullable
                         java.io.InputStream body,
                         @Nullable
                         java.lang.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
                         java.lang.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

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

        java.io.InputStream body()
        Gets the body as InputStream
        Returns:
        body as InputStream
      • bodyAsString

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

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

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