Http://blog.csdn.net/qxs965266509/article/details/8082810
Common request header fields in HTTP requests
Accept: the data type supported by the client for high-speed servers.
Accept-charset: Used to tell the server that the client adopts the encoding format
Accept-encoding: Used to tell the server the data compression format supported by the client.
Accept-language: language environment of the Client
HOST: the host name that the client wants to access through this high-speed server.
If-modified-since: the client uses this header to tell the server the cache time of the resource.
Referer: the client uses this header to tell the server from which resource it accesses the server (Anti-leech)
User-Agent: the client uses this header to notify the server of the client's software environment.
COOKIE: the client can use this header to bring data to the server.
Connection: whether to disconnect or continue to maintain the connection after the request is processed
Date: Current Time Value
HTTP Response
Status line: used to describe the server's processing results for the request.
Status Code: 100 ~ 199: the request is successfully received, and the client is required to submit the next request to complete the processing.
200 ~ 299: indicates that the request is successfully received and the entire process has been completed. Common 200
300 ~ 399: to complete the request, the customer needs to further refine the request. For example, the requested resource has been moved to a new address, commonly used 302 (meaning you request me, I want you to find someone else), 307 and 304 (I don't give you this resource, cache by yourself)
400 ~ 499: client requests are incorrect. Commonly Used 404 (meaning that the requested resources are not in the web server) 403 (the server rejects access and has insufficient permissions)
500 ~ 599: Server errors, usually 500
Multiple Response Headers: The response headers are used to describe the basic information of the server and the description of the data. The server can use the description information to notify the client about how to process the data that will be sent back later.
Location: This header is used with the 302 status code to tell the customer who is looking for it.
Server: the server uses this header to tell the browser the type of the server.
Content-encoding: the server uses this header to tell the browser the compression format of data.
Content-Length: the server uses this header to tell the browser the length of the data to be sent back.
Content-Type: the server uses this header to tell the browser the type of data to be sent back.
Last-modified: tells the browser the last cache time of the current resource.
Refresh: Tell the browser how often it will refresh
Content-Disposition: tells the browser to open data as a download
Transfer-encoding: tells the browser the data transfer format
Etag: cache-related Headers
Three header fields prohibited from browser cache:
Expires: Tell the browser how long the sent resource is cached-1 or 0, it is not cached
Cache-control: No-Cache
Pragma: No-Cache
The server uses the preceding two headers to control the browser against caching data.
Entity content: data sent from the server to the client
L
200 (normal)Indicates that everything is normal, and the returned result is a normal request. L
302/307 (temporary redirection)Indicates that the requested document has been temporarily moved elsewhere. The new URL of this document is provided in the location response header. L
304 (not modified)Indicates that the Client Cache version is the latest, and the client should continue to use it. L
403 (Forbidden)The server understands the client request but rejects it. This is usually caused by permission settings for files or directories on the server. L
404 (not found)The server does not have the resources requested by the client. L
500 (internal server error)An error occurs in CGI, ASP, JSP, and other programs on the server.
1. Briefly describe the differences between HTTP 1.1 and HTTP 1.0 based on your understanding. 2. Describe the composition structure of HTTP request messages and HTTP response messages. 3. In what situations does the browser use the get and post methods to access the Web server? If the parameter content sent by the browser to the Web server exceeds 1 kb, which method should I use to send the request message? 4. Describe the meaning of response status codes such as 200, 302, 304, 404, and 500.
5. list three header fields that disable browser cache and write the corresponding settings.
Answer:
1. http1.0 can send only one request and response at a time for each connection to establish a connection, and the request will be closed. http1.0 does not have the Host field;
Http1.1 can send multiple requests and responses in the same connection, and multiple requests can overlap and simultaneously. http1.1 must have the Host field.
2. Request Message structure: a request line, several message headers, and body content. Some message headers and entity content are optional. The message header and entity content must be separated by blank lines.
Response Message structure: a status line, several message headers, and body content. Some message headers and entity content are optional. The message header and entity content must be separated by a blank line.
The difference between the two is that the request message has a request line and the Response Message has a status line.
GET/mail/aa.html HTTP/1.1
Accept: text/html, application/XHTML + XML ,*/*
Accept-language: ZH-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept-encoding: gzip, deflate
HOST: localhost: 8080
If-modified-since: Wed, 17 oct 2012 09:35:13 GMT
If-None-Match: W/"62-1350466513174"
Connection: keep-alive
HTTP/1.1 304 not modified
Server: APACHE-Coyote/1.1
Etag: W/"62-1350466513174"
Date: Wed, 17 oct 2012 09:45:38 GMT
3. the data volume is small, because the get method has a limited data volume of 1 K, and the get method is used to access the Web server without protecting data. The data volume is large, in addition, the POST method is used to access the Web server when there is data to be protected.
If the data volume of the browser Transfer Server exceeds 1 kb, the post method should be used to access the server, because when the POST method transfers data to the server, the transmitted data is first packaged and sent to the web server.
4. What is the meaning of the response status:
200: indicates successful. The result is normal;
302: Indicates redirection to another site;
304: Indicates not modified;
404: The resource cannot be found;
500: indicates an internal server error;
5. expires: Tell the browser how long it will take to cache the sent resources-1 or 0 is not cached
Cache-control: No-Cache
Pragma: No-Cache
HTTP protocol-common request fields in HTTP requests and HTTP response status codes and Response Headers