HTTP protocol
1. Four characteristics
HTTP协议
1.四大特性
1.基于TCP/IP作用于应用层之上的协议
2.基于请求响应
3.无状态
cookie
session
token
4.无连接
keep-alive
2. The request response data format
请求首行(请求方式 协议版本)
请求头(一堆k:v键值对) 就类似于开路先锋 携带了一些服务端可以提前知道的信息
(/r/n)(如果请求头里没有内容 那就是 /r/n/r/n)
请求体(发送post请求 携带的数据都会放在请求体中)
3. Response Status Code
The following are common HTTP status codes:
- 200-- request was successful
- 301-- resources (web pages, etc.) is permanently transferred to another URL
- 404 - resources (web pages, etc.) requested does not exist
- 500 - Internal Server Error
HTTP status code classification
classification | Category Description |
---|---|
1** | Information, the server receives the request, the requester needs to continue operation |
2** | Successful operation has been successfully received and processed |
3** | Redirection, further action is required to complete the request |
4** | Client error, the request contains a syntax error or could not fulfill the request |
5** | Server Error The server error has occurred during the processing of the request |
HTTP protocol messaging format requirements
Each HTTP requests and responses follow the same format, an HTTP Header and Body comprising two portions, wherein Body is optional. Header HTTP response has a Content-Type
show content format of the response. As text/html
expressed HTML page.