First, the URL
HTTP is a TCP-based application-layer protocol in which the HTTP1.1 version supports a continuous connection mechanism (keep-alive), and the vast majority of WEB development is HTTP-based.
The URL of an HTTP is a special Uri,uri that uniquely identifies a resource, but does not necessarily find the resource through a URI, and the URL contains all the information that finds the resource, where the resource can be found by URL.
The URL format is:, http://host[‘:‘port][abs_path] which http represents the HTTP protocol to locate network resources, host representing a legitimate domain name or IP, port for the service port, usually is the URI of the abs_path requested resource, if the URL is not given So when it has to be / given in the form of a request URI, usually the browser will do the work for us.
such as: Input www.baidu.com , the browser will automatically convert to http://www.baidu.com/ .
Second, HTTP request
Request message: Request line, request header, request body
1. Request Line
Request Line Format:方法 + URI + 版本
-
Methods (method)
The difference between GET and POST: TODO
- GET:
- POST:
-
Uri
A URI is a uniform resource identity, which is a unique identifier for a resource on the server.
-
Versions (version)
The http/1.1 version is now generally used.
2. Request Header
The request header contains additional information that the client carries when it passes the request to the server, including information about the client itself.
-
The contents of the request header are as follows:
3. Request Body
The request body is not required for a GET request, and for a POST request, the content of the request needs to be carried in the request body, such as when multiple sets of pictures are requested, and the request is placed in the request body.
Third, HTTP response
The HTTP response message is actually similar to the structure of the HTTP request message, including: status line, response header, response body.
1. Status line
Status line format:版本 + 状态码 + 说明
-
Versions (version)
The http/1.1 version is now generally used.
-
Status Code and description
2. Response header
In addition to the status line, the server is required to carry information about the next access to the resource identified by Request-uri and the server itself, which is placed in the response header.
-
Common response Headers
Iv. examples of HTTP message interactions
-
Request message
-
Response message
HTTP Protocol (2)