Interface HttpMessageBuilder<Builder extends HttpMessageBuilder,Message extends HttpMessage>

Type Parameters:
Builder - the type of the builder itself.
Message - the type of HttpMessage that the builder creates.
All Known Subinterfaces:
HttpRequestBuilder, HttpResponseBuilder

@Experimental @NoImplement @MinMuleVersion("4.10.0") public interface HttpMessageBuilder<Builder extends HttpMessageBuilder,Message extends HttpMessage>
Base implementation of an HttpMessage builder. Implementations should extend it and indicate their type and the type of the message they build.
Since:
0.12.0
  • Method Details

    • entity

      Builder entity(HttpEntity entity)
      Parameters:
      entity - the HttpEntity that should be used as body for the HttpMessage. Non null.
      Returns:
      this builder
    • headers

      Builder headers(org.mule.runtime.api.util.MultiMap<String,String> headersMap)
      Parameters:
      headersMap - a MultiMap representing the HTTP headers of the HttpMessage desired. Non-null.
      Returns:
      this builder
    • addHeader

      Builder addHeader(String name, String value)
      Includes a new header to be sent in the desired HttpMessage. Since HTTP headers are case insensitive and can have several values, multiple calls to this method using the same header name will accumulate the values and all of them will be sent.
      Parameters:
      name - the name of the HTTP header
      value - the value of the HTTP header
      Returns:
      this builder
    • addHeaders

      Builder addHeaders(String name, Collection<String> values)
      Includes a new header with multiple values to be sent in the desired HttpMessage.
      Parameters:
      name - the name of the HTTP header
      values - the values of the HTTP header
      Returns:
      this builder
    • removeHeader

      Builder removeHeader(String name)
      Removes a header. Since multiple values might be present, all are removed.
      Parameters:
      name - the name of the HTTP header to remove
      Returns:
      this builder
    • getHeaderValue

      Optional<String> getHeaderValue(String name)
      Returns the value of a given HTTP request. If there are several then the first will be return. Use getHeaderValues(String) instead if all values are required.
      Parameters:
      name - the name of the desired HTTP header
      Returns:
      the value of the header or null if there isn't one
    • getHeaderValues

      Collection<String> getHeaderValues(String name)
      Gives access to all current values of a given HTTP header.
      Parameters:
      name - the name of the desired HTTP header
      Returns:
      an immutable Collection of String values for the header
    • getHeaders

      org.mule.runtime.api.util.MultiMap<String,String> getHeaders()
      Returns:
      an immutable version of the current headers in the builder.
    • build

      Message build()
      Discard this builder after calling this method.