400 lines
12 KiB
Markdown
400 lines
12 KiB
Markdown
<!-- GFM-TOC -->
|
||
* [????????](#????????)
|
||
* [Web????](#web????)
|
||
* [URL](#url)
|
||
* [????????????](#????????????)
|
||
* [HTTP ????](#http-????)
|
||
* [GET????????](#get????????)
|
||
* [POST?????????????](#post?????????????)
|
||
* [HEAD????????????](#head????????????)
|
||
* [PUT????????](#put???θ????)
|
||
* [DELETE????????](#delete????????)
|
||
* [OPTIONS????????????](#options????????????)
|
||
* [RACE?????·??](#race?????·??)
|
||
* [CONNECT??????????Э?????????](#connect??????????э?????????)
|
||
* [HTTP ????](#http-????)
|
||
* [2XX ???](#2xx-???)
|
||
* [3XX ?????](#3xx-?????)
|
||
* [4XX ????????](#4xx-????????)
|
||
* [5XX ??????????](#5xx-??????????)
|
||
* [HTTP???](#http???)
|
||
* [?????????](#?????????)
|
||
* [??????????](#??????????)
|
||
* [?????????](#?????????)
|
||
* [?????????](#?????????)
|
||
* [???????](#???????)
|
||
* [Cookie](#cookie)
|
||
* [????](#????)
|
||
* [???????](#???????)
|
||
* [????](#????)
|
||
* [??鴫??](#??鴫??)
|
||
* [????????](#????????)
|
||
* [??Χ????](#??χ????)
|
||
* [????Э??](#????э??)
|
||
* [????????](#????????)
|
||
* [??????????](#??????????)
|
||
* [HTTPs](#https)
|
||
* [????](#????)
|
||
* [???](#???)
|
||
* [??????](#??????)
|
||
<!-- GFM-TOC -->
|
||
|
||
# ????????
|
||
|
||
## Web????
|
||
|
||
HTTP??HyperText Transfer Protocol???????????Э?飩??
|
||
|
||
WWW??Word Wide Web?????????????HTML??HTTP??URL??
|
||
|
||
RFC??Request for Comments??????????????飩??????????????????
|
||
|
||
## URL
|
||
|
||
URI??Uniform Resource Indentifier????????????????URL??Uniform Resource Locator?????????λ??????URN??Uniform Resource Name?????????????????? urn:isbn:0-486-27557-4 ??URI ???? URL ?? URN???? WEB ??? URL ??????У????????????????? URL??
|
||
|
||
URL?????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/4102b7d0-39b9-48d8-82ae-ac4addb7ebfb.jpg)
|
||
|
||
## ????????????
|
||
|
||
**??????**
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/9dbb5fc2-936b-4c6d-b3a7-9617aae45080.jpg)
|
||
|
||
**???????**
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/c634b5ed-a14b-4302-b40e-3ee387dd3c8a.jpg)
|
||
|
||
# HTTP ????
|
||
|
||
?????????????????????????У????????????Ρ?
|
||
|
||
## GET????????
|
||
|
||
## POST?????????????
|
||
|
||
POST ???????????????????????????????????
|
||
|
||
GET ?? POST ???????????????????????? GET ?????????????????????? URL?У??? POST ??????洢????????岿???
|
||
|
||
```
|
||
GET /test/demo_form.asp?name1=value1&name2=value2 HTTP/1.1
|
||
```
|
||
```
|
||
POST /test/demo_form.asp HTTP/1.1
|
||
Host: w3schools.com
|
||
name1=value1&name2=value2
|
||
```
|
||
|
||
GET ????η??????? POST ?????????? GET ????????? URL ????????????й????????????? GET ???? ASCII ???????????????????????????????? POST ????????????
|
||
|
||
## HEAD????????????
|
||
|
||
?? GET ???????????????????????????岿???
|
||
|
||
?????????? URL ????Ч??????????????????????
|
||
|
||
## PUT????????
|
||
|
||
???????????????????κ????????????????????????????????? WEB ????????÷?????
|
||
|
||
## DELETE????????
|
||
|
||
?? PUT ???????????????????????????
|
||
|
||
## OPTIONS????????????
|
||
|
||
???????? URL ????????????
|
||
|
||
???? Allow: GET, POST, HEAD, OPTIONS ???????????
|
||
|
||
## RACE?????·??
|
||
|
||
???????????·?????????????
|
||
|
||
????????????? Max-Forwards ??????????????????????????????????? 1???????? 0 ?????????
|
||
|
||
TRACE ?????????????????????? XST ??????Cross-Site Tracing???????????????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/ca711108-e937-4d7d-99aa-61b325c61f1a.jpg)
|
||
|
||
## CONNECT??????????Э?????????
|
||
|
||
?????Э????? TCP ????
|
||
|
||
?????? SSL??Secure Sokets Layer????????????? TLS??Transport Layer Security??????????Э?????????????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/d8355d56-aa2b-4452-8001-8475cc095af1.jpg)
|
||
|
||
# HTTP ????
|
||
|
||
???????????????????е????????У???????????????????????????????????????
|
||
|
||
| ???? | ??? | ?????? |
|
||
| --- | --- | --- |
|
||
| 1XX | Informational??????????? | ???????????????? |
|
||
| 2XX | Success????????? | ??????????????? |
|
||
| 3XX | Redirection??????????? | ??????и??????????????? |
|
||
| 4XX | Client Error?????????????? | ????????????????? |
|
||
| 5XX | Server Error???????????????? | ????????????????? |
|
||
|
||
## 2XX ???
|
||
|
||
**200 OK**
|
||
|
||
**204 No Content**???????????????????????????????????????????岿?????????????????????????????????????????????????????á?
|
||
|
||
**206 Partial Content**
|
||
|
||
## 3XX ?????
|
||
|
||
**301 Moved Permanently**?????????????
|
||
|
||
**302 Found**????????????
|
||
|
||
**303 See Other**
|
||
|
||
?????? HTTP Э??涨 301??302 ????????????????? POST ??????? GET ???????????????????????? 301??302 ?? 303 ??????????? POST ??????? GET ??????
|
||
|
||
**304 Not Modified**???????????????????Щ?????????磺If-Match??If-ModifiedSince??If-None-Match??If-Range??If-Unmodified-Since???????????????????????????? 304 ????
|
||
|
||
**307 Temporary Redirect**???????????? 302 ?????????????? 307 ??????????????????????? POST ??????? GET ??????
|
||
|
||
## 4XX ????????
|
||
|
||
**400 Bad Request**?????????д?????????
|
||
|
||
**401 Unauthorized**??????????????????????????? HTTP ?????BASIC ?????DIGEST ????????????????????????й??????????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/b1b4cf7d-c54a-4ff1-9741-cd2eea331123.jpg)
|
||
|
||
**403 Forbidden**????????????????????б?????????????????ɡ?
|
||
|
||
**404 Not Found**
|
||
|
||
## 5XX ??????????
|
||
|
||
**500 Internal Server Error**????????????????????????????
|
||
|
||
**503 Service Unavilable**????????????????????????????????????????????????????????????
|
||
|
||
# HTTP???
|
||
|
||
HTTP ??????????????????????????? 4 ????????????Σ?????????Ρ??????????Ρ?????????κ?????????Ρ??????????μ??京???????????????????????????
|
||
|
||
## ?????????
|
||
|
||
| ???????? | ??? |
|
||
| -- | -- |
|
||
| Cache-Control | ??????????? |
|
||
| Connection | ????????? ???????? |
|
||
| Date | ???????????????? |
|
||
| Pragma | ??????? |
|
||
| Trailer | ?????????????? |
|
||
| Transfer-Encoding | ??????????????????? |
|
||
| Upgrade | ?????????Э?? |
|
||
| Via | ????????????????? |
|
||
| Warning | ?????? |
|
||
|
||
## ??????????
|
||
|
||
| ???????? | ??? |
|
||
| -- | -- |
|
||
| Accept | ??????????????????? |
|
||
| Accept-Charset | ?????????? |
|
||
| Accept-Encoding | ???????????? |
|
||
| Accept-Language | ?????????????????? |
|
||
| Authorization | Web?????? |
|
||
| Expect | ????????????????? |
|
||
| From | ?????????????? |
|
||
| Host | ???????????????? |
|
||
| If-Match | ?????????ETag?? |
|
||
| If-Modified-Since | ?????????????? |
|
||
| If-None-Match | ??????????? If-Match ???? |
|
||
| If-Range | ???δ???????????? Byte ???Χ???? |
|
||
| If-Unmodified-Since | ????????????????If-Modified-Since???? |
|
||
| Max-Forwards | ??????????? |
|
||
| Proxy-Authorization | ??????????????????????? |
|
||
| Range | ????????Χ???? |
|
||
| Referer | ???????? URI ????????? |
|
||
| TE | ????????????? |
|
||
| User-Agent | HTTP ???????????? |
|
||
|
||
## ?????????
|
||
|
||
| ???????? | ??? |
|
||
| -- | -- |
|
||
| Accept-Ranges | ??????????Χ???? |
|
||
| Age | ?????????????????? |
|
||
| ETag | ??????????? |
|
||
| Location | ????????????????URI |
|
||
| Proxy-Authenticate | ?????????????????????? |
|
||
| Retry-After | ????η?????????????? |
|
||
| Server | HTTP????????????? |
|
||
| Vary | ???????????????????? |
|
||
| WWW-Authenticate | ??????????????????? |
|
||
|
||
## ?????????
|
||
|
||
| ???????? | ??? |
|
||
| -- | -- |
|
||
| Allow | ?????????HTTP???? |
|
||
| Content-Encoding | ???????????????? |
|
||
| Content-Language | ??????????????? |
|
||
| Content-Length | ?????????С????λ?? ???? |
|
||
| Content-Location | ???????????URI |
|
||
| Content-MD5 | ????????????? |
|
||
| Content-Range | ????????λ?÷?Χ |
|
||
| Content-Type | ??????????????? |
|
||
| Expires | ?????????????????? |
|
||
| Last-Modified | ?????????????????? |
|
||
|
||
# ???????
|
||
|
||
## Cookie
|
||
|
||
HTTP Э????????????????????? HTTP Э?龡?????????????????????????HTTP/1.1 ???? Cookie ?????????????
|
||
|
||
????????????????????? Set-Cookie ??Σ???????????????? Cookie ??????浽??????С????????????????????????ж??? Cookie ????????????а??? Cookie ??Σ??????????????????????????????Cookie ?????????????????????У???????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/ff17c103-750a-4bb8-9afa-576327023af9.png)
|
||
|
||
Set-Cookie ??????????????
|
||
|
||
| ???? | ??? |
|
||
| -- | -- |
|
||
| NAME=VALUE | ???? Cookie ?????????????????? |
|
||
| expires=DATE | Cookie ????Ч???????????????????????????????? |
|
||
| path=PATH | ??????????????????? Cookie ????????????????????????????????????? |
|
||
| domain=???? | ??? Cookie ??????????????????????????????? Cookie ??????????????? |
|
||
| Secure | ???? HTTPS ???????????? Cookie |
|
||
| HttpOnly | ?????????? Cookie ????? JavaScript ??????? |
|
||
|
||
**Session ?? Cookie ????**
|
||
|
||
Session ?????????????????????????Σ???? Session ???????Ψ??????Session ID??????????????????? Session ??????????????????????????? Set-Cookie ??Σ????????????? sid ?????????????????? Session ID?????????????? Cookie ????????????У?????????????????????? Session ID??HTTP ???? Session ?? Cookie ???????????????????????????????? Session ????????????Cookie ?????????
|
||
|
||
**????????? Cookie ?????**
|
||
|
||
????? URL ??д???????? URL ??????? sid=xxx ??
|
||
|
||
**??? Cookie ????????????????????д**
|
||
|
||
????????????? Cookie ?ж????????????????????????д??
|
||
|
||
## ????
|
||
|
||
????????淽?????????????????л??????????????????л??档
|
||
|
||
Cache-Control ????????????????
|
||
|
||
Cache-Control: no-cache ????????壬?????????????????????????????к??и???????????????????????????????????????????????????????????к??и???????????????????????????л??档
|
||
|
||
Expires ??ο????????????????????????????????????????? Cache-Control ????? max-age ???????????????? Expires??????????? max-age ??䶮
|
||
|
||
## ???????
|
||
|
||
?????????????????????????? HTML ????????????????? HTML ?????????????????????????????????? HTTP ??????????? TCP ?????????????????????????**???????** ??????????? TCP ?????????ж?? HTTP ????HTTP/1.1????????е??????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/c73a0b78-5f46-4d2d-a009-dab2a999b5d8.jpg)
|
||
|
||
????????????? Connection ?????ν??й???HTTP/1.1 ???HTTP ????????????????????? TCP ??????????????????????????????????? Connection: close ??????HTTP/1.1?????????????????????????????????????? Keep-Alive??
|
||
|
||
???????????????????????????????????????????????????????????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/6943e2af-5a70-4004-8bee-b33d60f39da3.jpg)
|
||
|
||
## ????
|
||
|
||
????Encoding???????????????????????????????У?gzip??compress??deflate??identity?????? identity ????????????????????
|
||
|
||
## ??鴫??
|
||
|
||
??鴫??Chunked Transfer Coding???????????????飬??????????????档
|
||
|
||
## ????????
|
||
|
||
???????????????ж???????????????????????????? boundary ??ζ???????????з???????????????????????Ρ?
|
||
|
||
???磬???????????????????·????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/decb0936-e83c-4a55-840a-fe8aa101ac61.png)
|
||
|
||
## ??Χ????
|
||
|
||
???????????ж???????????????????????????Χ???????????????????δ????????????????????????????????·????????????
|
||
|
||
???????????????? Range ??Σ?????????????Χ?????? Range : bytes = 5001-10000????????????????????? 206 Partial Content ????
|
||
|
||
## ????Э??
|
||
|
||
???????Э???????????????????????????????????????????????滹???????档
|
||
|
||
?漰?????????Σ?Accept??Accept-Charset??Accept-Encoding??Accept-Language??Content-Language??
|
||
|
||
## ????????
|
||
|
||
??????????????????????????????ж???????????????????????????????????
|
||
|
||
## ??????????
|
||
|
||
**????**
|
||
|
||
???????????????????????????????????????????????????????????????????? URL??
|
||
|
||
???????????????????桢?????????????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/c07035c3-a9ba-4508-8e3c-d8ae4c6ee9ee.jpg)
|
||
|
||
**????**
|
||
|
||
????????????????????????????? HTTP ????????Э?????????????????? HTTP ???????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/81375888-6be1-476f-9521-42eea3e3154f.jpg)
|
||
|
||
**???**
|
||
|
||
??? SSL ???????Σ???????????????佨???????????????·??
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/64b95403-d976-421a-8b45-bac89c0b5185.jpg)
|
||
|
||
# HTTPs
|
||
|
||
HTTP ?????°????????
|
||
|
||
1. ?????????????????????????
|
||
2. ???????????????????п???????α???
|
||
3. ???????????????????????п??????????
|
||
|
||
HTTPs ????????Э?飬???? HTTP ??? SSL??Secure Socket Layer?????????? SSL ?? TCP ?????????? SSL??HTTPs ????????????????????????
|
||
|
||
## ????
|
||
|
||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????ù?????????м??????????????????????????????????
|
||
|
||
?????????????????????????????????????????????????????????
|
||
|
||
HTTPs ???? **??????????**????ù????????????????????????????????????????????????????У??????????????????
|
||
|
||
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/110b1a9b-87cd-45c3-a21d-824623715b33.jpg)
|
||
|
||
## ???
|
||
|
||
?????? **???** ???????????????????????й????????????????????????????????????????????????????????????????
|
||
|
||
????????????????CA??Certificate
|
||
Authority??????????????飬??????? CA ????????????
|
||
|
||
???? HTTPs ?????????????????鷢????????????????????е????????????????????????
|
||
|
||
??? OpenSSL ?????????????????????????????????????????????????????????????????顣??????????÷????????????????????????????????????????????????????????????
|
||
|
||
?????????????????а????????????????????????????????????飬???????????С?
|
||
|
||
## ??????
|
||
|
||
SSL ????????????????????
|
||
|