Class Response

    • Constructor Detail

      • 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 Detail

      • 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