12 KiB
????????
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?????
????????????
??????
???????
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???????????????????????????
CONNECT??????????Э?????????
?????Э????? TCP ????
?????? SSL??Secure Sokets Layer????????????? TLS??Transport Layer Security??????????Э?????????????????????????
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 ????????????????????????й??????????????????????
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 ?????????????????????У???????????????
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????????е??????????????????
????????????? Connection ?????ν??й???HTTP/1.1 ???HTTP ????????????????????? TCP ??????????????????????????????????? Connection: close ??????HTTP/1.1?????????????????????????????????????? Keep-Alive??
???????????????????????????????????????????????????????????????????????
????
????Encoding???????????????????????????????У?gzip??compress??deflate??identity?????? identity ????????????????????
??鴫??
??鴫??Chunked Transfer Coding???????????????飬??????????????档
????????
???????????????ж???????????????????????????? boundary ??ζ???????????з???????????????????????Ρ?
???磬???????????????????·????
??Χ????
???????????ж???????????????????????????Χ???????????????????δ????????????????????????????????·????????????
???????????????? Range ??Σ?????????????Χ?????? Range : bytes = 5001-10000????????????????????? 206 Partial Content ????
????Э??
???????Э???????????????????????????????????????????????滹???????档
?漰?????????Σ?Accept??Accept-Charset??Accept-Encoding??Accept-Language??Content-Language??
????????
??????????????????????????????ж???????????????????????????????????
??????????
????
???????????????????????????????????????????????????????????????????? URL??
???????????????????桢?????????????????????????
????
????????????????????????????? HTTP ????????Э?????????????????? HTTP ???????????
???
??? SSL ???????Σ???????????????佨???????????????·??
HTTPs
HTTP ?????°????????
- ?????????????????????????
- ???????????????????п???????α???
- ???????????????????????п??????????
HTTPs ????????Э?飬???? HTTP ??? SSL??Secure Socket Layer?????????? SSL ?? TCP ?????????? SSL??HTTPs ????????????????????????
????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????ù?????????м??????????????????????????????????
?????????????????????????????????????????????????????????
HTTPs ???? ??????????????ù????????????????????????????????????????????????????У??????????????????
???
?????? ??? ???????????????????????й????????????????????????????????????????????????????????????????
????????????????CA??Certificate Authority??????????????飬??????? CA ????????????
???? HTTPs ?????????????????鷢????????????????????е????????????????????????
??? OpenSSL ?????????????????????????????????????????????????????????????????顣??????????÷????????????????????????????????????????????????????????????
?????????????????а????????????????????????????????????飬???????????С?
??????
SSL ????????????????????