java.lang.Object
ch.tocco.nice2.optional.cms.impl.publish.output.freemarker.header.Headers
All Implemented Interfaces:
Iterable<Header>

public class Headers extends Object implements Iterable<Header>
Represents a collection of HTTP header entries. This object is added to the page model and available in the templates during the render process. It can be used to add headers to the server response from a template.
  • Constructor Details

    • Headers

      public Headers()
  • Method Details

    • set

      public String set(String name, String value)
      Set a header.
      Parameters:
      name - The name of the header.
      Returns:
      an empty string. If we returned nothing or null, we would have to handle it in the template.
    • get

      @Nullable public @Nullable String get(String name)
      Get a header value.
      Parameters:
      name - The name of the header.
      Returns:
      the value of the header or null.
    • has

      public boolean has(String name)
      Determine if a header is set.
      Parameters:
      name - The name of the header.
      Returns:
      true, if the header exists, else false.
    • noCache

      public String noCache()
      Set the "Cache-Control" header to "no-cache".
      Returns:
      an empty string. If we returned nothing or null, we would have to handle it in the template.
    • iterator

      public Iterator<Header> iterator()
      Specified by:
      iterator in interface Iterable<Header>