class Headers extends Object with Iterable[Array[ByteString]]
¶6.1 Headers Class of whatwg spec
The Headers interface of the Fetch API allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
For security reasons, some headers can only be controller by the user agent. These headers include the forbidden header names and forbidden response header names.
A Headers object also has an associated guard, which takes a value of immutable, request, request-no-cors, response, or none. This affects whether the set(), delete(), and append() methods will mutate the header. For more information see Guard.
You can retrieve a Headers object via the Request.headers and Response.headers properties, and create a new Headers object using the Headers.Headers() constructor.
- Annotations
- @JSType() @native() @JSGlobal()
- Alphabetic
- By Inheritance
- Headers
- Iterable
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Headers(map: HeadersInit = js.Array[js.Array[String]]())
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def append(name: ByteString, value: ByteString): Unit
The append() method of the Headers interface appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.
The append() method of the Headers interface appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.
The difference between Headers.set and append() is that if the specified header already exists and accepts multiple values, Headers.set will overwrite the existing value with the new one, whereas append() will append the new value onto the end of the set of values.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def delete(name: ByteString): Unit
The delete() method of the Headers interface deletes a header from the current Headers object.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def get(name: ByteString): ByteString
The get() method of the Headers interface returns the first value of a given header from within a Headers object .
The get() method of the Headers interface returns the first value of a given header from within a Headers object . If the requested header doesn't exist in the Headers object, the call returns null.
- name
a ByteString, ie. only ASCII chars
- def getAll(name: ByteString): Sequence[ByteString]
The getAll() method of the Headers interface returns an array of all the values of a header within a Headers object with a given name.
The getAll() method of the Headers interface returns an array of all the values of a header within a Headers object with a given name. If the requested header doesn't exist in the Headers object, it returns an empty array.
- name
a ByteString, ie. only ASCII chars
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def has(name: ByteString): Boolean
The has() method of the Headers interface returns a boolean stating whether a Headers object contains a certain header.
The has() method of the Headers interface returns a boolean stating whether a Headers object contains a certain header.
- name
a ByteString, ie. only ASCII chars
- def hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
- def jsIterator(): Iterator[Array[ByteString]]
- Definition Classes
- Headers → Iterable
- Annotations
- @JSName(js.Symbol.iterator)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
- def set(name: ByteString, value: ByteString): Unit
The set() method of the Headers interface sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
The set() method of the Headers interface sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
The difference between set() and Headers.append is that if the specified header already exists and accepts multiple values, set() overwrites the existing value with the new one, whereas Headers.append appends the new value to the end of the set of values.
Not all headers can be set. See the list of forbidden header names in https://fetch.spec.whatwg.org/#terminology-headers
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toLocaleString(): String
- Definition Classes
- Object
- def toString(): String
- Definition Classes
- AnyRef → Any
- def valueOf(): Any
- Definition Classes
- Object
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()