听说你JavaWeb学的不好?(十八)

91 阅读2分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第18天,点击查看活动详情

接上

    • HTTP协议就是提前制定好的一种消息模板。通过它能让B和S交流

      • 不管你是哪个品牌的浏览器,都是以这种模式发送。
      • 不管你是哪个品牌的WEB服务器,都是以这种模式发送。
  • HTTP的请求协议(B --> S)

    • HTTP的请求协议包括:4部分

      • 请求行
      • 请求头
      • 空白行
      • 请求体
    • HTTP请求协议的具体报文:GET请求

      • GET /servlet05/getServlet?username=lucy&userpwd=1111 HTTP/1.1          请求行
        Host: localhost:8080                                                   请求头
        Connection: keep-alive
        sec-ch-ua: "Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"
        sec-ch-ua-mobile: ?0
        sec-ch-ua-platform: "Windows"
        Upgrade-Insecure-Requests: 1
        User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36
        Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
        Sec-Fetch-Site: same-origin
        Sec-Fetch-Mode: navigate
        Sec-Fetch-User: ?1
        Sec-Fetch-Dest: document
        Referer: http://localhost:8080/servlet05/index.html
        Accept-Encoding: gzip, deflate, br
        Accept-Language: zh-CN,zh;q=0.9
                                                                                  空白行
                                                                                  请求体
        
    • HTTP请求协议的具体报文:POST请求

    • POST /servlet05/postServlet HTTP/1.1 请求行

Host: localhost:8080                                                      请求头
Connection: keep-alive
Content-Length: 25
Cache-Control: max-age=0
sec-ch-ua: "Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
Origin: http://localhost:8080
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost:8080/servlet05/index.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
                                                                    空白行
username=lisi&userpwd=123                                           请求体