Class Response


  • public final class Response
    extends Object
    A response to an HTTP request, typically originating from a Request.
    • Constructor Detail

      • Response

        public Response​(int statusCode,
                        Map<String,​String> headers,
                        InputStream body)
        Constructs a response from a status code, headers, and bodu.
        Parameters:
        statusCode - the status code of the response.
        headers - the headers of the response.
        body - the body of the response.
      • Response

        public Response​(int statusCode,
                        InputStream body)
        Constructs a response from a status code and body.
        Parameters:
        statusCode - the status code of the response.
        body - the body of the response.
      • Response

        public Response​(int statusCode,
                        byte[] body)
        Constructs a response from a status code and raw body bytes.
        Parameters:
        statusCode - the status code of the response.
        body - the body of the response as raw bytes.
      • Response

        public Response​(int statusCode,
                        Map<String,​String> headers,
                        String body)
        Constructs a response from a status, headers, and a body represented by a String.
        Parameters:
        statusCode - the status code of the response.
        headers - the headers of the response.
        body - the body of the response as a string.
      • Response

        public Response​(int statusCode,
                        String body)
        Constructs a response from a status and a body represented by a String.
        Parameters:
        statusCode - the status code of the response.
        body - the body of the response as a string.
      • Response

        public Response​(int statusCode,
                        Map<String,​String> headers)
        Constructs a response from a status and headers.
        Parameters:
        statusCode - the status code of the response.
        headers - the headers of the response.
      • Response

        public Response​(byte[] body)
        Constructs a successful (200 OK) response from raw body bytes.
        Parameters:
        body - the body of the response as raw bytes.
      • Response

        public Response​(String body)
        Constructs a successful (200 OK) response from a body represented by a String.
        Parameters:
        body - the body of the response as a string.
      • Response

        public Response​(int statusCode)
        Constructs a response from the given status code.
        Parameters:
        statusCode - the status code of the response.
    • Method Detail

      • getStatusCode

        public int getStatusCode()
        Returns the status code of the response.
        Returns:
        the status code of the response.
      • getHeaders

        public Map<String,​String> getHeaders()
        Returns the headers of the response.
        Returns:
        the headers of the response.
      • getBody

        @Nullable
        public InputStream getBody()
        Returns the body of the response; may be null.
        Returns:
        the body of the response; may be null.