Network transmission protocol and http protocol, transmission http protocol
Overview: it refers to the constraints and specifications for communication between the server and the client. The data interaction between the client and the server is not disorganized and must follow (based on) certain specifications.
Common protocols:
A) HTTP and HTTPS Hypertext Transfer Protocol B) FTP File Transfer Protocol c) SMTP Simple Mail Transfer Protocol this article mainly introduces http Hypertext Transfer protocol.
1. HTTP protocol
That is, Hypertext Transfer Protocol. websites are based on HTTP protocol. For example, website images, CSS, and JS are all transmitted Based on HTTP protocol. HTTP is a Request from the client to the server and a Response from the server to the client.
Common Request methods include GET, POST, PUT, and DELETE.
2. Request-Request Message:
A) a request is initiated by a client in the following format: request line, request header, and request body. For example:
B) Request Message line: consists of the Request Method, request URL, and Protocol version.
C) Request Message Header
Host: localhost requested Host Cache-Control: max-age = 0 Control cache (no-Cache | no-store) Accept: */* accepted document MIME Type User-Agent: provide the website with the identification of your browser type, operating system and version, CPU type, browser rendering engine, browser language, browser plug-in, and other information. the standard format of the browser UA string is: browser identifier (operating system identifier; encryption level identifier; browser language) Rendering Engine identifier version information Referer: from which URL to jump
Accept-Encoding: acceptable compression format
D) Request Message style: data transmitted to the server
Note: When a form is submitted in the form of post, Content-Type: application/x-www-form-urlencoded is set in the request header. This setting is not required when a request is made in the form of get.
3. Response-Response Message:
A) The response is sent by the server in the following format: Status line, response header, and response body.
B) Response Header:
Date: Response Time Server: Server Information Content-Length: response body Length Content-Type: MIME Type of the response resource
C) response body: Content returned by the server to the client
D) Status Code:
Common status codes: 200 --- the server returns the webpage successfully, 304 --- the document is not modified, 403 --- no permission, 404 --- the requested webpage does not exist, 500 --- server error, 503 --- the service is unavailable
Note: both the client and server transmit data in bytes, which can be understood as text transmission, in this case, the browser needs to clearly know how to parse the data in the text form, and the MIME is to explicitly tell the browser how to handle it.