Class HttpResponse.Builder

  • Enclosing class:
    HttpResponse

    public static class HttpResponse.Builder
    extends Object
    Provides a HTTP response builder class.
    Since:
    1.0
    • Method Detail

      • status

        public HttpResponse.Builder status​(int status)
        Set the HTTP response status, e.g. 200 for HTTP OK.
        Parameters:
        status - the response status
        Returns:
        the response builder instance
      • header

        public HttpResponse.Builder header​(String name,
                                           String value)
        Set the response header name and value.
        Parameters:
        name - the header name (required)
        value - the header value (required)
        Returns:
        the response builder instance
      • headers

        public HttpResponse.Builder headers​(Map<String,​List<String>> headers)
        Set the function response headers.
        Parameters:
        headers - the function response headers
        Returns:
        the response builder instance
      • body

        public HttpResponse.Builder body​(byte[] body)
        Set the HTTP response body.
        Parameters:
        body - the response body
        Returns:
        the response builder instance.
      • bodyText

        public HttpResponse.Builder bodyText​(String body)
        Set the HTTP response body text (UTF-8) encoded.
        Parameters:
        body - the response body text
        Returns:
        the response builder instance.
      • build

        public HttpResponse build()
        Return a new HTTP response object.
        Returns:
        a new HTTP response object