Class WebRequest.Builder

java.lang.Object
io.fluxzero.sdk.web.WebRequest.Builder
Enclosing class:
WebRequest

public static class WebRequest.Builder extends Object
Fluent builder for WebRequest. Use WebRequest.builder() to start building.
  • Constructor Details

    • Builder

      protected Builder(io.fluxzero.common.api.Metadata metadata)
    • Builder

      protected Builder(WebRequest request)
  • Method Details

    • headerIfAbsent

      public WebRequest.Builder headerIfAbsent(String key, String value)
      Adds the header value only when the header has no values, and returns this builder.
    • header

      public WebRequest.Builder header(String key, String value)
      Appends a header value and returns this builder.
    • header

      public WebRequest.Builder header(String key, String value, boolean ifAbsent)
      Appends a header value and returns this builder. If ifAbsent is true, existing non-empty values are preserved without appending.
    • headers

      public WebRequest.Builder headers(Map<String, List<String>> headers)
      Replaces values for the supplied header keys with copied lists, retains other headers, and returns this builder.
    • clearHeader

      public WebRequest.Builder clearHeader(String key)
      Removes all values for the header and returns this builder.
    • cookie

      public WebRequest.Builder cookie(HttpCookie cookie)
      Adds a request cookie, first parsing any stored Cookie headers, and returns this builder.
    • cookies

      public List<HttpCookie> cookies()
      Returns the builder's mutable cookie list after moving any stored Cookie header values into parsed cookies.
    • contentType

      public WebRequest.Builder contentType(String contentType)
      Appends a Content-Type header and returns this builder.
    • body

      public WebRequest.Builder body(Object payload)
      Sets the request body through the payload builder method and returns this builder.
    • headers

      public Map<String, List<String>> headers()
      Assembles request headers, adding the configured gzip acceptance and inferred string or byte-array content type when absent. Registered cookies supply the Cookie header.
    • build

      public WebRequest build()
      Builds the request. Throws IllegalStateException when no HTTP method has been configured.