Class HttpResponse.Builder

java.lang.Object
com.luciad.net.http.HttpResponse.Builder
All Implemented Interfaces:
AutoCloseable
Enclosing class:
HttpResponse

public static final class HttpResponse.Builder extends Object implements AutoCloseable
Builder for the HttpResponse class.

Instances of HttpRequest.Builder are created by calling HttpResponse#newBuilder.

Since:
2023.0
  • Constructor Details Link icon

  • Method Details Link icon

    • finalize Link icon

      protected void finalize()
      Overrides:
      finalize in class Object
    • close Link icon

      public void close()
      Specified by:
      close in interface AutoCloseable
    • build Link icon

      @NotNull public HttpResponse build() throws IllegalStateException
      Returns an HttpResponse based on the properties set on this builder.
      Returns:
      an HttpResponse.
      Throws:
      IllegalStateException - if the status code for this response has not been set.
    • statusCode Link icon

      @NotNull public HttpResponse.Builder statusCode(int statusCode)
      Sets the status code of the HTTP response.

      This parameter is mandatory. If it is not set, HttpResponse.Builder#build will throw an exception.

      Parameters:
      statusCode - the status code for this response.
      Returns:
      this builder.
    • body Link icon

      @NotNull public HttpResponse.Builder body(@NotNull DataEntity body)
      Sets the HTTP response content.

      This parameter is optional.

      Parameters:
      body - the response content.
      Returns:
      this builder.
    • header Link icon

      @NotNull public HttpResponse.Builder header(@NotNull String name, @NotNull String value)
      Sets the given name value pair to the set of headers for this response.
      Parameters:
      name - header name
      value - header value
      Returns:
      this builder.
    • header Link icon

      @NotNull public HttpResponse.Builder header(@NotNull HttpHeader header)
      Sets the given http header to the set of headers for this response.
      Parameters:
      header - an HttpHeader.
      Returns:
      this builder.