blob: 32b348b50b086ba89c8905088d8fe8f5b96c46a4 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
---
title: Origin
slug: Web/HTTP/Headers/Origin
translation_of: Web/HTTP/Headers/Origin
---
<div>{{HTTPSidebar}}</div>
<p>请求首部字段 <strong><code>Origin</code></strong> 指示了请求来自于哪个站点。该字段仅指示服务器名称,并不包含任何路径信息。该首部用于 {{Glossary("CORS")}} 请求或者 {{HTTPMethod("POST")}} 请求。除了不包含路径信息,该字段与 {{HTTPHeader("Referer")}} 首部字段相似。</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>{{Glossary("Request header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>yes</td>
</tr>
</tbody>
</table>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">Origin: ""
Origin: <scheme> "://" <host> [ ":" <port> ]
</pre>
<p><code>有时候将该字段的值置空是有用的,例如,资源由一个 data URL 指定。</code></p>
<h2 id="声明">声明</h2>
<dl>
<dt><scheme></dt>
<dd>请求所使用的协议,通常是HTTP协议或者它的安全版本HTTPS协议。</dd>
<dt><host></dt>
<dd>服务器的域名或 IP 地址。</dd>
<dt><port> {{optional_inline}}</dt>
<dd>服务器正在监听的TCP 端口号。缺省为服务的默认端口(对于 HTTP 请求而言,默认端口为 80)。</dd>
</dl>
<h2 id="示例">示例</h2>
<pre>Origin: https://developer.mozilla.org</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{RFC("6454", "Origin", "7")}}</td>
<td>The Web Origin Concept</td>
</tr>
<tr>
<td>{{SpecName('Fetch','#origin-header','Origin header')}}</td>
<td>Supplants the <code>Origin</code> header as defined in RFC6454.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
<p>{{Compat("http/headers/origin")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li>{{HTTPHeader("Host")}}</li>
<li>{{HTTPHeader("Referer")}}</li>
<li><a href="/en-US/docs/Web/Security/Same-origin_policy">同源策略</a></li>
</ul>
|