Package org.takes.rs

Class RsWithBody

  • All Implemented Interfaces:
    Body, Head, Response

    public final class RsWithBody
    extends RsWrap
    Response decorator, with body.

    This implementation of the Response interface requires that the Head.head() method has to be invoked before reading from the InputStream obtained from the Body.body() method.

    The class is immutable and thread-safe.

    Since:
    0.1
    • Constructor Detail

      • RsWithBody

        public RsWithBody​(CharSequence body)
        Constructs a RsWithBody with the specified body that will be encoded into UTF-8 by default.
        Parameters:
        body - Body
      • RsWithBody

        public RsWithBody​(byte[] body)
        Constructs a RsWithBody with the specified body.
        Parameters:
        body - Body
      • RsWithBody

        public RsWithBody​(InputStream body)
        Constructs a RsWithBody with the specified body.
        Parameters:
        body - Body
      • RsWithBody

        public RsWithBody​(URL url)
        Constructs a RsWithBody with the content located at the specified url as body.
        Parameters:
        url - URL with body
      • RsWithBody

        public RsWithBody​(Response res,
                          CharSequence body)
        Constructs a RsWithBody with the specified response and body. The body will be encoded into UTF-8 by default.
        Parameters:
        res - Original response
        body - Body
      • RsWithBody

        public RsWithBody​(Response res,
                          CharSequence body,
                          Charset charset)
        Constructs a RsWithBody with the specified response and body. The body will be encoded using the specified character set.
        Parameters:
        res - Original response
        body - Body
        charset - The character set to use to serialize the body
      • RsWithBody

        public RsWithBody​(Response res,
                          URL url)
        Ctor.
        Parameters:
        res - Original response
        url - URL with body
      • RsWithBody

        public RsWithBody​(Response res,
                          byte[] body)
        Ctor.
        Parameters:
        res - Original response
        body - Body
      • RsWithBody

        public RsWithBody​(Response res,
                          InputStream body)
        Ctor.
        Parameters:
        res - Original response
        body - Body