First, the concept: Hypertext Transfer Protocol;
Second, the role: standardized data interaction between the browser and the server;
Three, HTTP interaction process:
(1) client and server to establish a connection;
(2) the client sends a request to the data server;
(3) Upon receipt of the service termination request, processes it, and the processing result in response to the client;
(4) closes the connection of the client and server; (does not turn off immediately after HTTP1.1)
Four, the HTTP request format:
1. Line request: the request mode, the request address, HTTP protocol version; // separated by a space of three fields; // GET /data/info.html HTTP / 1.1
2. request header: message header, used to illustrate some of the general clients accessories to be used;
3. blank line: is located between the request header and request data, the blank line is required;
4. The request data: non-essential; // get no request body, post there is a request body;
V. request method:
(1 ) HTTP1.0: GET ( Query ) , POST ( add ) , the HEAD.
(2 ) HTTP1.1 new: the OPTIONS, PUT ( modified ) , DELETE ( delete ) , the TRACE, the CONNECT.
( 3 ) GET and post difference:
classification |
get |
post |
Data Security |
Unsafe |
Safety |
The amount of data |
4k |
not limited |
speed |
fast |
slow |
Concurrency |
√ |
|
Data sharing |
not support |
stand by |
Data interactively |
Address Bar |
form data |
Six, HTTP response format:
1. The response line: the HTTP version, status codes, the status information;
2. Response Header: Additional information message header, used by the client;
3. blank line: located between the response headers and response entities, blank lines are required;
4. Response entities: text, the server returns information to the browser;
VII status code: three decimal digits, the first status code defines the decimal number of types ;
(1) the classification status code; (2) list of status codes ;
Eight, HTTP Content-table of the type ;
IX header request / response headers are explained:
( 1 ) the request header:
// receiving resource type (xml / json)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Compression type // resources
Accept-Encoding: gzip, deflate, br
// resource locale
Accept-Language: zh-CN,zh;q=0.9
// cache controller
Cache-Control: max-age=0
//Connection Status
Connection: keep-alive
// current host access
Host: www.baidu.com
// user's browser labeling
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/74.0.3729.157 Safari/537.36
( 2 ) response header:
// receiving type resources
accept-ranges: bytes
// maximum response time, in milliseconds
age: 944687
// cache maximum life cycle, in milliseconds
cache-control: max-age=2592000
// content compression formats
content-encoding: gzip
// content type
content-type: application/x-javascript
// returns the current server time
date: Mon, 13 May 2019 07:56:49 GMT
//Last Modified
last-modified: Wed, 13 May 2015 05:30:46 GMT
// response code
status: 200