Link: http://www.cnblogs.com/wxf0701/archive/2008/08/17/1269798.html
1. HTTP request format:
<Request line>
<Headers>
<Blank line>
[<Request-body>]
In an HTTP request, the first line must be a request line to describe the request type, resources to be accessed, and the HTTP Version Used. Next is a header section, which describes additional information to be used by the server. After the header is a blank line, you can add any other data [called the body].
2. Difference Between GET and POST
HTTP defines different methods for interaction with the server. The most basic methods are GET and POST.
HTTP-GET and HTTP-POST are standard protocol verbs that use HTTP to encode and transmit variable name/variable value pair parameters and use the relevant request semantics. Each HTTP-GET and HTTP-POST is composed of a series of HTTP request headers that define what the client has requested from the server, and the response is composed of a series of HTTP Response Headers and response data, if the request is successful, a response is returned.
The HTTP-GET Passes parameters in the format of urlencoded text that uses the MIME type application/x-www-form-urlencoded. Urlencoding is a character encoding that ensures that transmitted parameters are composed of compliant texts. For example, the encoding of a space is "% 20 ". The additional parameter can also be considered as a query string.
Like a HTTP-GET, HTTP-POST parameters are URL encoded. However, the variable name/variable value is not transmitted as part of the URL, but is transmitted within the actual HTTP request message.
(1) get is to get data from the server, and post is to send data to the server.
(1) on the client side, the Get method submits data through the URL, and the data can be seen in the URL. In the POST mode, the data is placed in the html header for submission.
(2) For the get method, the server uses Request. QueryString to obtain the value of the variable. For the post method, the server uses Request. Form to obtain the submitted data.
(2) data submitted in GET mode can contain a maximum of 1024 bytes, whereas POST mode does not.
(3) security issues. As mentioned in (1), when Get is used, the parameter is displayed in the address bar, but Post is not. Therefore, if the data is Chinese and non-sensitive, use get. If the data you enter is not Chinese characters and contains sensitive data, use post as well.
Note: security means that this operation is used to obtain information instead of modifying information. Idempotence means that multiple requests to the same URL should return the same result. The complete definition is not as strict as it looks. In other words, GET requests generally do not have side effects. Basically, the goal is that when a user opens a link, she can be confident that the resource has not changed from her own perspective. For example, the front pages of news sites are constantly updated. Although the second request will return a different batch of news, this operation is still considered safe and idempotent because it always returns the current news. And vice versa. POST requests are not that easy. POST indicates a request that may change resources on the server. Taking the news site as an example, the reader's comments to the article should be implemented through the POST request, because the site is already different after the annotation is submitted (for example, an annotation appears below the article ).
The following is a simple example to illustrate their differences:
<! -Submit the form through get and post respectively -->
<Form action = "getpost. asp" METHOD = "get">
<Input type = "text" NAME = "Text" VALUE = "http://wxf0701.cnblogs.com //>
<Input type = "submit" VALUE = "Get mode"> </INPUT>
</FORM>
<BR>
<Form action = "getpost. asp" METHOD = "post">
<Input type = "text" NAME = "Text" VALUE = "http://wxf0701.cnblogs.com/>
<Input type = "submit" VALUE = "Post mode"> </INPUT>
</FORM>
<BR>
<% If Request. QueryString ("Text") <> "" Then %>
The string passed through the get method is: "<B> <% = Request. QueryString (" Text ") %> </B>" <BR>
<% End If %>
<% If Request. Form ("Text") <> "" Then %>
The string passed by Post is: "<B> <% = Request. Form (" Text ") %> </B>" <BR>
<% End If %>