Class HttpHeaders.Builder

Object
se.curity.identityserver.sdk.http.HttpHeaders.Builder
Enclosing class:
HttpHeaders

public static class HttpHeaders.Builder extends Object
A Builder of HttpHeaders instances.

This builder is mutable and keeps intermediate state so that it can create headers based on the current state when create(String...) is called.

  • Constructor Details

    • Builder

      public Builder()
      Creates an empty builder.
      See Also:
    • Builder

      public Builder(HttpHeaders.Builder otherBuilder)
      Creates a builder that makes a copy of the state of the other builder.
      Parameters:
      otherBuilder - to copy
    • Builder

      public Builder(HttpHeaders headers)
      Creates a builder that uses the header contents of the given HttpHeaders instance.
      Parameters:
      headers - to copy into this builder
  • Method Details

    • header

      public HttpHeaders.Builder header(String name, String value)
      Add a header with the given name and value.

      Notice that if the value contains ',' (comma) or ';' (semicolon), it may be split apart into different values if the header is known to accept comma-separated or semicolon-separated values.

      See also RFC-7230 and RFC-6265.

      Parameters:
      name - of the header
      value - of the header
      Returns:
      this builder
    • remove

      public HttpHeaders.Builder remove(String name)
      Remove the header with the given name.

      If not present, this method has no effect.

      Parameters:
      name - of header to remove
      Returns:
      this builder
      Since:
      2.1.0
    • header

      public HttpHeaders.Builder header(String name, Collection<String> values)
      Add a header with the given name and values.

      Notice that if any value contains ',' (comma) or ';' (semicolon), it may be split apart into different values if the header is known to accept comma-separated or semicolon-separated values.

      See also RFC-7230 and RFC-6265.

      Parameters:
      name - of the header
      values - for the header
      Returns:
      this builder
    • create

      public HttpHeaders create()
      Create an instance of HttpHeaders using the current state of this builder.
      Returns:
      a new HttpHeaders.
    • create

      public HttpHeaders create(String[] exclude)
      Create an instance of HttpHeaders using the current state of this builder.
      Parameters:
      exclude - name of the headers to exclude from the returned HttpHeaders.
      Returns:
      a new HttpHeaders.
    • get

      public List<String> get(String headerName)
      Get the values of the header with the given name.
      Parameters:
      headerName - header name
      Returns:
      the values of this header, or the empty List if the header was not set
      Since:
      2.1.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      2.2.0