Class Response

    • Constructor Summary

      Constructors 
      Constructor Description
      Response()
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getBody()
      Returns the body of this Response.
      java.lang.String getBodyAsString()
      Attempts to decode the buffer returned by getBody() as a String in a best-effort manner.
      Headers getHeaders()
      Returns a mutable multi-map of headers for this Response.
      int getStatus()
      Returns the status code of this response.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 java.lang.String getBodyAsString()
                                         throws java.nio.charset.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:
        java.nio.charset.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object