# 4.5 Authorization
> 作者:肖鵬-SpiritLing 時間:2018-08-02
> `Authorization` 是用來告知服務器,用戶代理的認證信息(證書值)。通常,想要通過服務器認證的用戶代理會在接受到返回的401狀態碼響應后,把首部字段 `Authorization` 加入請求中。公眾緩存在接受到含有 `Authorization` 首部字段的請求時的操作處理會略有差異。
| 客戶端 | 數據包 | 服務器 |
| --- | --- | --- |
| ==> | GET /index.html | == |
| == | 401 Unauthorized | <== |
| == | WWW-Authenticate: Basic ... | <== |
| ==> | GET /index.html | == |
| ==> | Authorization: Basic dWVub3N1bjpwYXHzd29yZA== | == |
| == | 200 OK | <== |
```http
Authorization: Basic dWVub3N1bjpwYXHzd29yZA==
```
有關HTTP訪問認證及 `Authorization` 首部字段,稍后的章節會有詳細說明。另外,也可以參閱 [RFC2616](https://tools.ietf.org/html/rfc2616)。
> 作者:肖鵬-SpiritLing 時間:2018-08-02
- 首語
- 第一章 HTTP協議及網絡基礎
- 第二章 協議返回狀態碼
- 第三章 HTTP通用首部字段
- 第一節 Cache-Control字段
- 第二節 Connection 字段
- 第三節 Date 字段
- 第四節 Pragma 字段
- 第五節 Trailer 字段
- 第六節 Transfer-Encoding 字段
- 第七節 Upgrade 字段
- 第八節 Via 字段
- 第九節 Warning 字段
- 第四章 HTTP請求首部字段
- 第一節 Accept 字段
- 第二節 Accept-Charset 字段
- 第三節 Accept-Encoding 字段
- 第四節 Accept-Language 字段
- 第五節 Authorization 字段
- 第六節 Expect 字段
- 第七節 From 字段
- 第八節 Host 字段
- 第九節 If-Match 字段
- 第十節 If-Modified-Since 字段
- 第十一節 If-None-Match 字段
- 第十二節 If-Range 字段
- 第十三節 If-Unmodified-Since 字段
- 第十四節 Max-Forwards 字段
- 第十五節 Proxy-Authorization 字段
- 第十六節 Range 字段
- 第十七節 Referer 字段
- 第十八節 TE 字段
- 第十九節 User-Agent 字段
- 第五章 HTTP響應首部字段
- 第一節 Accept-Ranges 字段
- 第二節 Age 字段
- 第三節 ETge 字段
- 第四節 Location 字段
- 第五節 Proxy-Authenticate 字段
- 第六節 Retry-After 字段
- 第七節 Server 字段
- 第八節 Vary 字段
- 第九節 WWW-Authenticate 字段
- 第六章 HTTP實體首部字段
- 第一節 Allow 字段
- 第二節 Content-Encoding字段
- 第三節 Content-Language 字段
- 第四節 Content-Length 字段
- 第五節 Content-Location 字段
- 第六節 Content-MD5 字段
- 第七節 Content-Range 字段
- 第八節 Content-Type 字段
- 第九節 Expires 字段
- 第十節 Last-Modified 字段
- 第七章 Cookie相關和其他的首部字段