Proxy Site, HTTP Protocol Request Message Request

http protocol

HTTP request message request
The request message that the client sends an HTTP request to the server includes the following format:
It consists of four parts: request line, request header, blank line, and request data.
<br />
Http request message structure.png
• The request line begins with a method symbol, separated by a space, followed by the requested URI and the protocol version.
Get request example, use Charles to retrieve the request:
GET /562f25980001b1b106000338.jpg HTTP/1.1
Host on proxysite
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Accept image/webp,image/*,*/*;q=0.8
Accept-Encoding gzip, deflate, sdch
Accept-Language zh-CN,zh;q=0.8
The first part: request line, used to indicate the type of request, the resources to access, and the HTTP version used.
GET indicates that the request type is GET, and [/562f25980001b1b106000338.jpg] is the resource to be accessed. The last part of the line indicates that the HTTP 1.1 version is used.
The second part: the request header, immediately after the request line (that is, the first line), used to depict additional information to be used by the server
From the second line to the request header, HOST will indicate the destination of the request. User-Agent, both server-side and client-side scripts can access it. It is an important basis for browser-type detection logic. This information is accessed by you. To define, and automatically send in each request, etc.
The third part: blank line, the blank line behind the request header is a must
Even if the fourth part of the request data is empty, there must be a blank line.
Part IV: The request data is also called the subject and any other data can be added.
The request data for this example is empty.
POST request example, using the request captured by Charles:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Content-Length: 40
Connection: Keep-Alive
The first part: the request line, the first line is the post request, and the http1.1 version.
The second part: the request header, the second line to the sixth line.
The third part: blank line, blank line of the seventh line.
Part IV: Request Data, Eighth Line.
HTTP response message Response
Under normal circumstances, the server will return an HTTP response message after receiving and processing the request from the client.
The HTTP response also consists of four parts: the status line, the message header, the blank line, and the response body.
<br />
Http response message format.jpg
HTTP/1.1 200 OK
Date: Fri, 22 May 2009 06:07:21 GMT
Content-Type: text/html; charset=UTF-8
<!–body goes here–>
The first part: The status line consists of the HTTP protocol version number, status code, and status message.
The first behavior status line, (HTTP/1.1) indicates that the HTTP version is version 1.1, the status code is 200, and the status message is (ok)
The second part: The message header, used to explain some additional information to be used by the client
The second and third lines of message headers,
Date: The date and time the response was generated; Content-Type: Specifies the MIME type of HTML (text/html), the encoding type is UTF-8
The third part: blank line, blank line behind message header is required
Part IV: Response text, text information returned by the server to the client.
The html part behind the blank line is the response body.