Class Response

java.lang.Object
com.yahoo.application.container.handler.Response

public class Response extends Object
A response for use with JDisc.handleRequest(Request).
Author:
Einar M R Rosenvinge
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a Response with an empty body, and 200 (OK) response code.
    Response(byte[] body)
    Creates a Response with a message body, and 200 (OK) response code.
    Response(int status, byte[] body)
    Creates a Response with a message body, and the given response code.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the body of this Response.
    Attempts to decode the buffer returned by getBody() as a String in a best-effort manner.
    Returns a mutable multi-map of headers for this Response.
    int
    Returns the status code of this response.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Response

      public Response()
      Creates a Response with an empty body, and 200 (OK) response code.
    • Response

      public Response(byte[] body)
      Creates a Response with a message body, and 200 (OK) response code.
      Parameters:
      body - the body of the response
    • Response

      public Response(int status, byte[] body)
      Creates a Response with a message body, and the given response code.
      Parameters:
      status - the status code of the response
      body - the body of the response
      Since:
      5.1.28
  • Method Details

    • getStatus

      public int getStatus()

      Returns the status code of this response. This is an integer result code of the attempt to understand and satisfy the corresponding Request.

      Returns:
      The status code.
      Since:
      5.1.28
    • getBody

      public byte[] getBody()
      Returns the body of this Response.
      Returns:
      the body of this Response
    • getBodyAsString

      public String getBodyAsString() throws CharacterCodingException
      Attempts to decode the buffer returned by getBody() as a String in a best-effort manner. This is done using the Content-Type header - and defaults to UTF-8 encoding if the header is unparseable or not found. Note that this may very well throw a CharacterCodingException.
      Returns:
      a String with the decoded contents of the body buffer
      Throws:
      CharacterCodingException - if the body buffer was not well-formed
    • getHeaders

      public Headers getHeaders()
      Returns a mutable multi-map of headers for this Response.
      Returns:
      a mutable multi-map of headers for this Response
    • toString

      public String toString()
      Overrides:
      toString in class Object