Understanding the http protocol

HTTP (HyperText TransportProtocol) is the abbreviation of HyperText Transport Protocol, which is used to transmit WWW data. For details of HTTP protocol, please refer to RFC2616. The HTTP protocol adopts a request/response model. The client sends a request to the server, and the request header contains the requested method, URL, protocol version, and a MIME-like message structure containing request modifiers, client information, and content. The server responds with a status line containing the message protocol version, success or error code plus server information, entity meta information, and possibly entity content.

Usually HTTP messages include request messages from the client to the server and response messages from the server to the client. Both types of messages consist of a start line, one or more header fields, a blank line indicating the end of the header fields, and an optional message body. The HTTP header field includes four parts: general header, request header, response header and entity header. Each header field consists of a domain name, a colon (:) and a field value. Domain names are case-insensitive. Any number of spaces may be added before the field value. Header fields may be extended over multiple lines, using at least one space or tab at the beginning of each line.

Mainly remember that the first number of Status-Code in http defines the category of the response, and the last two numbers have no classification effect. The first number may take 5 different values:

  • 1xx: Information response class, indicating that the request is received and processing continues

  • 2xx: handle successful response class, indicating that the action was successfully received, understood and accepted

  • 3xx: Redirect response class, in order to complete the specified action, must accept further processing

  • 4xx: Client error, the client request contains a syntax error or cannot be executed correctly

  • 5xx: Server error, the server cannot execute a correct request correctly

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324918417&siteId=291194637