Summary of HTTP Interview Questions

HTTP: Hypertext Transfer Protocol (agreement, regulation), the protocol specifies in detail the mutual communication rules between the browser and the World Wide Web server
Composition:

  • Request message
    Request steps:
    1. DNS resolution: 1. According to the domain name resolution corresponding to the IP address of the remote server 2. TCP connection (three-way handshake)
    to establish a TCP connection
    and then initiate an HTTP request
    2. The server receives the HTTP request
    for processing
    and returns data
    3. The client receives the returned data
    and processes the data (renders the page)
  • Response message
    status code:
  • 200: The request was successful
  • 202: The server has received the request data but has not processed it yet
  • 301: Moved Permanently
  • 302: Temporary move
  • 304: The requested resource was not modified
  • 400: Syntax error in client request
  • 404: The requested resource does not exist
  • 500: internal server error

1. What is the difference between get and post?

post and get are two request methods of HTTP

Application scenario:

  • get: idempotent request, which will not affect server resources
  • post: It is not an idempotent request, but a scenario registered user that will affect server resources

Message format:

  • get: the request body of the message is empty
  • post: The request body of the message is not empty, and stores the request sent to the server
    Note:

Get request: You can also put the requested parameters in the URL and send them to the server, but compared with the post request, the URL of a request will be kept in the history, but the browser URL has a length limit, so It will affect the length of the request, and the parameters of the post can be passed to support more types of data

2. In an HTTP request, the browser needs to transmit a 4097-byte text data to the server. What methods can be used?

IndexdDB is the local storage of HTML5. It stores some data in the browser (client). When disconnected from the network, the data can be read from the browser for some offline applications.
A cookie identifies a user by recording information on the client side (browser), up to a maximum size of 4 kb.

The url parameter uses the get method to obtain data from the server, and the size cannot be greater than 2 kb.

Session is a mechanism used by the server to record the state of the client.

post is to send data to the server, and the amount of data is large.

Local Storage is also HTML5's local storage, which saves data in the client (usually permanently).

Guess you like

Origin blog.csdn.net/qq_59079803/article/details/124107887