Interface Headers

All Superinterfaces:
org.teavm.jso.JSObject

public interface Headers extends org.teavm.jso.JSObject
HTTP headers. Names are compared case-insensitively, so Content-Type and content-type are the same header.
Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(String name, String value)
    Adds one header without replacing existing values.
    void
    delete(String name)
    Removes a header.
    get(String name)
    Reads one header.
    default String
    get(String name, String fallback)
    Reads a header, falling back when absent.
    org.teavm.jso.core.JSArrayReader<org.teavm.jso.core.JSString>
    Returns every Set-Cookie separately, which get(String) cannot express.
    boolean
    has(String name)
    Reports whether a header is present.
    void
    set(String name, String value)
    Sets one header, replacing any existing value.
    default List<String>
    Returns every Set-Cookie, as a Java list.

    Methods inherited from interface org.teavm.jso.JSObject

    cast
  • Method Details

    • get

      String get(String name)
      Reads one header.

      A header sent more than once reads back as its values joined with ", ", which is what the Fetch specification requires. getSetCookie() is the exception, because joining cookies that way corrupts them.

      Parameters:
      name - the header name
      Returns:
      the value, or null when absent
    • set

      void set(String name, String value)
      Sets one header, replacing any existing value.
      Parameters:
      name - the header name
      value - the value
    • append

      void append(String name, String value)
      Adds one header without replacing existing values.
      Parameters:
      name - the header name
      value - the value
    • delete

      void delete(String name)
      Removes a header.
      Parameters:
      name - the header name
    • has

      boolean has(String name)
      Reports whether a header is present.
      Parameters:
      name - the header name
      Returns:
      whether it is present
    • getSetCookie

      org.teavm.jso.core.JSArrayReader<org.teavm.jso.core.JSString> getSetCookie()
      Returns every Set-Cookie separately, which get(String) cannot express.
      Returns:
      every Set-Cookie separately, which get(String) cannot express
    • get

      default String get(String name, String fallback)
      Reads a header, falling back when absent.
      Parameters:
      name - the header name
      fallback - the value to use when absent
      Returns:
      the value, or the fallback
    • setCookies

      default List<String> setCookies()
      Returns every Set-Cookie, as a Java list.
      Returns:
      every Set-Cookie, as a Java list