[Network] difference between get and post methods in HTTP

Source: Internet
Author: User

HTTP defines different methods for interaction with the server. There are four basic methods: Get, post, put, and delete. The full name of a URL is a resource descriptor. We can think that a URL address is used to describe resources on a network, while get, post, put, delete corresponds to the query, modify, add, and delete operations on this resource. Here, you should have a rough understanding. Get is generally used to obtain/query resource information, while post is generally used to update resource information.

According to the HTTP specification, get is used to obtain information, and should be secure and idempotent. The so-called security means that this operation is used to obtain information instead of modifying information. In other words, get requests generally do not have side effects. That is to say, it only obtains the resource information, just like the database query. It does not modify, add data, and does not affect the resource status.

Post indicates a request that may modify resources on the server.

The GET request data is appended to the URL (that is, the data is placed in the HTTP header? Splits the URL and transmits data. parameters are connected with each other.

Post places the submitted data in the packet body of the http package.

The maximum size of data submitted by the get method is 1024 bytes. Theoretically, there is no limit on post. A large amount of data can be transferred. The maximum size of IIS4 is 80 KB, and that of iis5 is kb.

First, "the data submitted in get mode can only be 1024 bytes". Because get submits data through a URL, the amount of data that can be submitted by get is directly related to the URL length. In fact, the URL does not have a parameter ceiling. The HTTP protocol does not limit the URL length. This restriction is imposed by specific browsers and servers. The length of the URL is limited to 2083 bytes (2 k + 35) by IE ). For other browsers, such as Netscape and Firefox, there is no length limit theoretically. The limit depends on the support of the operating system.

Theoretically, there is no size limit on post and no size limit on HTTP specifications. it is inaccurate to say that "the size of post data is limited to 80 K/K, there is no limit on post data, and the restriction is the processing capability of the server's processing program.

In ASP, the server uses request. querystring to obtain get GET request parameters, and request. Form to obtain POST request parameters. In JSP, request. getparameter (\ "XXXX \"), although the JSP also has a request. the getquerystring () method is difficult to use, for example, passing a test. JSP? Name = hyddd & Password = hyddd. What you get with request. getquerystring () is: Name = hyddd & Password = hyddd. In PHP, you can use $ _ Get and $ _ post to obtain data in get and Post respectively, while $ _ request can obtain data in get and post requests. It is worth noting that using $ _ Request in request and PHP in JSP poses a risk. Next time I will write a summary article.

Post is more secure than get. Note: The security mentioned here is not the same as the "Security" mentioned in get. The above "security" only means not to modify data, but here security means the meaning of true security. For example, if you submit data through get, the user name and password will appear in the URL in plain text, because (1) the login page may be cached by the browser, (2) if others view the browser's historical records, they will be able to get your account and password. In addition, using get to submit data may also cause cross-site request forgery attacks.

Get is a type of request to request data from the server, while post is a type of request to submit data to the server. In form, the default method is "get". In essence, get and post are only different sending mechanisms, not a single sending!

Http://www.cnblogs.com/hyddd/archive/2009/03/31/1426026.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.