Obsolete since Gecko 52 (Firefox 52 / Thunderbird 52 / SeaMonkey 2.49)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
getAll()
方法在
头
interface used to return an array of all the values of a header within a
头
object with a given name; in newer versions of the Fetch spec, it has been deleted, and
Headers.get()
has been updated to fetch
all
header values instead of only the first one.
If the requested header doesn't exist
在
头
object, it returns an empty array.
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 .
myHeaders.getAll(name);
头
对象。
If the given name is not the name of an HTTP header
, this method throws a
TypeError
.
数组
包含
ByteString
sequence representing the values of the retrieved header.
Creating an empty
头
object is simple:
var myHeaders = new Headers(); // Currently empty
You could add a header to this using
Headers.append
, then retrieve it using
getAll()
:
myHeaders.append('Content-Type', 'image/jpeg');
myHeaders.getAll('Content-Type'); // Returns [ "image/jpeg" ]
If the header has multiple values associated with it, the array will contain all the values, in the order they were added to the Headers object:
myHeaders.append('Accept-Encoding', 'deflate');
myHeaders.append('Accept-Encoding', 'gzip');
myHeaders.getAll('Accept-Encoding'); // Returns [ "deflate", "gzip" ]
注意
: Use
Headers.get
to return only the first value added to the
头
对象。
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAll
弃用
非标
|
Chrome 42 — 60 | Edge ≤18 — 79 |
Firefox
39 — 52
|
IE No | Opera 29 — 47 | Safari No | WebView Android 42 — 60 | Chrome Android 42 — 60 | Firefox Android No | Opera Android 29 — 44 | Safari iOS No | Samsung Internet Android 4.0 |
完整支持
不支持
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
用户必须明确启用此特征。