blob: 5b48e1a727c75a66a5ef8887dd1e2a984157e304 (
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: HEAD
slug: Web/HTTP/Methods/HEAD
tags:
- HTTP
- 参考
- 请求方法
translation_of: Web/HTTP/Methods/HEAD
---
<div>{{HTTPSidebar}}</div>
<p><strong>HTTP <code>HEAD</code> 方法</strong> 请求资源的头部信息, 并且这些头部与 HTTP {{HTTPMethod("GET")}} 方法请求时返回的一致. 该请求方法的一个使用场景是在下载一个大文件前先获取其大小再决定是否要下载, 以此可以节约带宽资源.</p>
<p><code>HEAD</code> 方法的响应不应包含响应正文. 即使包含了正文也必须忽略掉. 虽然描述正文信息的 {{glossary("Entity header", "entity headers")}}, 例如 {{HTTPHeader("Content-Length")}} 可能会包含在响应中, 但它们并不是用来描述 <code>HEAD</code> 响应本身的, 而是用来描述同样情况下的 {{HTTPMethod("GET")}} 请求应该返回的响应.</p>
<p>如果 <code>HEAD</code> 请求的结果显示在上一次 {{HTTPMethod("GET")}} 请求后缓存的资源已经过期了, 即使没有发出{{HTTPMethod("GET")}}请求,缓存也会失效</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">请求是否有正文</th>
<td>否</td>
</tr>
<tr>
<th scope="row">成功的响应是否有正文</th>
<td>否</td>
</tr>
<tr>
<th scope="row">{{Glossary("安全")}}</th>
<td>是</td>
</tr>
<tr>
<th scope="row">{{Glossary("幂等")}}</th>
<td>是</td>
</tr>
<tr>
<th scope="row">{{Glossary("可缓存")}}</th>
<td>是</td>
</tr>
<tr>
<th scope="row"><a href="/en-US/docs/Web/Guide/HTML/Forms">HTML 表单</a> 是否支持</th>
<td>否</td>
</tr>
</tbody>
</table>
<h2 id="语法">语法</h2>
<pre class="syntaxbox notranslate">HEAD /index.html
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">标题</th>
</tr>
<tr>
<td>{{RFC("7231", "HEAD", "4.3.2")}}</td>
<td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</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.methods.HEAD")}}</p>
<h2 id="另见">?另见</h2>
<ul>
<li>{{HTTPMethod("GET")}}</li>
</ul>
|