Introduction to 1.HTTP protocols and messages
HTTP(Hypertext Transport Protocol), which is the Hypertext Transfer Protocol. This protocol details the rules for communicating with each other between the browser and the World Wide Web server .
the content that is transmitted when the client communicates with the server is what we call a message.
HTTP is a communication rule that specifies the format of the message sent to the server by the client , and also specifies the server sent to The message format of the client.
The client is sent to the server called the "request message ", the server is sent to the client called "response message ."
2. Message Format
Message format: message header of the first empty line message
2.1 Request message: Request Header
GET request
get/hello/index.jsp http/1.1 Request First line: Request request Resource "URL" request agreement/version number
Accept: */* Request Header: */* represents the type of document that the client can accept, */* indicates that any type can be accepted
ACCEPT-LANGUAGE:ZH-CN Accept-language: Indicates that the current browser is in the same region, ZH-CN is the client language in Simplified Chinese, en-US English!
user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; trident/4.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. NET4.0E)
When the Accept-encoding:gzip,deflate browser sends a request to the server, it will tell the server-side browser to accept the compression format!
host:localhost:8080 is the IP address and port number of the target host!
Connection:keep-alive represents a communication connection between the browser and the server: Keep-alive means the session remains! The default session connection time is 3000ms!
Cookie:jsessionid=c55836cda892d9124c03cf8fe8311b15 is located on the browser side, and server communication is used!
GET request no blank line and request body!
POST request (roughly the same as get)
Post/hello/target.html http/1.1
Accept:application/x-ms-application, Image/jpeg, Application/xaml+xml, Image/gif, Image/pjpeg, application/ X-MS-XBAP, */*
referer:http://localhost:8080/hello/
Accept-language:zh-cn
user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; trident/4.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. NET4.0E)
content-type:application/x-www-form-urlencoded
Accept-encoding:gzip, deflate
host:localhost:8080
Content-length:14
Connection:keep-alive
Cache-control:no-cache
cookie:jsessionid=774da38c1b78ae288610d77621590345
2.2 Response Message: Response header blank line response body
Response message is the response header [response first line and response header], blank line, response body
http/1.1 OK response First line: Communication protocol/version number response status code
server:apache-coyote/1.1 Server: Apache
Content-type:text/html;charset=utf-8 Response body Encoding type: Content-type
content-length:274 Response Body Length: content-length
Date:tue, APR 10:08:26 GMT response time: Date
Response Status Code:
200: The response is successful
302: Redirect is indicated
404: Wrong URL for the request!
500: Server-side Error!
Brief analysis of Request message and Response message of HTTP protocol