当前位置:网站首页>Static web server

Static web server

2022-06-25 08:05:00 Mfy's little brother 1

1.HTTP Protocol Brief

  • HTTP Protocol definition Web How the client from Web Server request Web page , And how the server puts Web Page to client .
  • HTTP The protocol takes the request / Response model .
  • The client sends a request message to the server , The request message contains the method of the request 、URL、 Protocol version 、 Request headers and request data .
  • The server responds with a status line , The response includes the version of the protocol 、 Success or error code 、 server information 、 Response headers and response data .

1.1 HTTP request / Response steps

  1. The client connects to Web The server
    One HTTP client , Usually a browser , And Web Server's HTTP port ( Default 80) Build a TCP socket connection

  2. send out HTTP request
    adopt TCP Socket , Client to Web The server sends a text request message , A request message is sent by the request line , Request header , Blank lines and request data 4 Part of it is made up of .

  3. The server accepts the request and returns HTTP Respond to
    Web The server parses the request , Locate request resources . The server writes the resource copy to TCP Socket , Read by client . A response is made by the status line , Response head , Blank lines and data 4 Part of it is made up of

  4. Release the connection TCP Connect
    if connection The model is close, Then the server shuts down TCP Connect , The client passively closes the connection , Release TCP Connect ; if connection The model is keepalive, Then the connection will remain for a period of time , Can continue to receive requests during this time ;

  5. Client browser parsing HTML Content
    The client browser first parses the status line , Check the status code that indicates whether the request was successful . Then parse each response header , The response header tells you that there are several bytes of HTML Documents and character sets of documents . The client browser reads the response data HTML, according to HTML It's formatted with the syntax of , And display... In the browser window .

1.2 Response status code

 Insert picture description here

原网站

版权声明
本文为[Mfy's little brother 1]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250624539073.html