HTTP defines different ways to interact with the server, with 4 basic methods, namely get,post,put,delete.
URL full name is a resource descriptor, we can think: a URL address, which is used to describe a network of resources, and HTTP get,post,put,delete corresponding to this resource, change, increase, delete 4 operations. Here, you should have a general understanding, get is generally used to get/query resource information, and post is generally used to update resource information.
Some of the original problems of Get and post in the HTTP specification:
1 according to the HTTP specification, get is used for information acquisition and should be secure and idempotent.
(1) So-called security means that the operation is used to obtain information rather than modify information. In other words, GET requests generally should not have side effects. That is, it simply gets the resource information, just like a database query, without modification, adding data without affecting the state of the resource. (Note: The meaning of security here is simply non-modification information)
(2) idempotent means that multiple requests to the same URL should return the same result.
That is, if the goal is that when a user opens a link, he can be confident that the resource is not changed from his own point of view.
2 according to the HTTP specification, post represents a request that may modify resources on the server.
But in the actual time, many people do not follow the HTTP specification to do, the cause of this problem is many, for example, say:
1. Many people are greedy and use get when updating resources, because the post must go to the form (form), which can be a bit troublesome.
2. The increase of resources, delete, change, check operation, in fact, can be completed through get/post, do not need to use put and delete.
3. Another is that the early web MVC framework designers did not consciously view and design URLs as abstract resources, so a more serious problem is that the traditional web MVC framework basically only supports get and post two HTTP methods, The put and delete methods are not supported.
The above 3 points typically describe the style of the stereotype (no strict adherence to the HTTP specification), with the development of the architecture, there is now rest (representational state Transfer), a set of new styles to support the HTTP specification, here is not much to say, you can refer to the RESTful Web Services.
after talking about the original reason, let's look at the difference between the get and post from the surface as above:
1 GET Request data is appended to the URL (that is, the data is placed in the HTTP protocol header), to split the URL and transfer data, the parameters are connected to &, such as: Login.action?name=hyddd&password=idontknow &VERIFY=%E4%BD%A0%E5%A5%BD. If the data is an English letter/number, sent as is, if it is a space, converted to +, if it is Chinese/other characters, the string is directly encrypted with BASE64, such as:%E4%BD%A0%E5%A5%BD, where the xx in%xx is the symbol in 16 binary notation ASCII.
Post submits the data to the packet in the HTTP packet.
2 Get method submits the data can only be 1024 bytes, theoretically post No limit, can be transmitted a large amount of data, IIS4 in the maximum of 80kb,iis5 100KB "?
In fact, it is wrong to say that it is inaccurate:
(1) First, "The data submitted by the Get method can only be 1024 bytes," Because get is the data submitted through a URL, then the amount of data that get can be submitted is directly related to the length of the URL. In fact, the URL does not have the upper limit of the argument, the HTTP protocol specification does not limit the length of the URL. This restriction is restricted to specific browsers and servers. IE's limit on URL length is 2083 bytes (2k+35). For other browsers, such as Netscape, Firefox, etc., there is theoretically no length limit, and its limitations depend on the support of the operating system. (Note that this is the limit for the entire URL length, not just your parameter value data length)
(2) In theory, the post is no size limit, the HTTP protocol specification is not a size limit, said "post data volume exists 80k/100k size limit" is inaccurate, post data is not limited, the limit is the processing capacity of the server handler.
3 in ASP, the server obtains the GET request parameter with Request.QueryString, obtains the POST request parameter with the Request.Form. In JSP, with Request.getparameter (\ "xxxx\") to obtain, although JSP also has the request.getquerystring () method, but the use of more trouble, such as: Pass a test.jsp?name= HYDDD&PASSWORD=HYDDD, with Request.getquerystring () is: name=hyddd&password=hyddd. In PHP, you can use $_get and $_post to get the data in the get and post separately, while $_request can get the data from the get and post two requests. It should be noted that the use of JSP in the request and PHP use $_request will have hidden trouble, this next time to write an article summary.
The security of 4 post is higher than the security of get. Note: The security described here is not the same concept as the "security" mentioned in get above. The meaning of "security" above is simply not to make data changes, and the meaning of security here is the meaning of true security, such as: submit data through get, user name and password will appear in plaintext on the URL, because (1) the login page may be cached by the browser, (2) Other people to view the browser's history, Then other people can get your account number and password, in addition, using get to submit data may also cause Cross-site request forgery attack.
In summary, get is a request to the server for data, and post is a request to submit data to the server, in form (form), the method defaults to "get", in essence, get and post just send mechanism is different, not one to take a hair!
Transferred from: http://www.cnblogs.com/hyddd/
About the difference between HTTP GET & Post (GO)