HTTP messages are made up of plain ASCII text. The message includes the header and the data body part. The message header is a unit of behavior, and each line ends with a CRLF (carriage return and line break). http request:
Examples are as follows:
GET/sample.jspHTTP/1.1
Accept:image/gif.image/jpeg,*/*
Accept-Language:zh-cn
Connection:Keep-Alive
Host:localhost
User-Agent:Mozila/4.0(compatible;MSIE5.01;Window NT5.0)
Accept-Encoding:gzip,deflate
username=jinqiao&password=1234 RequestMethod: OPTIONS,, POST, PUT, DELETE, TRACE, and CONNECT.
GET request to obtain the resource identified by the Request-URI POST appends new data after the resource identified by the Request-URI HEAD request to get the response message header of the resource identified by the Request-URI The PUT request server stores a resource and uses the Request-URI as its identifier DELETE The request server deletes the resource identified by the request-URI The TRACE request server returns the received request information, which is mainly used for testing or diagnostics CONNECT is reserved for future use OPTIONS requests to query the performance of the server, or to query the options and requirements related to the resource
User-Agent: The client's browser information. Connection:close indicates that a short connection is used, and Keep-Alive indicates that the client supports persistent connections. Date: The current time when the message was generated. Accept-Language: The language supported by the client. Cache-Control: Whether the client supports cache. no-cache means that the client does not support cache, such as max-age=3600, tells the User Agent how long the response result of the request is valid, and during the validity period, when the user needs access again, it can be extracted directly from the client locally, without the need to access the server. Referer: The Referer tells the server which URL the request is coming from, which can be used to track the user's web access path.
If-Modified-Since: 如果请求消息包含If-Modified-Since标题 域,GET方法的语法就变成“条件GET”,即“(conditional GET)”。 条件GET方法可以对指定资源进行判断,如果它在If-Modified-Since标题域中的指定日期后发生了更新,才启动传输,否则不传输。这种条件 GET允许被缓存的实体在不必经过多次请求或不必要的数据传输就能进行刷新,从而有助于降低网络负载。
Last-Modified: Sun, 03 Dec 2008 23:52:56 GMT
ETag: “1cbf3-dfd-3a2adcd8″ Generally, it is used in file downloads to identify the last modification time of the response content or the content is more verified, and when the next user agent needs it, the service will first determine whether these two values are the same as those on the server, and the same does not need to return the content. Expires: At what time the response result of the request expires, and before it expires, the agent can return the previous response result directly from the cache. Host: Specifies the host and port number of the requesting resource. HTTP/1.1 requests must specify Host, otherwise the server returns a 400 status code.
http response: Examples are as follows: HTTP/1.1 200 OK
Date: Mon, 04 May 2015 04:47:13 GMT
Server: Apache
Cache-Control: max-age=0
Expires: Mon, 04 May 2015 04:47:13 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8
X-Pad: avoid browser bug
The status line includes: HTTP protocol version number, status code, and text description of the status code. For example: HTTP/1.1 200 OK A status code consists of a three-digit number, and the status code has roughly 5 meanings: 1. 1xx。 information, request received, continue processing. 2. 2xx。 Success. 200 requests are successful; 206 Breakpoint continued. 3. 3xx。 Redirect. Generally jump to the new address. 4. 4xx。 Client error. 404 files do not exist 5. 5xx。 Server error. 500 internal errors.
Set-Cookie: The server sets the client-side cookie. The setting format is name=value, and when setting multiple parameters, the middle is separated by a semicolon. Set-Cookie also uses several parameters: PATH sets the valid path, DOMAIN sets the domain name where the cookie takes effect, Expire sets the validity time of the cookie, and 0 means it will expire when the browser is closed. locatio{filter}n: This parameter implements the redirect when the server returns a 3xx redirect. This protocol is used for the jump of advertising links. Content-Length: The length of the appendage (data entity). |