* [????????](#????????) * [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) * [????](#????) * [???](#???) * [??????](#??????) # ???????? ## 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 ???? ## ?????? ????????????????????????????????????????????????????????????? ?p??????????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 ????????????????????