Interface WritableHeaders<B extends WritableHeaders<B>>

Type Parameters:
B - type of the headers (for inheritance)
All Superinterfaces:
Headers, Iterable<Header>
All Known Subinterfaces:
ClientRequestHeaders, ServerResponseHeaders, ServerResponseTrailers

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(Header 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(Header 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(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
    • add

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

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

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

      B remove(HeaderName name, Consumer<Header> 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, HttpMediaType may be used to add parameters
      Returns:
      this instance
    • set

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

      default B set(HeaderName name, String... values)
      Set a header and replace it if it already existed. Use set(Header) 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(HeaderName name, int value)
      Set a header and replace it if it already existed. Use set(Header) 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
      value - integer value of the header
      Returns:
      this instance
    • set

      default B set(HeaderName name, long value)
      Set a header and replace it if it already existed. Use set(Header) 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
      value - long value of the header
      Returns:
      this instance
    • set

      default B set(HeaderName name, Collection<String> values)
      Set a header and replace it if it already existed. Use set(Header) 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
    • from

      B from(Headers headers)
      For each header from the provided headers, set its value on these headers. If a header exists on these headers and on the provided headers, it would be replaced with the value(s) from provided headers.
      Parameters:
      headers - to read headers from and set them on this instance
      Returns:
      this instance