blob: 12776e896ff41d254e6377b2a8cfdc74368ffb56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
---
title: Forbidden header name
slug: Glossary/Forbidden_header_name
translation_of: Glossary/Forbidden_header_name
---
<p>A <dfn>forbidden header name</dfn> is the name of any <a href="/en-US/docs/Web/HTTP/Headers">HTTP header</a> that cannot be modified programmatically; specifically, an HTTP <strong>request</strong> header name (in contrast with a {{Glossary("Forbidden response header name")}}).</p>
<p>Modifying such headers is forbidden because the user agent retains full control over them. Names starting with `<code title="">Sec-</code>` are reserved for creating new headers safe from {{glossary("API","APIs")}} using <a href="/en-US/docs/Web/API/Fetch_API">Fetch</a> that grant developers control over headers, such as {{domxref("XMLHttpRequest")}}.</p>
<p>Forbidden header names start with <code>Proxy-</code> or <code>Sec-</code>, or are one of the following names:</p>
<ul class="brief">
<li><code title="">Accept-Charset</code></li>
<li><code title="">Accept-Encoding</code></li>
<li><code title="">Access-Control-Request-Headers</code></li>
<li><code title="">Access-Control-Request-Method</code></li>
<li><code title="">Connection</code></li>
<li><code title="">Content-Length</code></li>
<li><code title="">Cookie</code></li>
<li><code title="">Cookie2</code></li>
<li><code title="">Date</code></li>
<li><code title="">DNT</code></li>
<li><code title="">Expect</code></li>
<li><code title="">Feature-Policy</code></li>
<li><code title="">Host</code></li>
<li><code title="">Keep-Alive</code></li>
<li><code title="http-origin">Origin</code></li>
<li><code title="http-origin">Proxy-</code></li>
<li><code title="http-origin">Sec-</code></li>
<li><code title="">Referer</code></li>
<li><code title="">TE</code></li>
<li><code title="">Trailer</code></li>
<li><code title="">Transfer-Encoding</code></li>
<li><code title="">Upgrade</code></li>
<li><code title="">Via</code></li>
</ul>
<div class="note">
<p><strong>Note</strong>: The <code>User-Agent</code> header is no longer forbidden, <a href="https://fetch.spec.whatwg.org/#terminology-headers">as per spec</a> — see forbidden header name list (this was implemented in Firefox 43) — it can now be set in a Fetch <a href="/en-US/docs/Web/API/Headers">Headers</a> object, or via XHR <a href="/en-US/docs/Web/API/XMLHttpRequest#setRequestHeader%28%29">setRequestHeader()</a>. However, Chrome will silently drop the header from Fetch requests (see <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=571722">Chromium bug 571722</a>).</p>
</div>
<section class="Quick_links" id="Quick_Links">
<ol>
<li><a href="/en-US/docs/Glossary">MDN Web Docs Glossary</a>
<ol>
<li>{{Glossary("Forbidden response header name")}}</li>
</ol>
</li>
</ol>
</section>
|