JavaWeb study notes 20/10/9HTTP

HTTP

1.1 What is HTTP?

HTTP (Hypertext Transfer Protocol) is a simple request-response protocol, usually running on top of TCP, which specifies what kind of message the client may send to the server and what kind of response it gets. The headers of the request and response messages are given in ASCII code; the message content has a format similar to MIME.

  • Text: html, string, etc.
  • Hypertext: pictures, music, videos, positioning, etc.
  • Default port: 80 (https:443, s means secure)

1.2 Two eras

  • http/1.0: After the client can connect to the web server, only one web resource can be obtained, and the connection is disconnected
  • http/1.1: After the client can connect to the web server, multiple web resources can be obtained

1.3 HTTP request

  • Client... Request... Server
Request URL:https://www.baidu.com/	请求地址
Request Method:GET	get方法/post方法
status Code:200 OK	状态码: 200
Remote (远程) Address : 14.215.177.39 :443
  1. Request line

    • Request method in request line: GET
    • Request method: Get, Post...
      • get: The request can carry relatively few parameters, the size is limited, and the data content will be displayed in the URL address bar of the browser, which is not safe but efficient
      • post: the opposite of get
  2. Request header

    Accept:	告诉浏览器它所支持的数据类型
    Accept-Encoding: 告诉浏览器它所支持的编码格式(GBK UTF-8 GB2312 ISO8859-1	
    Accept-Language: 告诉浏览器它的语言环境
    cache-Control: 缓存控制
    Connection: 告诉浏览器,请求完成后是断开还是保持连接
    Host: 主机...                                
    

1.4 HTTP response

  1. Server...response...client
Cache-Control: private	缓存控制
Connection: keep-alive	连接:保持连接
Content-Encoding: gzip	编码
Content-Type: text/html;charset=utf-8	类型
  • Response body
Accept:	告诉浏览器它所支持的数据类型
Accept-Encoding: 告诉浏览器它所支持的编码格式(GBK UTF-8 GB2312 ISO8859-1	
Accept-Language: 告诉浏览器它的语言环境
cache-Control: 缓存控制
Connection: 告诉浏览器,请求完成后是断开还是保持连接
Host: 主机   
Refrush: 告诉客户端多久刷新一次
Location: 让网页重新定位                                
  1. Response status code

    200: request response succeeded

    3XX: request redirection (you go back to the new location I gave you)

    4XX: Resource not found, resource does not exist (404)

    5XX: server code error (500, 502 gateway error)

Interview question: When you enter the address in the address bar of your browser and press Enter, the page can be displayed back, what happened?

Guess you like

Origin blog.csdn.net/qq_44685947/article/details/109000017