Class MkAnswer.Simple

java.lang.Object
com.jcabi.http.mock.MkAnswer.Simple
All Implemented Interfaces:
MkAnswer
Enclosing interface:
MkAnswer

@Immutable @Loggable(1) public static final class MkAnswer.Simple extends Object implements MkAnswer
Simple implementation.
Since:
1.0
  • Constructor Details

    • Simple

      public Simple(String body)
      Public ctor.
      Parameters:
      body - Body of HTTP response
    • Simple

      public Simple(int status)
      Public ctor (with empty HTTP body).
      Parameters:
      status - HTTP status
      Since:
      1.9
    • Simple

      public Simple(int status, String body)
      Public ctor.
      Parameters:
      status - HTTP status
      body - Body of HTTP response
    • Simple

      public Simple(int status, Iterable<Map.Entry<String,String>> headers, byte[] body)
      Public ctor.
      Parameters:
      status - HTTP status
      headers - HTTP headers
      body - Body of HTTP response
  • Method Details

    • status

      public int status()
      Description copied from interface: MkAnswer
      HTTP response status.
      Specified by:
      status in interface MkAnswer
      Returns:
      The status code
    • headers

      public Map<String,List<String>> headers()
      Description copied from interface: MkAnswer
      HTTP response headers.
      Specified by:
      headers in interface MkAnswer
      Returns:
      The headers
    • body

      public String body()
      Description copied from interface: MkAnswer
      HTTP response body.
      Specified by:
      body in interface MkAnswer
      Returns:
      The body, as a UTF-8 string
    • bodyBytes

      public byte[] bodyBytes()
      Description copied from interface: MkAnswer
      HTTP response body as bytes.
      Specified by:
      bodyBytes in interface MkAnswer
      Returns:
      The body, as byte array
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withHeader

      public MkAnswer.Simple withHeader(String name, String value)
      Make a copy of this answer, with an extra header.
      Parameters:
      name - Name of the header
      value - ImmutableHeader value
      Returns:
      New answer
    • withStatus

      public MkAnswer.Simple withStatus(int status)
      Make a copy of this answer, with another status code.
      Parameters:
      status - Status code
      Returns:
      New answer
    • withBody

      public MkAnswer.Simple withBody(String body)
      Make a copy of this answer, with another body.
      Parameters:
      body - Body
      Returns:
      New answer
    • withBody

      public MkAnswer.Simple withBody(byte[] body)
      Make a copy of this answer, with another body.
      Parameters:
      body - Body
      Returns:
      New answer