Interface WritableHeaders<B extends WritableHeaders<B>>

Type Parameters:
B - type of the headers (for inheritance)
All Superinterfaces:
Headers, Iterable<Http.HeaderValue>
All Known Subinterfaces:
ClientRequestHeaders, ResponseHeaders, ServerResponseHeaders, WebClientRequestHeaders
All Known Implementing Classes:
WriteableBodyPartHeaders

public interface WritableHeaders<B extends WritableHeaders<B>> extends Headers
HTTP Headers that are mutable.
  • Method Details

    • create

      static WritableHeaders<?> create()
      Create a new instance of writable headers.
      Returns:
      mutable HTTP headers
    • create

      static WritableHeaders<?> create(Headers headers)
      Create a new instance of writable headers from existing headers.
      Parameters:
      headers - headers to add to the new mutable instance
      Returns:
      mutable HTTP headers
    • setIfAbsent

      B setIfAbsent(Http.HeaderValue header)
      Set a value of a header unless it is already present.
      Parameters:
      header - header with value to set
      Returns:
      this instance
    • add

      B add(Http.HeaderValue header)
      Add a header or add a header value if the header is already present.
      Parameters:
      header - header with value
      Returns:
      this instance
    • add

      default B add(Http.HeaderName header, String... value)
      Add a header or add a header value if the header is already present.
      Parameters:
      header - header name
      value - header value(s)
      Returns:
      this instance
    • remove

      B remove(Http.HeaderName name)
      Remove a header.
      Parameters:
      name - name of the header to remove
      Returns:
      this instance
    • remove

      B remove(Http.HeaderName name, Consumer<Http.HeaderValue> removedConsumer)
      Remove a header.
      Parameters:
      name - name of the header to remove
      removedConsumer - consumer to be called with existing header; if the header did not exist, consumer will not be called
      Returns:
      this instance
    • contentType

      default B contentType(MediaType contentType)
      Sets the MIME type of the response body.
      Parameters:
      contentType - Media type of the content.
      Returns:
      this instance
    • contentType

      default B contentType(HttpMediaType contentType)
      Sets the MIME type of the response body.
      Parameters:
      contentType - Media type of the content.
      Returns:
      this instance
    • set

      B set(Http.HeaderValue header)
      Set a header and replace it if it already existed.
      Parameters:
      header - header to set
      Returns:
      this instance
    • set

      default B set(Http.HeaderName name, String... values)
      Set a header and replace it if it already existed. Use set(io.helidon.common.http.Http.HeaderValue) for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.
      Parameters:
      name - header name to set
      values - value(s) of the header
      Returns:
      this instance
    • set

      default B set(Http.HeaderName name, List<String> values)
      Set a header and replace it if it already existed. Use set(io.helidon.common.http.Http.HeaderValue) for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.
      Parameters:
      name - header name to set
      values - value(s) of the header
      Returns:
      this instance
    • contentLength

      default B contentLength(long length)
      Content length of the entity in bytes. If not configured and a non-streaming entity is used, it will be configured based on the entity length. For streaming entities without content length we switch to chunked encoding (HTTP/1).
      Parameters:
      length - length of the entity
      Returns:
      this instance
    • clear

      B clear()
      Clear all current headers.
      Returns:
      this instance